Skip to content

Commit 27ce430

Browse files
committed
chore: use the branch name as release version
1 parent 0d40db2 commit 27ce430

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

packages/engine/build.plugin.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
const { execSync } = require('child_process');
12
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
2-
const fse = require('fs-extra');
3-
// read from lerna
4-
const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8'));
5-
const { version } = lernaConfig;
3+
4+
function getReleaseVersion() {
5+
const gitBranchName = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf-8' });
6+
const reBranchVersion = /^(?:[\w-]+\/)(\d+\.\d+\.\d+)$/im;
7+
const match = reBranchVersion.exec(gitBranchName);
8+
if (!match) {
9+
throw new Error(`[engine] gitBranchName: ${gitBranchName} is not valid`);
10+
}
11+
12+
return match[1];
13+
}
14+
15+
const version = getReleaseVersion();
616

717
module.exports = ({ context, onGetWebpackConfig }) => {
818
onGetWebpackConfig((config) => {

packages/engine/scripts/version.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)