v0.4.0 #6
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 to crates.io | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| publish: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Verify package version matches release tag | |
| run: | | |
| CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') | |
| RELEASE_TAG="${{ github.event.release.tag_name }}" | |
| # Strip 'v' prefix if present | |
| RELEASE_VERSION="${RELEASE_TAG#v}" | |
| if [ "$CARGO_VERSION" != "$RELEASE_VERSION" ]; then | |
| echo "Error: Cargo.toml version ($CARGO_VERSION) does not match release tag ($RELEASE_VERSION)" | |
| exit 1 | |
| fi | |
| echo "Version verified: $CARGO_VERSION" | |
| - name: Authenticate with crates.io | |
| uses: rust-lang/crates-io-auth-action@v1 | |
| id: auth | |
| - name: Publish to crates.io | |
| run: cargo publish | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} |