@@ -59,17 +59,21 @@ runs:
59
59
shell : bash
60
60
61
61
- id : flags
62
+ env :
63
+ targets : ${{inputs.target}}
64
+ components : ${{inputs.components}}
65
+ shell : bash
62
66
run : |
63
67
: construct rustup command line
64
68
echo "targets=$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)" >> $GITHUB_OUTPUT
65
69
echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT
66
70
echo "downgrade=${{inputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT
71
+
72
+ # The environment variables always need to be set before the caching action
73
+ - name : Setting Environment Variables
67
74
env :
68
- targets : ${{inputs.target}}
69
- components : ${{inputs.components}}
75
+ NEW_RUSTFLAGS : ${{inputs.rustflags}}
70
76
shell : bash
71
- # The environment variables always need to be set before the caching action
72
- - name : " Setting Environment Variables"
73
77
run : |
74
78
if [[ ! -v CARGO_INCREMENTAL ]]; then
75
79
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
@@ -95,23 +99,27 @@ runs:
95
99
if [[ ! -v CARGO_REGISTRIES_CRATES_IO_PROTOCOL ]]; then
96
100
echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse" >> $GITHUB_ENV
97
101
fi
98
- shell : bash
99
- env :
100
- NEW_RUSTFLAGS : ${{inputs.rustflags}}
101
- - name : " Install Rust Problem Matcher"
102
+
103
+ - name : Install Rust Problem Matcher
102
104
if : inputs.matcher == 'true'
103
- run : echo "::add-matcher::${{ github.action_path }}/rust.json"
104
105
shell : bash
106
+ run : echo "::add-matcher::${{ github.action_path }}/rust.json"
105
107
106
108
- name : Install rustup, if needed
109
+ if : runner.os != 'Windows'
110
+ shell : bash
107
111
run : |
108
112
if ! command -v rustup &> /dev/null ; then
109
113
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y
110
114
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
111
115
fi
112
- if : runner.os != 'Windows'
113
- shell : bash
116
+
114
117
- name : rustup toolchain install ${{inputs.toolchain || 'stable'}}
118
+ env :
119
+ toolchain : ${{inputs.toolchain}}
120
+ targets : ${{inputs.target}}
121
+ components : ${{inputs.components}}
122
+ shell : bash
115
123
run : |
116
124
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]]
117
125
then
@@ -132,14 +140,10 @@ runs:
132
140
rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
133
141
rustup default $toolchain
134
142
fi
135
- env :
136
- toolchain : ${{inputs.toolchain}}
137
- targets : ${{inputs.target}}
138
- components : ${{inputs.components}}
139
- shell : bash
140
143
141
- - name : Print installed versions
142
- id : versions
144
+ - id : versions
145
+ name : Print installed versions
146
+ shell : bash
143
147
run : |
144
148
echo "rustc-version=$(rustc --version)" >> $GITHUB_OUTPUT
145
149
rustc --version --verbose
@@ -151,9 +155,9 @@ runs:
151
155
DATE=$(rustc --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
152
156
HASH=$(rustc --version --verbose | sed -ne 's/^commit-hash: //p')
153
157
echo "cachekey=$(echo $DATE$HASH | head -c12)" >> $GITHUB_OUTPUT
154
- shell : bash
155
158
156
- - name : " Downgrade registry access protocol when needed"
159
+ - name : Downgrade registry access protocol when needed
160
+ shell : bash
157
161
run : |
158
162
# Not all versions support setting CARGO_REGISTRIES_CRATES_IO_PROTOCOL
159
163
# On versions 1.66, 1.67, and 1.68.0-nightly the value "sparse" is still unstable.
@@ -163,8 +167,7 @@ runs:
163
167
echo "Downgrade cargo registry protocol to git"
164
168
echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git" >> $GITHUB_ENV
165
169
fi
166
- shell : bash
167
170
168
- - name : " Setup Rust Caching"
171
+ - name : Setup Rust Caching
169
172
if : inputs.cache == 'true'
170
173
uses : Swatinem/rust-cache@v2
0 commit comments