@@ -12,6 +12,20 @@ const pkgFilePath = path.join(__dirname, '..', '..', 'package.json');
1212
1313process . env . TZ = 'Etc/UTC' ;
1414
15+ async function shouldPublish ( publish ) {
16+ const githubOutput = process . env . GITHUB_OUTPUT ?? '' ;
17+ if ( githubOutput . length === 0 ) {
18+ console . log ( 'output file does not exist' ) ;
19+ process . exit ( 1 ) ;
20+ }
21+
22+ const outputFile = await fs . open ( githubOutput , 'a' ) ;
23+ const output = publish ? 'publish=yes' : 'publish=no' ;
24+ console . log ( 'outputting:' , output , 'to' , githubOutput ) ;
25+ await outputFile . appendFile ( output , { encoding : 'utf8' } ) ;
26+ await outputFile . close ( ) ;
27+ }
28+
1529/**
1630 * FORMAT : M.M.P-dev.YYYYMMDD.sha.##########
1731 * EXAMPLE: 5.6.0-dev.20230601.sha.0853c6957c
@@ -55,6 +69,7 @@ class NightlyVersion {
5569 console . log ( 'package.json version updated to:' , pkg . version ) ;
5670
5771 await fs . writeFile ( pkgFilePath , JSON . stringify ( pkg , undefined , 2 ) , { encoding : 'utf8' } ) ;
72+ console . log ( 'wrote package.json' ) ;
5873 }
5974}
6075
@@ -64,8 +79,12 @@ const currentCommit = await NightlyVersion.currentCommit();
6479console . log ( 'current commit sha:' , currentCommit ) ;
6580
6681if ( currentPublishedNightly . commit === currentCommit ) {
67- console . log ( 'Published nightly is up to date' ) ;
68- process . exit ( 1 ) ;
82+ console . log ( 'Published nightly is up to date, nothing to do' ) ;
83+ await shouldPublish ( false ) ;
84+ } else {
85+ await NightlyVersion . generateNightlyVersion ( ) ;
86+ console . log ( 'Published nightly is behind main, updated package.json' ) ;
87+ await shouldPublish ( true ) ;
6988}
70- await NightlyVersion . generateNightlyVersion ( ) ;
71- process . exit ( 0 ) ;
89+
90+ console . log ( 'done.' ) ;
0 commit comments