name: Release
on:
push:
tags: ["*"]
permissions:
contents: write
jobs:
ci:
name: CI Gate
uses: ./.github/workflows/ci.yml
build:
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
needs: [ci]
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: linux-amd64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: linux-arm64
cross: true
- target: aarch64-apple-darwin
os: macos-latest
name: macos-arm64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross-compilation deps (Linux arm64)
if: matrix.cross
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
mkdir -p .cargo
echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- name: Verify build
run: echo "Build successful for ${{ matrix.target }}"
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: [ci, build]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify version consistency
run: |
FILE_VERSION=$(cat VERSION | tr -d '[:space:]')
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
TAG_VERSION="${GITHUB_REF_NAME}"
if [ "$FILE_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: VERSION ($FILE_VERSION) != tag ($TAG_VERSION)"
exit 1
fi
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Cargo.toml ($CARGO_VERSION) != tag ($TAG_VERSION)"
exit 1
fi
echo "Version verified: $TAG_VERSION"
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [ci, build, publish]
steps:
- uses: actions/checkout@v4
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true