Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
e258f77
Initial commit
dtolnay Oct 9, 2021
4138c80
Add MIT license
dtolnay Oct 9, 2021
f51b131
Add initial attempt at composite Actions logic
dtolnay Oct 9, 2021
6ab2a4a
Print rustc version after install
dtolnay Oct 9, 2021
1b2f63d
Provide rustc version as a workflow output
dtolnay Oct 9, 2021
d115c87
Support specifying target triple
dtolnay Oct 9, 2021
5852257
Support installing additional rustup components
dtolnay Oct 9, 2021
123acc0
Extract target and component flag generation to steps
dtolnay Oct 9, 2021
8fb5bc3
Handle whitespace in comma separated components
dtolnay Oct 9, 2021
a538c0e
Rearrange flags generation into one step
dtolnay Oct 9, 2021
947b7d5
Name flags step
dtolnay Oct 9, 2021
eaa8734
Name in a way that is actually rendered by Actions ui
dtolnay Oct 9, 2021
8e1a49f
Support multiple targets
dtolnay Oct 9, 2021
cd924db
Opt in to downgrade on unavailable components
dtolnay Oct 9, 2021
7f2ec0f
Add readme
dtolnay Oct 9, 2021
23a8e99
Add revs update script
dtolnay Oct 9, 2021
c1964a6
Clean up bash variable naming
dtolnay Oct 9, 2021
1bccaa1
Emit allow-downgrade flag only on nightly with components
dtolnay Oct 9, 2021
2fe8a8e
Test self in CI
dtolnay Dec 27, 2021
29ecc71
Merge pull request #5 from dtolnay/ci
dtolnay Dec 27, 2021
0179615
Replace 'ex.' abbreviation in readme
dtolnay Feb 14, 2022
e8eba93
Increment revs max version to 1.70.0
dtolnay Mar 20, 2022
e9a5c18
Update example workflow in readme to actions/checkout@v3
dtolnay Apr 25, 2022
47fb9d8
Update CI to actions/checkout@v3
dtolnay Apr 25, 2022
89849aa
Merge pull request #6 from dtolnay/checkout
dtolnay Apr 25, 2022
314c329
Move base checkout into loop
dtolnay Apr 25, 2022
0566215
Update update-revs.sh to create clippy and miri branches
dtolnay Apr 25, 2022
88e7c2e
Merge pull request #7 from dtolnay/tools
dtolnay Apr 25, 2022
6b014e5
Attempt to install rustup when not present
thomcc Jun 4, 2022
6ebfe94
Respect `$CARGO_HOME` when auto-installing `rustup`
thomcc Jun 4, 2022
a8259c0
Merge pull request #8 from thomcc/autoinstall-rustup
dtolnay Jun 4, 2022
2dcd099
Move title of rustup install step into the run script
dtolnay Jun 4, 2022
a11e214
Merge pull request #9 from dtolnay/rustup
dtolnay Jun 4, 2022
157fe05
Print git push command at end of update-revs.sh
dtolnay Jun 4, 2022
ac5882a
Merge pull request #10 from dtolnay/push
dtolnay Jun 4, 2022
b88a231
Only do CI for the miri branch on nightly
dtolnay Jun 5, 2022
6b4029f
Merge pull request #11 from dtolnay/mirici
dtolnay Jun 5, 2022
10eb3a9
Disable GitHub Actions run when release branches pushed
dtolnay Jun 17, 2022
933cf18
Add git refs for patch releases
dtolnay Jun 17, 2022
1fe5530
Merge pull request #13 from dtolnay/patch
dtolnay Jun 17, 2022
e04dee5
Disambiguate action name
dtolnay Jun 24, 2022
a21fd5d
Merge pull request #14 from dtolnay/name
dtolnay Jun 24, 2022
4192802
Add icon+color branding for Action
dtolnay Jun 24, 2022
4cbcd90
Add a funding file
dtolnay Jun 24, 2022
2c39999
Install rust-src component by default for miri toolchain
dtolnay Jun 29, 2022
e2fb672
Merge pull request #15 from dtolnay/rustsrc
dtolnay Jun 29, 2022
add0c76
Install xargo with miri toolchain
dtolnay Jun 29, 2022
6f4de0a
Merge pull request #16 from dtolnay/xargo
dtolnay Jun 29, 2022
f4fe19d
Fix default components for miri
dtolnay Jun 29, 2022
e1883a8
Convert readme markdown table to html table
dtolnay Jul 14, 2022
a6f60ec
Wrap description of toolchain input
dtolnay Jul 14, 2022
0bbb8b4
Add example of dated nightly toolchain version
dtolnay Jul 14, 2022
3d5c338
Mention what rev to use when passing toolchain
dtolnay Jul 14, 2022
53c4b46
Add a macOS and Windows job to CI matrix
dtolnay Jul 15, 2022
e2d87b1
Merge pull request #18 from dtolnay/ci
dtolnay Jul 15, 2022
28efc6c
Add example of the 'version' output
dtolnay Jul 15, 2022
e4aceea
Include compiler commit hash, date, and host in the log
dtolnay Jul 15, 2022
18ca32f
Merge pull request #19 from dtolnay/verbose
dtolnay Jul 15, 2022
378ab83
Add an output intended for cache keys
dtolnay Jul 15, 2022
7961e77
Merge pull request #21 from dtolnay/cachekey
dtolnay Jul 15, 2022
e75f9d3
Delete version output
dtolnay Jul 15, 2022
9ca18f9
Merge pull request #22 from dtolnay/noversion
dtolnay Jul 15, 2022
d335e67
Retitle cachekey step
dtolnay Jul 15, 2022
19603a2
Ensure version comes from the just-installed toolchain
dtolnay Jul 15, 2022
1ce4a73
Merge pull request #23 from dtolnay/version
dtolnay Jul 15, 2022
7476109
Add a CI job on rust 1.0.0
dtolnay Jul 15, 2022
4050d6c
Check cache key against expected
dtolnay Jul 15, 2022
6249e85
Merge pull request #24 from dtolnay/check
dtolnay Jul 16, 2022
fd72fa8
Rename `target` to `targets`
9999years Jul 19, 2022
c517642
Add 1.62.1 patch release
dtolnay Jul 19, 2022
6af6d2b
Space out workflow steps
dtolnay Jul 20, 2022
df47cd7
Set CARGO_INCREMENTAL=0
dtolnay Jul 20, 2022
6d6cd0e
Merge pull request #27 from dtolnay/incremental
dtolnay Jul 20, 2022
4582dac
Merge pull request #25 from 9999years/multiple-targets
dtolnay Jul 20, 2022
d872b66
Fill in missing input to rustup command line step
dtolnay Jul 20, 2022
8514966
Format targets conditional more compactly
dtolnay Jul 20, 2022
c9932df
Fix targets input
dtolnay Jul 20, 2022
404bb95
Do the fallback from targets to target as a yaml expression
dtolnay Jul 20, 2022
415f4ee
Fix typo in inputs expression
dtolnay Jul 20, 2022
1f48433
Add to GITHUB_PATH with $HOME instead of ~
silwol Aug 1, 2022
f7003ee
Merge pull request #28 from silwol/master-home-notilde
dtolnay Aug 2, 2022
4d318db
Concise isn't the only point
dtolnay Aug 15, 2022
0f2a412
GitHub Workflows security hardening
dtolnay Sep 2, 2022
dab5f91
Add toolchain expressions like '18 months ago'
dtolnay Sep 25, 2022
ebab191
Merge pull request #31 from dtolnay/expr
dtolnay Sep 25, 2022
b6a0604
Make sure the 'ago' syntax specifies 'stable'
dtolnay Sep 25, 2022
2e4fc08
Merge pull request #32 from dtolnay/ago
dtolnay Sep 25, 2022
bb53cd0
Switch from set-output to $GITHUB_OUTPUT
dtolnay Oct 13, 2022
ba37adf
Merge pull request #34 from dtolnay/output
dtolnay Oct 13, 2022
ba4a065
Enable colors in Cargo output
dtolnay Oct 25, 2022
d593a44
Merge pull request #36 from dtolnay/colors
dtolnay Oct 25, 2022
0a0bbf0
Add branches for minor versions
dtolnay Oct 25, 2022
026b841
Merge pull request #38 from dtolnay/minor
dtolnay Oct 25, 2022
5529c95
Push same commit as both minor and largest patch
dtolnay Oct 25, 2022
03a97c9
Merge pull request #39 from dtolnay/minor
dtolnay Oct 25, 2022
a4398b8
Fix "[: ==: unary operator expected"
dtolnay Oct 25, 2022
55c7845
Merge pull request #40 from dtolnay/minor
dtolnay Oct 25, 2022
e645b0c
Time out workflows after 45 minutes
dtolnay Nov 26, 2022
5f2e2a7
Add 1.66.1 patch release
dtolnay Jan 11, 2023
bf2c4a2
Enable Cargo nightly sparse-registry feature
dtolnay Jan 19, 2023
22cb704
Merge pull request #52 from dtolnay/sparseregistry
dtolnay Jan 19, 2023
60cdf46
Also enable sparse registries with the _new_ environment variable
alex Jan 21, 2023
b4b52b7
Merge pull request #54 from alex/patch-1
dtolnay Jan 21, 2023
68e6c34
Dummy package jsons
dtolnay Jan 21, 2023
3cf1bcc
Merge pull request #55 from dtolnay/packagejson
dtolnay Jan 21, 2023
ce8f658
Revert "Dummy package jsons"
dtolnay Jan 21, 2023
38c74e4
Fix sparse registries environment variable
dtolnay Jan 31, 2023
60436bd
Delete stable sparse registry env variable
dtolnay Jan 31, 2023
d7bc4da
Bash comment
dtolnay Jan 31, 2023
6395c05
Test all the toolchain expressions on all platforms
dtolnay Jan 31, 2023
82765d8
Add coverage of a cargo invocation in CI
dtolnay Jan 31, 2023
c8acf68
Merge pull request #57 from dtolnay/ci
dtolnay Jan 31, 2023
5e9debf
Add output providing the installed toolchain name
dtolnay Jan 31, 2023
0c819c9
Fix CI workflow parse error
dtolnay Jan 31, 2023
c758e63
Merge pull request #58 from dtolnay/name
dtolnay Jan 31, 2023
3fd7e41
Document workflow outputs in a table in readme
dtolnay Feb 1, 2023
9cd00a8
Merge pull request #60 from dtolnay/outputs
dtolnay Feb 1, 2023
bb357d4
Add 1.67.1 patch release
dtolnay Feb 10, 2023
0b8aa5e
Touch up spacing in rustup command
dtolnay Feb 12, 2023
5dd156c
Do not override value of an already set environment variable
dtolnay Feb 12, 2023
dd1a82b
Merge pull request #65 from dtolnay/envset
dtolnay Feb 12, 2023
de1aa37
Set CARGO_REGISTRIES_CRATES_IO_PROTOCOL
dtolnay Feb 12, 2023
785525d
Merge pull request #66 from dtolnay/sparseregistry
dtolnay Feb 12, 2023
f4baa51
Enable -Zrandomize-layout on nightly toolchain
dtolnay Feb 12, 2023
620177c
Merge pull request #67 from dtolnay/randomizelayout
dtolnay Feb 12, 2023
edee0ab
Revert "Enable -Zrandomize-layout on nightly toolchain"
dtolnay Feb 12, 2023
b17a489
Move sparse registry comment out of section title
dtolnay Feb 12, 2023
138ed95
Tweak sparse registry conditional
dtolnay Feb 12, 2023
25dc93b
Merge pull request #69 from dtolnay/sparseregistry
dtolnay Feb 12, 2023
9fd0ad2
Fix not -> !
dtolnay Feb 15, 2023
e6d955b
Fix 'syntax error near unexpected token `!`'
dtolnay Feb 15, 2023
0a1713a
Merge pull request #72 from dtolnay/not
dtolnay Feb 15, 2023
0313d8c
Pass empty string to -z, instead of no arg
dtolnay Feb 15, 2023
df6c627
Overwrite previously set CARGO_REGISTRIES_CRATES_IO_PROTOCOL
dtolnay Feb 15, 2023
52e6953
Merge pull request #74 from dtolnay/gitprotocol
dtolnay Feb 15, 2023
e12eda5
Support a manual trigger on CI workflow
dtolnay Feb 19, 2023
fc32530
Add 1.68.1 patch release
dtolnay Mar 21, 2023
b44cb14
Add 1.68.2 patch release
dtolnay Mar 28, 2023
b051cf3
Expand curl flags
dtolnay Jun 19, 2023
1f5cdb5
Predefine branches up to 1.80
dtolnay Jun 19, 2023
0d263d7
Omit CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse on rustc 1.70+
dtolnay Jun 24, 2023
0e66bd3
Merge pull request #90 from dtolnay/sparsedefault
dtolnay Jun 24, 2023
f361669
Add 1.71.1 patch release
dtolnay Aug 3, 2023
7a26acb
Update actions/checkout@v3 -> v4
dtolnay Sep 5, 2023
6f2eb0d
Work around spurious network errors in curl 8.0
dtolnay Sep 7, 2023
5cb429d
Merge pull request #94 from dtolnay/httpmultiplexing
dtolnay Sep 7, 2023
07e430b
Update doc actions/checkout@v3 -> v4
Mon-ius Sep 17, 2023
1482605
Merge pull request #97 from Mon-ius/master
dtolnay Sep 17, 2023
439cf60
Add 1.72.1 patch release
dtolnay Sep 19, 2023
be73d79
Add 1.74.1 patch release
dtolnay Dec 7, 2023
fdb24fe
feat: Add 1.77.1 patch release
siketyan Mar 31, 2024
dc63535
Merge pull request #104 from siketyan/patch-1
dtolnay Mar 31, 2024
201ca1e
Add 1.77.2 rust release
phsym Apr 10, 2024
7164405
Merge pull request #105 from phsym/patch-1
dtolnay Apr 10, 2024
c24b276
Skip xargo installation for miri toolchain
dtolnay Apr 14, 2024
9a6ad42
Merge pull request #106 from dtolnay/noxargo
dtolnay Apr 14, 2024
56909e6
Centralize references to inputs.toolchain to a single spot
dtolnay Apr 14, 2024
bb45937
Remove toolchain input when toolchain is specified in action rev
dtolnay Apr 14, 2024
18c33af
Add `CARGO_HOME` to `GITHUB_ENV`
dariocurr Apr 30, 2024
b004a9e
Merge pull request #108 from dariocurr/master
dtolnay May 1, 2024
e4e1c59
Combine CARGO_HOME choice into a single step
dtolnay May 1, 2024
22eb75f
Add description for CARGO_HOME step
dtolnay May 1, 2024
d8352f6
Move CARGO_HOME step in front of rustup install
dtolnay May 1, 2024
21dc36f
Predefine branches up to 1.90
dtolnay Jun 13, 2024
7b1c307
Add 1.80.1 patch release
dtolnay Aug 8, 2024
2d6236e
Ignore 'rustup default' failure
dtolnay Nov 18, 2024
315e265
Merge pull request #129 from dtolnay/defaultfail
dtolnay Nov 18, 2024
aacd1c2
Append zeros to toolchain versions truncated by GitHub
dtolnay Dec 14, 2024
a54c7af
Merge pull request #131 from dtolnay/float
dtolnay Dec 14, 2024
c5a29dd
Add 1.84.1 patch release
dtolnay Jan 30, 2025
888c2e1
Predefine branches up to 1.100
dtolnay Mar 15, 2025
56f8432
Add 1.85.1 patch release
dtolnay Mar 18, 2025
d8b2468
Install rustup on windows (including ARM)
joe-p Apr 29, 2025
113d638
Add ubuntu and windows arm to CI
joe-p Apr 29, 2025
9ec87f1
Merge pull request #145 from joe-p/feat/install_rustup_windows
dtolnay Apr 29, 2025
1c80aed
Align curl and rustup-init flags between windows and non-windows
dtolnay Apr 29, 2025
1901dba
Merge pull request #146 from dtolnay/flags
dtolnay Apr 29, 2025
1f3b09e
Download rustup-init.exe to temp dir instead of current dir
dtolnay Apr 29, 2025
636f3b2
Merge pull request #147 from dtolnay/rustuptemp
dtolnay Apr 29, 2025
802126c
Consistently use backslash directories on Windows
dtolnay Apr 29, 2025
3d21cbb
Merge pull request #148 from dtolnay/backslash
dtolnay Apr 29, 2025
f36efba
Fix GITHUB_PATH
dtolnay Apr 29, 2025
449259c
Merge pull request #150 from dtolnay/githubpath
dtolnay Apr 29, 2025
eceb16e
Respect pre-existing CARGO_HOME on Windows
dtolnay Apr 29, 2025
c9b8f05
Merge pull request #149 from dtolnay/wincargohome
dtolnay Apr 29, 2025
d69c8f6
Use rustup.rs advertised download URLs
dtolnay Apr 29, 2025
3038d43
Merge pull request #151 from dtolnay/winrustup
dtolnay Apr 29, 2025
6ff96e9
Clean up trailing whitespace from PR 145
dtolnay Apr 29, 2025
b3b07ba
Merge pull request #152 from dtolnay/trailingwhitespace
dtolnay Apr 29, 2025
2769202
Support pinning rustup version
Techassi May 19, 2025
2801f79
chore: Prepare for forking to stackabletech/actions
NickLarsenNZ May 21, 2025
6eabd7a
chore: Merge locally prepared dtolnay/rust-toolchain
NickLarsenNZ May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions rust-toolchain/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
107 changes: 107 additions & 0 deletions rust-toolchain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Install Rust Toolchain

