Skip to content

Commit 009bab8

Browse files
committed
version test
1 parent 970c5a9 commit 009bab8

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Retrieve Release Version From `package.json`
3232
run: |
3333
cd scripts
34-
node version.js >> $GITHUB_ENV
34+
node version.js
3535
3636
- name: Validate Input Version Against `package.json`
3737
uses: actions/github-script@v3

scripts/version.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
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+
17
import fs from 'node:fs';
28
import path from 'node:path';
39
import url from 'node:url';
410

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+
}
714

815
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
916
const packageJson = path.join(__dirname, '..', 'package.json');
1017

1118
const { version } = JSON.parse(fs.readFileSync(packageJson, 'utf-8'));
12-
const string = `APP_VERSION=${version}`;
19+
const envVar = `APP_VERSION=${version}`;
1320

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);

0 commit comments

Comments
 (0)