gem-audit 2.9.0

Ultra-fast, standalone security auditor for Gemfile.lock
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            artifact: gem-audit
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            artifact: gem-audit
          - target: x86_64-apple-darwin
            os: macos-latest
            artifact: gem-audit
          - target: aarch64-apple-darwin
            os: macos-latest
            artifact: gem-audit
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            artifact: gem-audit.exe

    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - uses: Swatinem/rust-cache@v2

      - name: Install cross-compilation tools
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu

      - name: Build
        run: cargo build --release --target ${{ matrix.target }}
        env:
          CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc

      - name: Strip binary (unix)
        if: runner.os != 'Windows'
        run: |
          if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
            aarch64-linux-gnu-strip target/${{ matrix.target }}/release/${{ matrix.artifact }}
          else
            strip target/${{ matrix.target }}/release/${{ matrix.artifact }}
          fi

      - name: Package (unix)
        if: runner.os != 'Windows'
        run: |
          cd target/${{ matrix.target }}/release
          tar czf ../../../gem-audit-${{ matrix.target }}.tar.gz ${{ matrix.artifact }}

      - name: Package (windows)
        if: runner.os == 'Windows'
        run: |
          cd target/${{ matrix.target }}/release
          Compress-Archive -Path ${{ matrix.artifact }} -DestinationPath ../../../gem-audit-${{ matrix.target }}.zip

      - name: Upload artifact
        uses: actions/upload-artifact@v7
        with:
          name: gem-audit-${{ matrix.target }}
          path: gem-audit-${{ matrix.target }}.*

  release:
    name: Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Download artifacts
        uses: actions/download-artifact@v8
        with:
          path: artifacts
          merge-multiple: true

      - name: Generate checksums
        run: |
          cd artifacts
          sha256sum * > sha256sums.txt

      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          files: artifacts/*

  publish-crate:
    name: Publish to crates.io
    needs: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}