This GitHub Action installs a Rust toolchain using rustup. It is designed for
one-line concise usage and good defaults.

<br>

## Example workflow

```yaml
name: test suite
on: [push, pull_request]

jobs:
test:
name: cargo test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --all-features
```

The selection of Rust toolchain is made based on the particular @rev of this
Action being requested. For example "dtolnay/rust-toolchain@nightly" pulls in
the nightly Rust toolchain, while "dtolnay/rust-toolchain@1.42.0" pulls in
1.42.0.

<br>

## Inputs

All inputs are optional.

<table>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<tr>
<td><code>toolchain</code></td>
<td>
Rustup toolchain specifier e.g. <code>stable</code>, <code>nightly</code>, <code>1.42.0</code>, <code>nightly-2022-01-01</code>.
<b>Important: the default is to match the @rev as described above.</b>
When passing an explicit <code>toolchain</code> as an input instead of @rev, you'll want to use "dtolnay/rust-toolchain@master" as the revision of the action.
</td>
</tr>
<tr>
<td><code>targets</code></td>
<td>Comma-separated string of additional targets to install e.g. <code>wasm32-unknown-unknown</code></td>
</tr>
<tr>
<td><code>components</code></td>
<td>Comma-separated string of additional components to install e.g. <code>clippy, rustfmt</code></td>
</tr>
</table>

<br>

## Outputs

<table>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
<tr>
<td><code>cachekey</code></td>
<td>A short hash of the installed rustc version, appropriate for use as a cache key. <code>"20220627a831"</code></td>
</tr>
<tr>
<td><code>name</code></td>
<td>Rustup's name for the selected version of the toolchain, like <code>"1.62.0"</code>. Suitable for use with <code>cargo +${{steps.toolchain.outputs.name}}</code>.</td>
</tr>
</table>

<br>

## Toolchain expressions

The following forms are available for projects that use a sliding window of
compiler support.

```yaml
# Installs the most recent stable toolchain as of the specified time
# offset, which may be written in years, months, weeks, or days.
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable 18 months ago
```

```yaml
# Installs the stable toolchain which preceded the most recent one by
# the specified number of minor versions.
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable minus 8 releases
```

<br>

## License

The scripts and documentation in this project are released under the [MIT
License].

[MIT License]: LICENSE
149 changes: 149 additions & 0 deletions rust-toolchain/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: rustup toolchain install
author: David Tolnay
description: Install the Rust toolchain
branding:
icon: activity
color: purple

inputs:
toolchain:
description: Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification
required: true
targets:
description: Comma-separated list of target triples to install for this toolchain
required: false
target:
description: Alias for `targets`
required: false
components:
description: Comma-separated list of components to be additionally installed
required: false
rustup-version:
description: The version of rustup used during installation
required: false
default: 1.28.2

outputs:
cachekey:
description: A short hash of the rustc version, appropriate for use as a cache key. "20220627a831"
value: ${{steps.rustc-version.outputs.cachekey}}
name:
description: Rustup's name for the selected version of the toolchain. "1.62.0" # suitable for use with `cargo +${{steps.toolchain.outputs.name}}`
value: ${{steps.parse.outputs.toolchain}}

runs:
using: composite
steps:
- id: parse
run: |
: parse toolchain version
if [[ $toolchain =~ ^stable' '[0-9]+' '(year|month|week|day)s?' 'ago$ ]]; then
if [[ ${{runner.os}} == macOS ]]; then
echo "toolchain=1.$((($(date -v-$(sed 's/stable \([0-9]*\) \(.\).*/\1\2/' <<< $toolchain) +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
else
echo "toolchain=1.$((($(date --date "${toolchain#stable }" +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
fi
elif [[ $toolchain =~ ^stable' 'minus' '[0-9]+' 'releases?$ ]]; then
echo "toolchain=1.$((($(date +%s)/60/60/24-16569)/7/6-${toolchain//[^0-9]/}))" >> $GITHUB_OUTPUT
elif [[ $toolchain =~ ^1\.[0-9]+$ ]]; then
echo "toolchain=1.$((i=${toolchain#1.}, c=($(date +%s)/60/60/24-16569)/7/6, i+9*i*(10*i<=c)+90*i*(100*i<=c)))" >> $GITHUB_OUTPUT
else
echo "toolchain=$toolchain" >> $GITHUB_OUTPUT
fi
env:
toolchain: ${{inputs.toolchain}}
shell: bash

- id: flags
run: |
: construct rustup command line
echo "targets=$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)" >> $GITHUB_OUTPUT
echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT
echo "downgrade=${{steps.parse.outputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT
env:
targets: ${{inputs.targets || inputs.target || ''}}
components: ${{inputs.components}}
shell: bash

- run: |
: set $CARGO_HOME
echo CARGO_HOME=${CARGO_HOME:-"${{runner.os == 'Windows' && '$USERPROFILE\.cargo' || '$HOME/.cargo'}}"} >> $GITHUB_ENV
shell: bash

- run: |
: install rustup if needed
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail https://sh.rustup.rs | RUSTUP_VERSION="$RUSTUP_VERSION" sh -s -- --default-toolchain none -y
echo "$CARGO_HOME/bin" >> $GITHUB_PATH
fi
if: runner.os != 'Windows'
env:
RUSTUP_VERSION: ${{ inputs.rustup-version }}
shell: bash

- run: |
: install rustup if needed on windows
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail https://win.rustup.rs/${{runner.arch == 'ARM64' && 'aarch64' || 'x86_64'}} --output '${{runner.temp}}\rustup-init.exe'
RUSTUP_VERSION="$RUSTUP_VERSION" '${{runner.temp}}\rustup-init.exe' --default-toolchain none --no-modify-path -y
echo "$CARGO_HOME\bin" >> $GITHUB_PATH
fi
if: runner.os == 'Windows'
env:
RUSTUP_VERSION: ${{ inputs.rustup-version }}
shell: bash

- name: rustup toolchain install ${{steps.parse.outputs.toolchain}}
run: rustup toolchain install ${{steps.parse.outputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
shell: bash

- run: rustup default ${{steps.parse.outputs.toolchain}}
shell: bash
continue-on-error: true # https://github.com/dtolnay/rust-toolchain/issues/127

- id: rustc-version
run: |
: create cachekey
DATE=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
HASH=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
echo "cachekey=$(echo $DATE$HASH | head -c12)" >> $GITHUB_OUTPUT
shell: bash

- run: |
: disable incremental compilation
if [ -z "${CARGO_INCREMENTAL+set}" ]; then
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
fi
shell: bash

- run: |
: enable colors in Cargo output
if [ -z "${CARGO_TERM_COLOR+set}" ]; then
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV
fi
shell: bash

- run: |
: enable Cargo sparse registry
# implemented in 1.66, stabilized in 1.68, made default in 1.70
if [ -z "${CARGO_REGISTRIES_CRATES_IO_PROTOCOL+set}" -o -f "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol ]; then
if rustc +${{steps.parse.outputs.toolchain}} --version --verbose | grep -q '^release: 1\.6[89]\.'; then
touch "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol || true
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
elif rustc +${{steps.parse.outputs.toolchain}} --version --verbose | grep -q '^release: 1\.6[67]\.'; then
touch "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol || true
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git >> $GITHUB_ENV
fi
fi
shell: bash

- run: |
: work around spurious network errors in curl 8.0
# https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/timeout.20investigation
if rustc +${{steps.parse.outputs.toolchain}} --version --verbose | grep -q '^release: 1\.7[01]\.'; then
echo CARGO_HTTP_MULTIPLEXING=false >> $GITHUB_ENV
fi
shell: bash

- run: rustc +${{steps.parse.outputs.toolchain}} --version --verbose
shell: bash
62 changes: 62 additions & 0 deletions rust-toolchain/scripts/update-revs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."

if ! git diff-index --quiet HEAD; then
echo "Not running update-revs.sh because git working directory is dirty" >&2
exit 1
fi

patch_releases=(
1.12.1 1.15.1 1.22.1 1.24.1 1.26.1 1.26.2 1.27.1 1.27.2 1.29.1 1.29.2 1.30.1
1.31.1 1.34.1 1.34.2 1.41.1 1.43.1 1.44.1 1.45.1 1.45.2 1.52.1 1.56.1 1.58.1
1.62.1 1.66.1 1.67.1 1.68.1 1.68.2 1.71.1 1.72.1 1.74.1 1.77.1 1.77.2 1.80.1
1.84.1 1.85.1
)

releases() {
printf "%s\n" 1.{0..100}.0 ${patch_releases[@]} | sort -V
}

base=$(git rev-parse HEAD)
push=()

declare -A minor
for rev in `releases`; do
minor[${rev%.*}]=$rev
done

for rev in `releases` stable beta nightly; do
echo "Updating $rev branch"
git checkout --quiet "$base"
git branch --quiet --delete --force $rev &>/dev/null || true
if [[ $rev == 1* ]]; then
sed -i "/^ toolchain:/,+2d; s/\${{inputs\.toolchain}}/$rev/" action.yml
else
sed -i "s/required: true/required: false\n default: $rev/" action.yml
fi
git add action.yml
git commit --quiet --message "toolchain: $rev"
git checkout --quiet -b $rev
push+=("$rev:refs/heads/$rev")
if [ "${minor[${rev%.*}]}" == $rev ]; then
push+=("$rev:refs/heads/${rev%.*}")
fi
done

for tool in clippy miri; do
echo "Updating $tool branch"
git checkout --quiet --detach nightly
git branch --quiet --delete --force $tool &>/dev/null || true
default=$tool
if [ $tool == miri ]; then default+=,\ rust-src; fi
sed -i "/required: false/{N;s/\n$/\n default: $default\n/}" action.yml
git add action.yml
git commit --quiet --message "components: $tool"
git checkout --quiet -b $tool
push+=("$tool:refs/heads/$tool")
done

git checkout --quiet "$base"

echo "git push origin --force-with-lease ${push[@]}"
Loading