name: Release
on:
push:
tags: ['v*.*.*']
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-apple-darwin
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.95"
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
set -euo pipefail
mkdir -p dist
BIN="target/${{ matrix.target }}/release/spec-drift"
test -f "$BIN"
TARBALL="spec-drift-${{ matrix.target }}.tar.gz"
tar -czf "dist/${TARBALL}" -C "target/${{ matrix.target }}/release" spec-drift
( cd dist && shasum -a 256 "${TARBALL}" > "${TARBALL}.sha256" )
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: spec-drift-${{ matrix.target }}
path: dist/spec-drift-${{ matrix.target }}.*
release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -lah dist/
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: dist/*
fail_on_unmatched_files: true
generate_release_notes: true
publish-crate:
name: crates.io
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.95"
- uses: Swatinem/rust-cache@v2
- name: Publish to crates.io (opt-in)
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "${CARGO_REGISTRY_TOKEN:-}" ]; then
echo "CARGO_REGISTRY_TOKEN is not set — skipping crates.io publish."
echo "Set the repo secret CARGO_REGISTRY_TOKEN to enable publishing on tag."
exit 0
fi
cargo publish --locked