name: Release
on:
push:
tags: ["*"]
permissions:
contents: write
jobs:
ci:
name: CI Gate
uses: ./.github/workflows/ci.yml
build:
name: Build (${{ matrix.arch }})
runs-on: ubuntu-latest
needs: [ci]
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
arch: amd64
- target: aarch64-unknown-linux-gnu
arch: 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 (arm64)
if: matrix.arch == 'arm64'
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: Package
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
ARCHIVE="hoosh-${VERSION}-linux-${{ matrix.arch }}.tar.gz"
tar czf "${ARCHIVE}" -C target/${{ matrix.target }}/release hoosh
sha256sum "${ARCHIVE}" > "${ARCHIVE}.sha256"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: hoosh-${{ matrix.arch }}
path: |
hoosh-*.tar.gz
hoosh-*.sha256
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: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
hoosh-*.tar.gz
hoosh-*.sha256
generate_release_notes: true