name: Publish to crates.io
on:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Refuse releases not contained in main
run: |
git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
git merge-base --is-ancestor "$GITHUB_SHA" refs/remotes/origin/main \
|| { echo "::error::release commit $GITHUB_SHA is not contained in main"; exit 1; }
- uses: dtolnay/rust-toolchain@stable
- run: cargo test
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}