@@ -80,10 +80,54 @@ jobs:
80
80
git config --global user.name "npm CLI robot"
81
81
- name : Setup Node
82
82
uses : actions/setup-node@v3
83
+ id : node
83
84
with :
84
85
node-version : 18.x
85
- - name : Install npm@8
86
- run : npm i --prefer-online --no-fund --no-audit -g npm@8
86
+ check-latest : contains('18.x', '.x')
87
+
88
+ # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
89
+ - name : Update Windows npm
90
+ if : |
91
+ matrix.platform.os == 'windows-latest' && (
92
+ startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
93
+ )
94
+ run : |
95
+ curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
96
+ tar xf npm-7.5.4.tgz
97
+ cd package
98
+ node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
99
+ cd ..
100
+ rmdir /s /q package
101
+
102
+ # Start on Node 10 because we dont test on anything lower
103
+ - name : Install npm@7 on Node 10
104
+ shell : bash
105
+ if : startsWith(steps.node.outputs.node-version, 'v10.')
106
+ id : npm-7
107
+ run : |
108
+ npm i --prefer-online --no-fund --no-audit -g npm@7
109
+ echo "updated=true" >> "$GITHUB_OUTPUT"
110
+
111
+ - name : Install npm@8 on Node 12
112
+ shell : bash
113
+ if : startsWith(steps.node.outputs.node-version, 'v12.')
114
+ id : npm-8
115
+ run : |
116
+ npm i --prefer-online --no-fund --no-audit -g npm@8
117
+ echo "updated=true" >> "$GITHUB_OUTPUT"
118
+
119
+ - name : Install npm@9 on Node 14/16/18.0
120
+ shell : bash
121
+ if : startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
122
+ id : npm-9
123
+ run : |
124
+ npm i --prefer-online --no-fund --no-audit -g npm@9
125
+ echo "updated=true" >> "$GITHUB_OUTPUT"
126
+
127
+ - name : Install npm@latest on Node
128
+ if : ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
129
+ run : npm i --prefer-online --no-fund --no-audit -g npm@latest
130
+
87
131
- name : npm Version
88
132
run : npm -v
89
133
- name : Install Dependencies
@@ -181,24 +225,54 @@ jobs:
181
225
git config --global user.name "npm CLI robot"
182
226
- name : Setup Node
183
227
uses : actions/setup-node@v3
228
+ id : node
184
229
with :
185
230
node-version : ${{ matrix.node-version }}
231
+ check-latest : contains(matrix.node-version, '.x')
232
+
233
+ # node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
186
234
- name : Update Windows npm
187
- # node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
188
- if : matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
235
+ if : |
236
+ matrix.platform.os == 'windows-latest' && (
237
+ startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
238
+ )
189
239
run : |
190
240
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
191
241
tar xf npm-7.5.4.tgz
192
242
cd package
193
243
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
194
244
cd ..
195
245
rmdir /s /q package
196
- - name : Install npm@7
197
- if : startsWith(matrix.node-version, '10.')
198
- run : npm i --prefer-online --no-fund --no-audit -g npm@7
199
- - name : Install npm@8
200
- if : ${{ !startsWith(matrix.node-version, '10.') }}
201
- run : npm i --prefer-online --no-fund --no-audit -g npm@8
246
+
247
+ # Start on Node 10 because we dont test on anything lower
248
+ - name : Install npm@7 on Node 10
249
+ shell : bash
250
+ if : startsWith(steps.node.outputs.node-version, 'v10.')
251
+ id : npm-7
252
+ run : |
253
+ npm i --prefer-online --no-fund --no-audit -g npm@7
254
+ echo "updated=true" >> "$GITHUB_OUTPUT"
255
+
256
+ - name : Install npm@8 on Node 12
257
+ shell : bash
258
+ if : startsWith(steps.node.outputs.node-version, 'v12.')
259
+ id : npm-8
260
+ run : |
261
+ npm i --prefer-online --no-fund --no-audit -g npm@8
262
+ echo "updated=true" >> "$GITHUB_OUTPUT"
263
+
264
+ - name : Install npm@9 on Node 14/16/18.0
265
+ shell : bash
266
+ if : startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
267
+ id : npm-9
268
+ run : |
269
+ npm i --prefer-online --no-fund --no-audit -g npm@9
270
+ echo "updated=true" >> "$GITHUB_OUTPUT"
271
+
272
+ - name : Install npm@latest on Node
273
+ if : ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
274
+ run : npm i --prefer-online --no-fund --no-audit -g npm@latest
275
+
202
276
- name : npm Version
203
277
run : npm -v
204
278
- name : Install Dependencies
0 commit comments