Skip to content

Commit ec007eb

Browse files
committed
release script - add hotfix and fix the tagging
1 parent d688127 commit ec007eb

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

.buildkite/pipeline.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ steps:
1414
value: true
1515
- label: "False"
1616
value: false
17+
- select: "IS_HOTFIX_BUILD"
18+
key: "is-hotfix"
19+
hint: "Publish hotfix version"
20+
default: 'false'
21+
options:
22+
- label: "True"
23+
value: true
24+
- label: "False"
25+
value: false
1726

1827
- label: "Build"
1928
command: |

scripts/release.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ const exec = require('shell-utils').exec;
66
const cp = require('child_process');
77

88
let IS_SNAPSHOT;
9+
let IS_HOTFIX;
910
const isReleaseBuild = process.env.BUILDKITE_MESSAGE.match(/^release$/i);
1011
const isPRBuild = process.env.BUILDKITE_PULL_REQUEST === 'true';
1112

1213
if (isReleaseBuild) {
1314
IS_SNAPSHOT = cp.execSync(`buildkite-agent meta-data get is-snapshot`).toString();
15+
IS_HOTFIX = cp.execSync(`buildkite-agent meta-data get is-hotfix`).toString();
1416
}
1517
const ONLY_ON_BRANCH = 'release';
1618
const isSnapshotBuild = (!isPRBuild && !isReleaseBuild) || IS_SNAPSHOT === 'true';
1719
const VERSION_TAG = isSnapshotBuild ? 'snapshot' : 'latest';
18-
const VERSION_INC = 'minor';
20+
const isHotFixBuild = !isPRBuild && isReleaseBuild && IS_HOTFIX === 'true';
21+
const VERSION_INC = isHotFixBuild ? 'patch' : 'minor';
1922

2023
function run() {
2124
if (!validateEnv()) {
@@ -72,6 +75,7 @@ function versionTagAndPublish() {
7275
version = semver.gt(packageVersion, currentPublished) ? packageVersion : semver.inc(currentPublished, VERSION_INC);
7376
}
7477

78+
console.log(`Publishing version: ${version}`);
7579
tryPublishAndTag(version);
7680
}
7781

@@ -84,27 +88,29 @@ function tryPublishAndTag(version) {
8488
for (let retry = 0; retry < 5; retry++) {
8589
try {
8690
tagAndPublish(theCandidate);
87-
console.log(`Released ${theCandidate}`);
91+
console.log(`Released version ${theCandidate}`);
8892
return;
8993
} catch (err) {
9094
const alreadyPublished = _.includes(err.toString(), 'You cannot publish over the previously published version');
9195
if (!alreadyPublished) {
9296
throw err;
9397
}
94-
console.log(`previously published. retrying with increased ${VERSION_INC}...`);
98+
console.log(`previous version published. Retrying with increased ${VERSION_INC}...`);
9599
theCandidate = semver.inc(theCandidate, VERSION_INC);
96100
}
97101
}
98102
}
99103

100104
function tagAndPublish(newVersion) {
101105
console.log(`trying to publish ${newVersion}...`);
102-
exec.execSync(`npm --no-git-tag-version --allow-same-version version ${newVersion}`);
103-
exec.execSyncRead(`npm publish --tag ${VERSION_TAG}`);
104-
if (isReleaseBuild && !IS_SNAPSHOT) {
106+
exec.execSync(`npm --no-git-tag-version version ${newVersion}`); // --allow-same-version
107+
exec.execSync(`npm publish --tag ${VERSION_TAG}`); // execSyncRead
108+
109+
if (isReleaseBuild && !isSnapshotBuild) {
105110
exec.execSync(`git tag -a ${newVersion} -m "${newVersion}"`);
106111
console.log(`tagging git for version ${newVersion}...`);
107-
exec.execSyncSilent(`git push origin ${newVersion}`);
112+
// exec.execSyncSilent(`git push origin ${newVersion}`);
113+
exec.execSyncSilent(`git push deploy ${newVersion} || true`);
108114
}
109115
}
110116

0 commit comments

Comments
 (0)