Add configurable backup retention #6
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: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: Package ${{ matrix.target }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| use_cross: false | |
| executable: cc-switchy | |
| archive: cc-switchy-${{ github.ref_name }}-x86_64-unknown-linux-gnu.tar.gz | |
| - runner: ubuntu-latest | |
| target: x86_64-unknown-linux-musl | |
| use_cross: true | |
| executable: cc-switchy | |
| archive: cc-switchy-${{ github.ref_name }}-x86_64-unknown-linux-musl.tar.gz | |
| - runner: ubuntu-latest | |
| target: aarch64-unknown-linux-musl | |
| use_cross: true | |
| executable: cc-switchy | |
| archive: cc-switchy-${{ github.ref_name }}-aarch64-unknown-linux-musl.tar.gz | |
| - runner: macos-latest | |
| target: x86_64-apple-darwin | |
| use_cross: false | |
| executable: cc-switchy | |
| archive: cc-switchy-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz | |
| - runner: macos-latest | |
| target: aarch64-apple-darwin | |
| use_cross: false | |
| executable: cc-switchy | |
| archive: cc-switchy-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz | |
| - runner: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| use_cross: false | |
| executable: cc-switchy.exe | |
| archive: cc-switchy-${{ github.ref_name }}-x86_64-pc-windows-msvc.zip | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Check out source | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Install Rust 1.95 target | |
| uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 | |
| with: | |
| toolchain: 1.95.0 | |
| targets: ${{ matrix.target }} | |
| - name: Ensure target standard library is installed | |
| run: rustup target add ${{ matrix.target }} --toolchain 1.95.0 | |
| - name: Install cross 0.2.5 | |
| if: matrix.use_cross | |
| run: cargo install cross --version 0.2.5 --locked | |
| - name: Build with cargo | |
| if: ${{ !matrix.use_cross }} | |
| run: cargo build --locked --release --target ${{ matrix.target }} | |
| - name: Build with cross | |
| if: matrix.use_cross | |
| run: cross build --locked --release --target ${{ matrix.target }} | |
| - name: Verify MUSL static linkage | |
| if: matrix.use_cross | |
| shell: bash | |
| run: | | |
| binary=target/${{ matrix.target }}/release/${{ matrix.executable }} | |
| file "$binary" | |
| if readelf -d "$binary" | grep -q '(NEEDED)'; then | |
| echo 'MUSL binary unexpectedly has dynamic NEEDED entries' >&2 | |
| exit 1 | |
| fi | |
| - name: Package Unix archive | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| mkdir package | |
| cp target/${{ matrix.target }}/release/${{ matrix.executable }} package/ | |
| cp README.md LICENSE THIRD_PARTY_NOTICES.md package/ | |
| tar -C package -czf "${{ matrix.archive }}" . | |
| - name: Package Windows archive | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: | | |
| mkdir package | |
| cp target/${{ matrix.target }}/release/${{ matrix.executable }} package/ | |
| cp README.md LICENSE THIRD_PARTY_NOTICES.md package/ | |
| 7z a "${{ matrix.archive }}" ./package/* | |
| - name: Upload package | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: ${{ matrix.target }} | |
| path: ${{ matrix.archive }} | |
| if-no-files-found: error | |
| publish: | |
| name: Publish GitHub Release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download packages | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate SHA-256 checksums | |
| working-directory: dist | |
| run: sha256sum *.tar.gz *.zip > SHA256SUMS | |
| - name: Publish release | |
| uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2 | |
| with: | |
| generate_release_notes: true | |
| files: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| dist/SHA256SUMS |