Skip to content

Publish

Publish #2

Workflow file for this run

name: Publish
on:
release:
types: [published]
permissions:
contents: read
id-token: write
jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify tag matches Cargo.toml version
run: |
CARGO_VERSION="v$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')"
if [ "$CARGO_VERSION" != "${{ github.ref_name }}" ]; then
echo "Tag ${{ github.ref_name }} does not match Cargo.toml version $CARGO_VERSION"
exit 1
fi
- name: Authenticate with crates.io
id: auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}