Skip to content

Commit

Permalink
fix: upgrade the toolchain (#325)
Browse files Browse the repository at this point in the history
* fix rustc version

Signed-off-by: Keming <kemingy94@gmail.com>

* only update when rustup exists

Signed-off-by: Keming <kemingy94@gmail.com>

* update host when toolchain specified

Signed-off-by: Keming <kemingy94@gmail.com>

* update readme

Signed-off-by: Keming <kemingy94@gmail.com>

* move `rustup update` up

---------

Signed-off-by: Keming <kemingy94@gmail.com>
Co-authored-by: messense <messense@icloud.com>
  • Loading branch information
kemingy and messense authored Feb 23, 2025
1 parent 761276d commit 2ea341a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ take a look at the following examples:
| target | No | The `--target` option for Cargo | string | |
| container | No | manylinux docker container image name | string | Default depends on `target` and `manylinux` options, Set to `off` to disable manylinux docker build and build on the host instead. |
| docker-options | No | Additional Docker run options, for passing environment variables and etc. | string |
| rust-toolchain | No | Rust toolchain name | string | Defaults to `stable` for Docker build |
| rust-toolchain | No | Rust toolchain name. | string | Defaults to `stable` for Docker build. To use the latest available version for the host build, the user must specify this in the CI config or repo config. |
| rustup-components | No | Rustup components | string | Defaults to empty |
| working-directory | No | The working directory to run the command in | string | Defaults to the root of the repository |
| sccache | No | Enable sccache for faster builds | boolean | Defaults to `false` |
Expand Down
5 changes: 3 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11890,9 +11890,9 @@ async function dockerBuild(container, maturinRelease, hostHomeMount, args) {
const rustupComponents = core.getInput('rustup-components');
const commands = [
'#!/bin/bash',
'set -e',
'set -euo pipefail',
'echo "::group::Install Rust"',
`which rustup > /dev/null || curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain ${rustToolchain}`,
`command -v rustup &> /dev/null && { rm -frv ~/.rustup/toolchains/; rustup show; } || curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain ${rustToolchain}`,
'export PATH="$HOME/.cargo/bin:$HOME/.local/bin:$PATH"',
`echo "Install Rust toolchain ${rustToolchain}"`,
`rustup override set ${rustToolchain}`,
Expand Down Expand Up @@ -12116,6 +12116,7 @@ async function hostBuild(maturinRelease, args) {
core.startGroup('Install Rust target');
if (rustToolchain && rustToolchain.length > 0) {
core.info(`Installing Rust toolchain ${rustToolchain}`);
await exec.exec('rustup', ['update', '--no-self-update', rustToolchain]);
await exec.exec('rustup', ['override', 'set', rustToolchain]);
await exec.exec('rustup', ['component', 'add', 'llvm-tools-preview'], {
ignoreReturnCode: true
Expand Down
36 changes: 27 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"typescript": "^4.6.2"
},
"devDependencies": {
"@types/node": "^18.11.3",
"@types/node": "^18.19.76",
"@typescript-eslint/parser": "^5.40.1",
"@vercel/ncc": "^0.36.0",
"eslint": "^8.26.0",
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,11 @@ async function dockerBuild(
const commands = [
'#!/bin/bash',
// Stop on first error
'set -e',
'set -euo pipefail',
// Install Rust
'echo "::group::Install Rust"',
`which rustup > /dev/null || curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain ${rustToolchain}`,
// refer to https://github.com/rust-lang/rustup/issues/1167#issuecomment-367061388
`command -v rustup &> /dev/null && { rm -frv ~/.rustup/toolchains/; rustup show; } || curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain ${rustToolchain}`,
'export PATH="$HOME/.cargo/bin:$HOME/.local/bin:$PATH"',
`echo "Install Rust toolchain ${rustToolchain}"`,
`rustup override set ${rustToolchain}`,
Expand Down Expand Up @@ -936,6 +937,7 @@ async function hostBuild(
core.startGroup('Install Rust target')
if (rustToolchain && rustToolchain.length > 0) {
core.info(`Installing Rust toolchain ${rustToolchain}`)
await exec.exec('rustup', ['update', '--no-self-update', rustToolchain])
await exec.exec('rustup', ['override', 'set', rustToolchain])
await exec.exec('rustup', ['component', 'add', 'llvm-tools-preview'], {
ignoreReturnCode: true
Expand Down

0 comments on commit 2ea341a

Please sign in to comment.