@@ -12,6 +12,20 @@ const pkgFilePath = path.join(__dirname, '..', '..', 'package.json');
12
12
13
13
process . env . TZ = 'Etc/UTC' ;
14
14
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
+
15
29
/**
16
30
* FORMAT : M.M.P-dev.YYYYMMDD.sha.##########
17
31
* EXAMPLE: 5.6.0-dev.20230601.sha.0853c6957c
@@ -55,6 +69,7 @@ class NightlyVersion {
55
69
console . log ( 'package.json version updated to:' , pkg . version ) ;
56
70
57
71
await fs . writeFile ( pkgFilePath , JSON . stringify ( pkg , undefined , 2 ) , { encoding : 'utf8' } ) ;
72
+ console . log ( 'wrote package.json' ) ;
58
73
}
59
74
}
60
75
@@ -64,8 +79,12 @@ const currentCommit = await NightlyVersion.currentCommit();
64
79
console . log ( 'current commit sha:' , currentCommit ) ;
65
80
66
81
if ( 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 ) ;
69
88
}
70
- await NightlyVersion . generateNightlyVersion ( ) ;
71
- process . exit ( 0 ) ;
89
+
90
+ console . log ( 'done.' ) ;
0 commit comments