Commit 009bab8 1 parent 970c5a9 commit 009bab8 Copy full SHA for 009bab8
File tree 2 files changed +12
-9
lines changed
2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 31
31
- name : Retrieve Release Version From `package.json`
32
32
run : |
33
33
cd scripts
34
- node version.js >> $GITHUB_ENV
34
+ node version.js
35
35
36
36
- name : Validate Input Version Against `package.json`
37
37
uses : actions/github-script@v3
Original file line number Diff line number Diff line change
1
+ /**
2
+ * This script is used to get the version of the package.json file.
3
+ * It is used in the build process, and it will append the version to the
4
+ * GitHub Actions env file.
5
+ */
6
+
1
7
import fs from 'node:fs' ;
2
8
import path from 'node:path' ;
3
9
import url from 'node:url' ;
4
10
5
- // For some reason, on mac we need to use console.log
6
- // and on windows we need to use process.stdout.write
11
+ if ( ! process . env . GITHUB_ENV ) {
12
+ throw new Error ( 'GITHUB_ENV not found' ) ;
13
+ }
7
14
8
15
const __dirname = path . dirname ( url . fileURLToPath ( import . meta. url ) ) ;
9
16
const packageJson = path . join ( __dirname , '..' , 'package.json' ) ;
10
17
11
18
const { version } = JSON . parse ( fs . readFileSync ( packageJson , 'utf-8' ) ) ;
12
- const string = `APP_VERSION=${ version } ` ;
19
+ const envVar = `APP_VERSION=${ version } ` ;
13
20
14
- if ( process . platform === 'win32' ) {
15
- process . stdout . write ( string ) ;
16
- } else {
17
- console . log ( string ) ;
18
- }
21
+ fs . appendFileSync ( process . env . GITHUB_ENV , envVar ) ;
You can’t perform that action at this time.
0 commit comments