Mirror of github.com/getsigit/si.
Mirrored from https://github.com/getsigit/si.git
Synced Nov 24, 08:15 UTC
Add a crates.io publish workflow using Trusted Publishing
The workflow is dispatched by hand, picks one of the two crates and can do a dry run. It exchanges its OIDC token for a short-lived crates.io token instead of using a stored API key. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Seto Elkahfi committed
Oct 27, 2026 at 21:35 UTC
6907b934cf6ac21f64bd2681b538cdb63ee93ab6
1 file changed
+64
.github/workflows/release-crates.yml
new
+64
@@ -0,0 +1,64 @@
1
+name: Publish to crates.io
2
+
3
+on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ crate:
7
+ description: "Crate to publish. The CLI depends on the API crate, so publish sigit-si-api first."
8
+ type: choice
9
+ options:
10
+ - sigit-si-api
11
+ - sigit-si-cli
12
+ required: true
13
+ dry_run:
14
+ description: "Package and verify without uploading"
15
+ type: boolean
16
+ default: false
17
+
18
+# Publishing uses crates.io Trusted Publishing: the job trades its GitHub OIDC
19
+# token for a short-lived crates.io token, so no long-lived API token is stored
20
+# in the repository. Each crate needs a Trusted Publisher entry in its
21
+# crates.io settings pointing at this repository and the workflow file
22
+# `release-crates.yml`.
23
+permissions:
24
+ contents: read
25
+
26
+jobs:
27
+ publish:
28
+ name: Publish ${{ inputs.crate }}
29
+ runs-on: ubuntu-latest
30
+ permissions:
31
+ contents: read
32
+ id-token: write
33
+ steps:
34
+ - uses: actions/checkout@v4
35
+
36
+ - name: Read Rust toolchain
37
+ shell: bash
38
+ run: |
39
+ rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
40
+ echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
41
+
42
+ - uses: dtolnay/rust-toolchain@stable
43
+ with:
44
+ toolchain: ${{ env.RUST_TOOLCHAIN }}
45
+
46
+ - uses: Swatinem/rust-cache@v2
47
+
48
+ - name: Test
49
+ run: cargo test -p ${{ inputs.crate }}
50
+
51
+ - name: Dry run
52
+ if: ${{ inputs.dry_run }}
53
+ run: cargo publish -p ${{ inputs.crate }} --dry-run
54
+
55
+ - name: Get a crates.io token
56
+ if: ${{ !inputs.dry_run }}
57
+ id: auth
58
+ uses: rust-lang/crates-io-auth-action@v1
59
+
60
+ - name: Publish
61
+ if: ${{ !inputs.dry_run }}
62
+ run: cargo publish -p ${{ inputs.crate }}
63
+ env:
64
+ CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}