name: Publish to 🦀 crates.io
on:
release:
types: [published]
workflow_dispatch:
inputs:
dry_run:
description: "Perform a dry run (no actual publish)"
type: boolean
default: true
env:
CARGO_MANIFEST_PATH: Cargo.toml
jobs:
publish-crates-io:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- name: Verify package
run: cargo package --manifest-path ${{ env.CARGO_MANIFEST_PATH }} --allow-dirty
- name: Publish (dry run)
if: ${{ github.event.inputs.dry_run == 'true' }}
run: cargo publish --manifest-path ${{ env.CARGO_MANIFEST_PATH }} --dry-run
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish to crates.io
if: ${{ github.event.inputs.dry_run != 'true' }}
run: cargo publish --manifest-path ${{ env.CARGO_MANIFEST_PATH }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}