1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Publish the `confer-cli` crate to crates.io. Separate from the dist-generated
# release.yml (which is brew + GitHub-release only, and is regenerated by
# `dist generate`, so it must not be hand-edited to add this).
#
# Runs on every `v*` tag alongside the dist release, and can be run by hand
# (workflow_dispatch) to publish the current `main` — used to publish a version
# whose tag predates this workflow.
#
# Requires a repo secret CARGO_REGISTRY_TOKEN: a scoped crates.io API token with
# publish-update on `confer-cli` (crates.io → Account → API Tokens).
name: crates.io
on:
push:
tags:
workflow_dispatch:
permissions:
contents: read
jobs:
publish:
name: cargo publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install stable Rust
run: rustup toolchain install stable --profile minimal --no-self-update
- name: cargo publish (skips cleanly if this version is already on crates.io)
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "${CARGO_REGISTRY_TOKEN}" ]; then
echo "::error::CARGO_REGISTRY_TOKEN secret is not set — add a scoped crates.io token to publish."
exit 1
fi
ver="$(cargo metadata --no-deps --format-version 1 | python3 -c 'import sys,json;print(json.load(sys.stdin)["packages"][0]["version"])')"
if cargo search confer-cli | grep -q "^confer-cli = \"${ver}\""; then
echo "confer-cli ${ver} is already on crates.io — nothing to do."
exit 0
fi
cargo publish --locked