semanting versioning, support release branch
This commit is contained in:
parent
fa8b08edde
commit
bc854ce069
1 changed files with 10 additions and 12 deletions
|
@ -3,24 +3,22 @@ if (!process.env['CIRCLECI']) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const {readFileSync, writeFile} = require('fs')
|
const { readFileSync, writeFile } = require('fs')
|
||||||
const pkg = JSON.parse(readFileSync('package.json').toString());
|
const pkg = JSON.parse(readFileSync('package.json').toString());
|
||||||
let channel = process.env['CIRCLE_BRANCH'];
|
let channel = process.env['CIRCLE_BRANCH'];
|
||||||
|
|
||||||
if (process.env['CIRCLE_BRANCH'] === 'lts') {
|
|
||||||
channel = 'latest'
|
|
||||||
} else if (process.env['CIRCLE_BRANCH'] === 'main') {
|
|
||||||
channel = 'beta'
|
|
||||||
} else if (process.env['CIRCLE_BRANCH'] === 'develop') {
|
|
||||||
channel = 'alpha'
|
|
||||||
}
|
|
||||||
|
|
||||||
channel = channel.split('/').join('-')
|
channel = channel.split('/').join('-')
|
||||||
|
|
||||||
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
|
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
|
||||||
const version = pkg.version.split('.');
|
const version = pkg.version.split('.');
|
||||||
const patch = version[2].split('-');
|
const patch = version[2].split('-');
|
||||||
pkg.version = `${version[0]}.${version[1]}.${patch[0]}-${channel}.${patch[1]}`
|
if (process.env['CIRCLE_BRANCH'] === 'release') {
|
||||||
|
pkg.version = `${version[0]}.${version[1]}.${patch[0]}`
|
||||||
|
} else if (process.env['CIRCLE_BRANCH'] === 'main') {
|
||||||
|
pkg.version = `${version[0]}.${version[1]}.${patch[0]}-beta.${patch[1]}`
|
||||||
|
} else {
|
||||||
|
pkg.version = `${version[0]}.${version[1]}.${patch[0]}-${channel}.${process.env['CIRCLE_BUILD_NUM']}`
|
||||||
|
}
|
||||||
// package.build.channel = channel
|
// package.build.channel = channel
|
||||||
pkg.publish = {
|
pkg.publish = {
|
||||||
"provider": "github",
|
"provider": "github",
|
||||||
|
@ -32,9 +30,9 @@ pkg.publish = {
|
||||||
"releaseType": "release"
|
"releaseType": "release"
|
||||||
}
|
}
|
||||||
|
|
||||||
const {exec} = require('child_process')
|
const { exec } = require('child_process')
|
||||||
|
|
||||||
exec(`echo $APP_VERSION`, {env: {'APP_VERSION': pkg.version}}, function (error, stdout, stderr) {
|
exec(`echo $APP_VERSION`, { env: { 'APP_VERSION': pkg.version } }, function (error, stdout, stderr) {
|
||||||
console.log(stdout, stderr, error);
|
console.log(stdout, stderr, error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue