@@ -17,12 +17,22 @@ const checkIfThereAreNewVersions = async (github) => {
1717
1818 for ( let supportedVersion of supportedVersions ) {
1919 const { stdout } = await exec ( `ls ${ supportedVersion } ` ) ;
20-
21- const { stdout : fullVersionOutput } = await exec ( `. ./functions.sh && get_full_version ./${ supportedVersion } /${ stdout . trim ( ) . split ( "\n" ) [ 0 ] } ` , { shell : "bash" } ) ;
22-
23- console . log ( fullVersionOutput ) ;
24-
25- latestSupportedVersions [ supportedVersion ] = { fullVersion : fullVersionOutput . trim ( ) } ;
20+ const baseVersions = stdout . trim ( ) . split ( "\n" ) ;
21+
22+ const debianVersion = baseVersions . find ( v => ! v . startsWith ( "alpine" ) ) ;
23+ const { stdout : debianVersionOutput } = await exec ( `. ./functions.sh && get_full_version ./${ supportedVersion } /${ debianVersion } ` , { shell : "bash" } ) ;
24+
25+ const alpineVersion = baseVersions . find ( v => v . startsWith ( "alpine" ) ) ;
26+ const { stdout : alpineVersionOutput } = await exec ( `. ./functions.sh && get_full_version ./${ supportedVersion } /${ alpineVersion } ` , { shell : "bash" } ) ;
27+
28+ const fullVersion = { debian : debianVersionOutput . trim ( ) , alpine : alpineVersionOutput . trim ( ) } ;
29+ console . log ( `${ supportedVersion } : debian=${ fullVersion . debian } , alpine=${ fullVersion . alpine } ` ) ;
30+
31+ latestSupportedVersions [ supportedVersion ] = {
32+ fullVersion : fullVersion . debian ,
33+ alpineVersion : fullVersion . alpine ,
34+ alpineIsBehind : fullVersion . debian !== fullVersion . alpine
35+ } ;
2636 }
2737
2838 const { data : availableVersionsJson } = await github . request ( 'https://nodejs.org/download/release/index.json' ) ;
@@ -39,9 +49,25 @@ const checkIfThereAreNewVersions = async (github) => {
3949 if ( latestSupportedVersions [ availableMajor ] == null ) {
4050 continue ;
4151 }
42- const [ _latestMajor , latestMinor , latestPatch ] = latestSupportedVersions [ availableMajor ] . fullVersion . split ( "." ) ;
43- if ( latestSupportedVersions [ availableMajor ] && ( Number ( availableMinor ) > Number ( latestMinor ) || ( availableMinor === latestMinor && Number ( availablePatch ) > Number ( latestPatch ) ) ) ) {
44- filteredNewerVersions [ availableMajor ] = { fullVersion : `${ availableMajor } .${ availableMinor } .${ availablePatch } ` } ;
52+
53+ const supported = latestSupportedVersions [ availableMajor ] ;
54+ const [ _latestMajor , latestMinor , latestPatch ] = supported . fullVersion . split ( "." ) ;
55+ const [ _alpineMajor , alpineMinor , alpinePatch ] = supported . alpineVersion . split ( "." ) ;
56+
57+ const availableFullVersion = `${ availableMajor } .${ availableMinor } .${ availablePatch } ` ;
58+
59+ const newDebian = Number ( availableMinor ) > Number ( latestMinor ) || ( availableMinor === latestMinor && Number ( availablePatch ) > Number ( latestPatch ) ) ;
60+ const newAlpine = Number ( availableMinor ) > Number ( alpineMinor ) || ( availableMinor === alpineMinor && Number ( availablePatch ) > Number ( alpinePatch ) ) ;
61+
62+ const isCatchup = supported . alpineIsBehind && newAlpine && availableFullVersion === supported . fullVersion ;
63+
64+ // Alpine will be always behind or equal to Debian
65+ // So if Debian is new version, then alpineOnly is always false. And vice versa
66+ if ( newDebian || isCatchup ) {
67+ filteredNewerVersions [ availableMajor ] = {
68+ fullVersion : availableFullVersion ,
69+ alpineOnly : ! newDebian
70+ } ;
4571 }
4672 }
4773
@@ -88,18 +114,35 @@ export default async function(github) {
88114 const newVersions = await checkForMuslVersionsAndSecurityReleases ( github , versions ) ;
89115 let updatedVersions = [ ] ;
90116 for ( const [ version , newVersion ] of Object . entries ( newVersions ) ) {
91- if ( newVersion . muslBuildExists ) {
92- const { stdout } = await exec ( `./update.sh ${ newVersion . isSecurityRelease ? "-s " : "" } ${ version } ` ) ;
117+ if ( newVersion . alpineOnly ) {
118+ if ( newVersion . muslBuildExists ) {
119+ console . log ( `Catch-up Alpine build for version ${ newVersion . fullVersion } ` ) ;
120+ const { stdout } = await exec ( `./update.sh ${ version } alpine` ) ;
121+ console . log ( stdout ) ;
122+ updatedVersions . push ( `${ newVersion . fullVersion } (alpine)` ) ;
123+ } else {
124+ console . log ( `There's no musl build for version ${ newVersion . fullVersion } yet. Skipping Alpine catch-up.` ) ;
125+ }
126+ } else if ( newVersion . isSecurityRelease ) {
127+ console . log ( `Processing security release ${ newVersion . fullVersion } ` ) ;
128+ const { stdout } = await exec ( `./update.sh -s ${ version } ` ) ;
129+ console . log ( stdout ) ;
130+ updatedVersions . push ( newVersion . fullVersion ) ;
131+ } else if ( newVersion . muslBuildExists ) {
132+ const { stdout } = await exec ( `./update.sh ${ version } ` ) ;
93133 console . log ( stdout ) ;
94134 updatedVersions . push ( newVersion . fullVersion ) ;
95135 } else {
96- console . log ( `There's no musl build for version ${ newVersion . fullVersion } yet.` ) ;
97- process . exit ( 0 ) ;
136+ // No musl build - update non-alpine only
137+ console . log ( `There's no musl build for version ${ newVersion . fullVersion } yet. Updating non-alpine only.` ) ;
138+ const { stdout } = await exec ( `./update.sh ${ version } bookworm,bookworm-slim,bullseye,bullseye-slim,trixie,trixie-slim` ) ;
139+ console . log ( stdout ) ;
140+ updatedVersions . push ( `${ newVersion . fullVersion } (non-alpine)` ) ;
98141 }
99142 }
100143 const { stdout } = ( await exec ( `git diff` ) ) ;
101144 console . log ( stdout ) ;
102145
103146 return updatedVersions . join ( ', ' ) ;
104147 }
105- }
148+ }
0 commit comments