name: Publish to crates.io
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Verify release metadata
run: |
EXPECTED_VERSION="${GITHUB_REF#refs/tags/v}"
MANIFEST_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
if [ "$MANIFEST_VERSION" != "$EXPECTED_VERSION" ]; then
echo "::error::Cargo.toml version ${MANIFEST_VERSION} does not match tag ${EXPECTED_VERSION}"
exit 1
fi
cargo metadata --locked --format-version 1 >/dev/null
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-publish-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt --all -- --check
- name: Run clippy
run: cargo clippy --locked --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --locked --all-features --release
- name: Run all tests
run: cargo test --locked --all-features
- name: Run integration tests
run: cargo test --locked --all-features --test '*'
- name: Run doc tests
run: cargo test --locked --doc
- name: Publish solverforge-maps
run: cargo publish --locked --token ${{ secrets.CARGO_REGISTRY_TOKEN }}