Align CI Rust toolchain with rust-toolchain.toml
Update release workflow and documentation to read the Rust toolchain version from rust-toolchain.toml and pass it explicitly to the dtolnay/rust-toolchain action. This ensures the workflow uses a single source of truth for the Rust version and avoids implicit action behavior.
Seto Elkahfi committed
Mar 28, 2026 at 21:17 UTC
7a580eb4b035a4e8b60130b8265d5f8568af02ec
2 files changed
+32
-7
.agents/skills/smbcloud-cli-release/SKILL.md
+18
-6
@@ -140,7 +140,9 @@ The npm CLI detects the GitHub OIDC environment automatically and exchanges it f
140
141
When cross-compiling in CI, the Rust toolchain used for `rustup target add` must match the toolchain used by `cargo build`.
142
143
-For this repo, check `rust-toolchain.toml` first and keep the workflow matrix aligned with it.
143
+For this repo, `rust-toolchain.toml` is the source of truth.
144
+
145
+Do not duplicate the Rust version in the matrix unless the workflow intentionally tests multiple toolchains.
146
147
If the workflow installs a target for one toolchain but Cargo builds with another, CI can fail with:
148
@@ -149,13 +151,23 @@ If the workflow installs a target for one toolchain but Cargo builds with anothe
151
152
This can happen even when `rustup target add <target>` already ran successfully.
153
152
-Preferred pattern:
154
+### dtolnay action behavior
155
+
156
+For the pinned `dtolnay/rust-toolchain` revision used in this repo, do not assume the action will infer the toolchain from `rust-toolchain.toml` without input.
157
+
158
+A workflow can fail with:
159
+
160
+- `'toolchain' is a required input`
161
+
162
+Preferred pattern in this repo:
163
154
-- install the requested toolchain explicitly
155
-- run `rustup target add <target> --toolchain <toolchain>`
156
-- run `cargo +<toolchain> build --target <target>`
164
+- read `channel = "..."` from `rust-toolchain.toml`
165
+- write it to `RUST_TOOLCHAIN` in `GITHUB_ENV`
166
+- pass `toolchain: ${{ env.RUST_TOOLCHAIN }}` to `dtolnay/rust-toolchain`
167
+- run `rustup target add <target> --toolchain ${{ env.RUST_TOOLCHAIN }}`
168
+- run `cargo build --target <target>` after the action sets that toolchain active
169
158
-Do not rely on plain `cargo build` if the repo pin in `rust-toolchain.toml` can differ from the matrix toolchain version.
170
+This keeps `rust-toolchain.toml` as the only Rust version source while avoiding implicit action behavior.
171
172
### Trusted publisher command
173
.github/workflows/release-npm.yml
+14
-1
@@ -75,13 +75,26 @@ jobs:
75
76
echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV"
77
78
+ - name: Read Rust toolchain
79
+ shell: bash
80
+ run: |
81
+ rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
82
+ if [ -z "$rust_toolchain" ]; then
83
+ echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
84
+ exit 1
85
+ fi
86
+
87
+ echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
88
+
89
- name: Install toolkit
90
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
91
+ with:
92
+ toolchain: ${{ env.RUST_TOOLCHAIN }}
93
94
- name: Install Rust target
95
shell: bash
96
run: |
84
- rustup target add ${{ matrix.build.TARGET }}
97
+ rustup target add ${{ matrix.build.TARGET }} --toolchain ${{ env.RUST_TOOLCHAIN }}
98
rustup target list --installed
99
100
- name: Create .env file