File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
.github/action/setup-node Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -9,25 +9,21 @@ inputs:
99runs :
1010 using : composite
1111 steps :
12- - name : Get Node.js version from volta
12+ # Extracts the major version from the last version range in engines.node (e.g. >=22.0.0 <23.0.0 || >=24.0.0 <25.0.0 => 24)
13+ # This allows the CI to always use the latest declared LTS without changing the workflow for each new LTS
14+ - name : Get Node.js LTS major version from engines (last range)
1315 shell : bash
14- run : echo "NODE_VERSION=$(jq -r .volta.node package.json)" >> $GITHUB_ENV
15-
16- - name : Get npm version from volta
17- shell : bash
18- run : echo "NPM_VERSION=$(jq -r .volta.npm package.json)" >> $GITHUB_ENV
16+ run : |
17+ NODE_RANGE=$(jq -r .engines.node package.json | awk -F ' *\\|\\| *' '{print $NF}')
18+ NODE_MAJOR=$(echo "$NODE_RANGE" | grep -oE '[0-9]+' | head -1)
19+ echo "NODE_VERSION=$NODE_MAJOR" >> $GITHUB_ENV
1920
2021 - name : Setup Node.js
2122 uses : actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
2223 with :
2324 registry-url : " https://registry.npmjs.org"
2425 node-version : ${{ env.NODE_VERSION || 'lts/*' }}
2526
26- - name : Setup npm version
27- if : ${{ env.NPM_VERSION }}
28- shell : bash
29- run : npm install -g npm@${{ env.NPM_VERSION }}
30-
3127 - name : Check package
3228 if : inputs.check-package
3329 run : npm run package:check
You can’t perform that action at this time.
0 commit comments