git-agent-verdict 0.1.6

Verify that a commit message carries an attested review verdict
name: release

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+*"

env:
  CARGO_TERM_COLOR: always

jobs:
  create-release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
      - uses: taiki-e/create-gh-release-action@v1
        with:
          changelog: CHANGELOG.md
          token: ${{ secrets.GITHUB_TOKEN }}

  upload-assets:
    needs: create-release
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            build_tool: cargo-zigbuild
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            build_tool: cargo-zigbuild
          - target: aarch64-unknown-linux-musl
            os: ubuntu-latest
            build_tool: cargo-zigbuild
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: aarch64-apple-darwin
            os: macos-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      # Produces cargo-binstall-compatible archives (name-target.tar.gz + .sha256)
      # and uploads them to the release for this tag.
      - uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: git-agent-verdict
          target: ${{ matrix.target }}
          build-tool: ${{ matrix.build_tool || 'cargo' }}
          archive: $bin-$target
          checksum: sha256
          token: ${{ secrets.GITHUB_TOKEN }}

  publish-crate:
    needs: create-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      # Tolerate a version already on crates.io rather than failing. A version can
      # be published by hand before its tag exists, and re-running a half-failed
      # release must not red on the one step that already succeeded.
      # Decided from cargo's own error, not from a crates.io API pre-check: that
      # API rejects a default curl User-Agent, so the check failed closed and ran
      # the publish it was meant to skip.
      - name: Publish unless this version is already on crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          set -eu
          # Capture OUTSIDE the checkout: cargo publish refuses on a dirty working
          # directory, so a log file written here fails the publish it is recording.
          err="$(mktemp)"
          if cargo publish 2>"$err"; then
            exit 0
          fi
          cat "$err" >&2
          grep -qE 'already (exists|been uploaded|uploaded)' "$err"
          echo "Version already on crates.io; nothing to do."