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
44
name: rust
# Compiles the crate in the cloud — local cargo is unavailable (Smart App Control)
# and the prod server has no cargo, so this is the only thing that actually verifies
# the Rust SDK builds + is publishable before a crates.io release.
#
# `build` runs on every push/PR/dispatch (compile + dry-run publish).
# `publish` runs ONLY on a `v*` tag push or manual dispatch, and ONLY after
# `build` is green — it does the real `cargo publish` using the CRATES_TOKEN
# repo secret (Settings → Secrets and variables → Actions → New repository secret,
# name CRATES_TOKEN, value = a crates.io API token scoped to publish-update).
# Tag a release with `git tag vX.Y.Z && git push origin vX.Y.Z` and it self-publishes.
on:
push:
branches:
tags:
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable branch as of 2026-07-02
- name: Build (debug)
run: cargo build --verbose
- name: Compile all targets (lib + tests + examples, no run)
run: cargo check --all-targets --verbose
- name: Verify it packages + builds for publish
run: cargo publish --dry-run --verbose
publish:
# Real publish to crates.io. Only on a version tag or a manual run, and only
# if `build` passed. A no-op-with-error if the version already exists on
# crates.io (cargo publish refuses to overwrite) — safe to re-run.
needs: build
if: ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable branch as of 2026-07-02
- name: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: cargo publish --verbose