File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,4 +14,5 @@ easy-monitor/nodemon.json
1414.github
1515* .md
1616build.sh
17- test /
17+ test /
18+ scripts /
Original file line number Diff line number Diff line change 1414env :
1515 TEST_COMPLIE : yunnysunny/node-compiler:latest
1616 TEST_RUNTIME : yunnysunny/node-runtime:latest
17-
17+ jobs :
18+ generate-matrix :
19+ runs-on : ubuntu-latest
20+ outputs :
21+ matrix : ${{ steps.gen.outputs.matrix }}
22+ steps :
23+ - name : Checkout repo
24+ uses : actions/checkout@v4
25+
26+ - name : Generate matrix JSON with Node.js
27+ id : gen
28+ run : |
29+ MATRIX_JSON=$(node ./scripts/get_all_versions.mjs)
30+ echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
1831
1932jobs :
2033 docker :
2134 runs-on : ubuntu-latest
2235 strategy :
2336 fail-fast : false
24- matrix :
25- include :
26- # - node-version: 16.20.2
27- # major-version: 16
28- - node-version : 18.20.5
29- major-version : 18
30- - node-version : 20.18.1
31- major-version : 20
32- - node-version : 22.12.0
33- major-version : 22
34- latest : true
37+ matrix : ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
3538 steps :
3639 - name : Checkout
3740 uses : actions/checkout@v3
Original file line number Diff line number Diff line change 1+ async function get_all_versions ( ) {
2+ const response = await fetch ( "https://nodejs.org/dist/index.json" ) ;
3+ const data = await response . json ( ) ;
4+ return data ;
5+ }
6+ async function printLtsVersions ( versions ) {
7+ const include = [ ] ;
8+ let firstLts = false ;
9+ versions . filter ( ( version ) => ! ! version . lts ) . forEach ( ( version ) => {
10+ let latest = false ;
11+ const ltsVersion = version . version
12+ const majorVersion = ltsVersion . split ( '.' ) [ 0 ] . slice ( 1 )
13+ if ( firstLts ) {
14+ firstLts = false ;
15+ latest = true ;
16+ } else {
17+ latest = false ;
18+ }
19+ if ( majorVersion >= 16 ) {
20+ include . push ( {
21+ 'node-version' : ltsVersion ,
22+ 'major-version' : majorVersion ,
23+ 'latest' : latest ,
24+ } ) ;
25+ }
26+ } ) ;
27+ console . log ( JSON . stringify ( { include} ) ) ;
28+ }
29+
30+ const versions = await get_all_versions ( ) ;
31+ printLtsVersions ( versions ) ;
You can’t perform that action at this time.
0 commit comments