name: Publish to crates.io
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run (do not actually publish)'
required: false
default: false
type: boolean
env:
CARGO_TERM_COLOR: always
jobs:
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-publish-cargo-${{ hashFiles('Cargo.lock') }}
- name: Run tests
run: cargo test --locked
- name: Publish to crates.io (dry run)
if: github.event.inputs.dry_run == 'true'
run: cargo publish --dry-run
- name: Publish to crates.io
if: github.event.inputs.dry_run != 'true'
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Summary
run: |
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
echo "✅ Dry run completed successfully"
else
echo "✅ Published to crates.io successfully"
echo "🎉 Your crate is now available at: https://crates.io/crates/rsdo"
fi