v0.1.5 #7
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish | |
on: | |
push: | |
tags: | |
- 'v*' | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
# Run all tests first using the reusable workflow | |
tests: | |
uses: ./.github/workflows/tests.yml | |
# Publish job that depends on tests passing | |
publish: | |
name: Publish to crates.io | |
needs: tests | |
runs-on: ubuntu-latest-8-cores | |
environment: publish | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: ${{ runner.os }} | |
- name: Verify version matches tag | |
run: | | |
# Extract version from Cargo.toml | |
CARGO_VERSION=$(grep -E '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') | |
# Get the git tag without the 'v' prefix | |
TAG_VERSION=${GITHUB_REF_NAME#v} | |
echo "Cargo.toml version: $CARGO_VERSION" | |
echo "Git tag version: $TAG_VERSION" | |
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then | |
echo "Error: Version mismatch!" | |
echo "Cargo.toml has version $CARGO_VERSION but git tag is $GITHUB_REF_NAME" | |
exit 1 | |
fi | |
echo "Version check passed!" | |
- name: Build release | |
run: cargo build --release --verbose | |
- name: Publish to crates.io | |
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |