mirror of
https://github.com/dtolnay/rust-toolchain.git
synced 2024-11-22 00:39:31 +01:00
Add toolchain expressions like '18 months ago'
This commit is contained in:
parent
0f2a41247f
commit
dab5f91926
3 changed files with 67 additions and 8 deletions
16
.github/workflows/ci.yml
vendored
16
.github/workflows/ci.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
name: [Linux]
|
name: [Linux]
|
||||||
os: [ubuntu]
|
os: [ubuntu]
|
||||||
rust: [nightly, beta, stable, 1.62.0, 1.0.0]
|
rust: [nightly, beta, stable, 1.62.0, 1.0.0, 18 months ago, stable minus 8 releases]
|
||||||
include:
|
include:
|
||||||
- name: macOS
|
- name: macOS
|
||||||
os: macos
|
os: macos
|
||||||
|
@ -26,16 +26,28 @@ jobs:
|
||||||
- name: macOS
|
- name: macOS
|
||||||
os: macos
|
os: macos
|
||||||
rust: 1.62.0
|
rust: 1.62.0
|
||||||
|
- name: macOS
|
||||||
|
os: macos
|
||||||
|
rust: 18 months ago
|
||||||
|
- name: macOS
|
||||||
|
os: macos
|
||||||
|
rust: stable minus 8 releases
|
||||||
- name: Windows
|
- name: Windows
|
||||||
os: windows
|
os: windows
|
||||||
rust: nightly
|
rust: nightly
|
||||||
- name: Windows
|
- name: Windows
|
||||||
os: windows
|
os: windows
|
||||||
rust: 1.62.0
|
rust: 1.62.0
|
||||||
|
- name: Windows
|
||||||
|
os: windows
|
||||||
|
rust: 18 months ago
|
||||||
|
- name: Windows
|
||||||
|
os: windows
|
||||||
|
rust: stable minus 8 releases
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: ./
|
- uses: ./
|
||||||
name: Run dtolnay/rust-toolchain@${{matrix.rust}}
|
name: Run dtolnay/rust-toolchain${{contains(matrix.rust, ' ') && ' for ' || '@'}}${{matrix.rust}}
|
||||||
id: toolchain
|
id: toolchain
|
||||||
with:
|
with:
|
||||||
toolchain: ${{matrix.rust}}
|
toolchain: ${{matrix.rust}}
|
||||||
|
|
29
README.md
29
README.md
|
@ -3,6 +3,8 @@
|
||||||
This GitHub Action installs a Rust toolchain using rustup. It is designed for
|
This GitHub Action installs a Rust toolchain using rustup. It is designed for
|
||||||
one-line concise usage and good defaults.
|
one-line concise usage and good defaults.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
## Example workflow
|
## Example workflow
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -24,6 +26,8 @@ Action being requested. For example "dtolnay/rust-toolchain@nightly" pulls in
|
||||||
the nightly Rust toolchain, while "dtolnay/rust-toolchain@1.42.0" pulls in
|
the nightly Rust toolchain, while "dtolnay/rust-toolchain@1.42.0" pulls in
|
||||||
1.42.0.
|
1.42.0.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
All inputs are optional.
|
All inputs are optional.
|
||||||
|
@ -51,6 +55,31 @@ All inputs are optional.
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</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: 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
|
## License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT
|
The scripts and documentation in this project are released under the [MIT
|
||||||
|
|
30
action.yml
30
action.yml
|
@ -27,6 +27,24 @@ outputs:
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
- id: parse
|
||||||
|
run: |
|
||||||
|
: parse toolchain version
|
||||||
|
if [[ $toolchain =~ ^[0-9]+' '(year|month|week|day)s?' 'ago$ ]]; then
|
||||||
|
if [[ ${{runner.os}} == macOS ]]; then
|
||||||
|
echo "::set-output name=toolchain::1.$((($(date -v-$(sed 's/\([0-9]*\) \(.\).*/\1\2/' <<< $toolchain) +%s)/60/60/24-16569)/7/6))"
|
||||||
|
else
|
||||||
|
echo "::set-output name=toolchain::1.$((($(date --date "$toolchain" +%s)/60/60/24-16569)/7/6))"
|
||||||
|
fi
|
||||||
|
elif [[ $toolchain =~ ^stable' 'minus' '[0-9]+' 'releases?$ ]]; then
|
||||||
|
echo "::set-output name=toolchain::1.$((($(date +%s)/60/60/24-16569)/7/6-${toolchain//[^0-9]/}))"
|
||||||
|
else
|
||||||
|
echo "::set-output name=toolchain::$toolchain"
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
toolchain: ${{inputs.toolchain}}
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- id: flags
|
- id: flags
|
||||||
run: |
|
run: |
|
||||||
: construct rustup command line
|
: construct rustup command line
|
||||||
|
@ -47,18 +65,18 @@ runs:
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: rustup toolchain install ${{inputs.toolchain}}
|
- name: rustup toolchain install ${{steps.parse.outputs.toolchain}}
|
||||||
run: rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
|
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
|
shell: bash
|
||||||
|
|
||||||
- run: rustup default ${{inputs.toolchain}}
|
- run: rustup default ${{steps.parse.outputs.toolchain}}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- id: rustc-version
|
- id: rustc-version
|
||||||
run: |
|
run: |
|
||||||
: create cachekey
|
: create cachekey
|
||||||
DATE=$(rustc +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
|
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 +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
|
HASH=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
|
||||||
echo "::set-output name=cachekey::$(echo $DATE$HASH | head -c12)"
|
echo "::set-output name=cachekey::$(echo $DATE$HASH | head -c12)"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
@ -67,5 +85,5 @@ runs:
|
||||||
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
|
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- run: rustc +${{inputs.toolchain}} --version --verbose
|
- run: rustc +${{steps.parse.outputs.toolchain}} --version --verbose
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
Loading…
Reference in a new issue