cargo-impact 0.5.0

Blast-radius analysis and selective test execution for Rust workspaces
Documentation
name: Release

on:
  push:
    tags:
      - "v*.*.*"

permissions:
  contents: write

jobs:
  # Build prebuilt binaries for the common targets so users can
  # `cargo binstall cargo-impact` or download from the GitHub release.
  build:
    name: build ${{ matrix.target }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            cross: true
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            ext: .exe
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v6
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
          target: ${{ matrix.target }}
      - name: Install cross (Linux aarch64)
        if: matrix.cross
        uses: taiki-e/install-action@v2
        with:
          tool: cross
      - name: Build release binary
        shell: bash
        run: |
          if [ "${{ matrix.cross }}" = "true" ]; then
            cross build --release --target ${{ matrix.target }} --locked
          else
            cargo build --release --target ${{ matrix.target }} --locked
          fi
      - name: Package artifact
        shell: bash
        run: |
          bin="cargo-impact${{ matrix.ext }}"
          archive="cargo-impact-${{ github.ref_name }}-${{ matrix.target }}"
          mkdir -p "dist/$archive"
          cp "target/${{ matrix.target }}/release/$bin" "dist/$archive/"
          cp README.md LICENSE-MIT LICENSE-APACHE "dist/$archive/"
          cd dist
          if [[ "${{ matrix.target }}" == *windows* ]]; then
            7z a "$archive.zip" "$archive"
            echo "ASSET=dist/$archive.zip" >> "$GITHUB_ENV"
          else
            tar czf "$archive.tar.gz" "$archive"
            echo "ASSET=dist/$archive.tar.gz" >> "$GITHUB_ENV"
          fi
      - uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.target }}
          path: ${{ env.ASSET }}

  github-release:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/download-artifact@v8
        with:
          path: artifacts
          merge-multiple: true
      - name: Create GitHub Release
        uses: softprops/action-gh-release@v3
        with:
          files: artifacts/*
          generate_release_notes: true
          # Pre-1.0 releases are drafts by default — promote manually after smoke test.
          draft: ${{ startsWith(github.ref_name, 'v0.') }}

  # Publish to crates.io. Requires the CRATES_IO_TOKEN repo secret
  # (generate one at https://crates.io/me and add via
  # `gh secret set CRATES_IO_TOKEN --repo asmuelle/cargo-impact`).
  # The job self-skips when the secret is absent so tag pushes don't
  # fail the whole workflow before you've configured crates.io access.
  # pre-release versions (0.3.0-alpha.X, etc.) publish fine — crates.io
  # supports them and just doesn't surface them in default install
  # resolution.
  crates-io:
    needs: build
    runs-on: ubuntu-latest
    env:
      CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
    steps:
      - name: Check for CRATES_IO_TOKEN
        id: check
        run: |
          if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
            echo "skip=true" >> "$GITHUB_OUTPUT"
            echo "::notice::CRATES_IO_TOKEN not set — skipping crates.io publish."
            echo "::notice::Set it with \`gh secret set CRATES_IO_TOKEN\` to enable."
          fi
      - uses: actions/checkout@v6
        if: steps.check.outputs.skip != 'true'
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        if: steps.check.outputs.skip != 'true'
        with:
          toolchain: stable
      - name: cargo publish
        if: steps.check.outputs.skip != 'true'
        run: cargo publish --locked