name: Continuous Deployment
on:
push:
tags:
- "v*"
workflow_dispatch:
concurrency:
group: deployment
cancel-in-progress: false
jobs:
deployment:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Install Rust (stable)
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Cache cargo registry + build
uses: actions/cache@v5.0.2
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/git/db
~/.cargo/registry/cache
~/.cargo/registry/index
target
key: deployment-${{ hashFiles('**/Cargo.lock') }}
- name: Make sure the tag matches Cargo.toml
run: |
TAG="${GITHUB_REF##*/}"
TOML_VERSION="v$(grep -m1 '^version' Cargo.toml | cut -d '"' -f2)"
if [[ "$TAG" != "$TOML_VERSION" ]]; then
echo "($TAG) and Cargo.toml ($TOML_VERSION) differ. Please update the tag or Cargo.toml."
exit 1
fi
- name: Obtain a token from crates.io
run: cargo login ${{ secrets.CRATES_IO_API_TOKEN }}
- name: Publish to crates.io (dry run)
run: cargo publish --verbose --dry-run
- name: Publish to crates.io
run: cargo publish --verbose