Skip to content

Prepare for crates.io publishing #1

Prepare for crates.io publishing

Prepare for crates.io publishing #1

Workflow file for this run

name: Publish
on:
push:
tags: ["v*"]
jobs:
ci:
uses: ./.github/workflows/ci.yml
publish:
name: Publish
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Verify tag matches Cargo.toml version
run: |
CARGO_VERSION="$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')"
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
exit 1
fi
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
release:
name: GitHub Release
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create GitHub Release
run: gh release create "$GITHUB_REF_NAME" --generate-notes
env:
GH_TOKEN: ${{ github.token }}