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
42
43
name: Publish to crates.io
on:
release:
types:
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout the code
uses: actions/checkout@v6
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Set version from tag
run: |
VERSION="${GITHUB_REF_NAME#v}"
sed -i "s/^version = .*/version = \"${VERSION}\"/" Cargo.toml
# First publish only: the crate does not yet exist on crates.io, so
# trusted publishing cannot be configured. Use the bootstrap token.
# After the crate is live, configure Trusted Publishing on crates.io
# and replace this step with the OIDC auth action (see publish.yaml
# in jsonfg / copc):
#
# - name: Authenticate via Trusted Publishing (OIDC)
# uses: rust-lang/crates-io-auth-action@v1
# id: auth
# env for publish: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Publish depthpack
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN_FOR_NEW_CRATES_ONLY }}