ci(release): Enhance workflow for tag releases and packages #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.target }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux targets | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| cross: false | |
| - target: x86_64-unknown-linux-musl | |
| os: ubuntu-latest | |
| cross: true | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-latest | |
| cross: true | |
| # macOS targets | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| cross: false | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| cross: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Install cross | |
| if: matrix.cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Build with cross | |
| if: matrix.cross | |
| run: cross build --release --target ${{ matrix.target }} | |
| - name: Build with cargo | |
| if: "!matrix.cross" | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package binary (Unix) | |
| shell: bash | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar czvf ../../../ntomb-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ntomb | |
| cd ../../.. | |
| - name: Generate checksum | |
| shell: bash | |
| run: | | |
| shasum -a 256 ntomb-${{ github.ref_name }}-${{ matrix.target }}.tar.gz > ntomb-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256 | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ntomb-${{ matrix.target }} | |
| path: | | |
| ntomb-${{ github.ref_name }}-${{ matrix.target }}.tar.gz | |
| ntomb-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256 | |
| build-packages: | |
| name: Build Linux Packages | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install cargo-deb and cargo-generate-rpm | |
| run: | | |
| cargo install cargo-deb | |
| cargo install cargo-generate-rpm | |
| - name: Build binary for packaging | |
| run: cargo build --release | |
| - name: Build DEB package | |
| run: cargo deb | |
| - name: Build RPM package | |
| run: cargo generate-rpm | |
| - name: Find package files | |
| id: packages | |
| run: | | |
| DEB_FILE=$(find target/debian -name "*.deb" | head -1) | |
| RPM_FILE=$(find target/generate-rpm -name "*.rpm" | head -1) | |
| echo "deb_file=$DEB_FILE" >> $GITHUB_OUTPUT | |
| echo "rpm_file=$RPM_FILE" >> $GITHUB_OUTPUT | |
| echo "deb_name=$(basename $DEB_FILE)" >> $GITHUB_OUTPUT | |
| echo "rpm_name=$(basename $RPM_FILE)" >> $GITHUB_OUTPUT | |
| - name: Generate package checksums | |
| run: | | |
| shasum -a 256 ${{ steps.packages.outputs.deb_file }} > ${{ steps.packages.outputs.deb_file }}.sha256 | |
| shasum -a 256 ${{ steps.packages.outputs.rpm_file }} > ${{ steps.packages.outputs.rpm_file }}.sha256 | |
| - name: Upload DEB/RPM packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ntomb-packages | |
| path: | | |
| ${{ steps.packages.outputs.deb_file }} | |
| ${{ steps.packages.outputs.deb_file }}.sha256 | |
| ${{ steps.packages.outputs.rpm_file }} | |
| ${{ steps.packages.outputs.rpm_file }}.sha256 |