Skip to content

Commit 7a580eb

Browse files
committed
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.
1 parent 2e8ce45 commit 7a580eb

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

.agents/skills/smbcloud-cli-release/SKILL.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ The npm CLI detects the GitHub OIDC environment automatically and exchanges it f
140140

141141
When cross-compiling in CI, the Rust toolchain used for `rustup target add` must match the toolchain used by `cargo build`.
142142

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.
144146

145147
If the workflow installs a target for one toolchain but Cargo builds with another, CI can fail with:
146148

@@ -149,13 +151,23 @@ If the workflow installs a target for one toolchain but Cargo builds with anothe
149151

150152
This can happen even when `rustup target add <target>` already ran successfully.
151153

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:
153163

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
157169

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.
159171

160172
### Trusted publisher command
161173

.github/workflows/release-npm.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,26 @@ jobs:
7575
7676
echo "RELEASE_VERSION=${release_version}" >> "$GITHUB_ENV"
7777
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+
7889
- name: Install toolkit
7990
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
91+
with:
92+
toolchain: ${{ env.RUST_TOOLCHAIN }}
8093

8194
- name: Install Rust target
8295
shell: bash
8396
run: |
84-
rustup target add ${{ matrix.build.TARGET }}
97+
rustup target add ${{ matrix.build.TARGET }} --toolchain ${{ env.RUST_TOOLCHAIN }}
8598
rustup target list --installed
8699
87100
- name: Create .env file

0 commit comments

Comments
 (0)