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
- 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
- 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."