Skip to content

Commit 1a3efb6

Browse files
authored
uilib-native - add a snapshot release (#3753)
1 parent 72325c2 commit 1a3efb6

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

lib/scripts/releaseNative.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
const exec = require('shell-utils').exec;
22
const p = require('path');
33

4+
// Export buildkite variables for Release build
5+
// We cast toString() because function returns 'object'
6+
const IS_SNAPSHOT = process.env.BUILDKITE_MESSAGE?.match(/^snapshot$/i);
7+
const VERSION_TAG = IS_SNAPSHOT ? 'snapshot' : 'latest';
8+
49
function run() {
510
if (!validateEnv()) {
611
return;
712
}
813

14+
const packageJsonVersion = require('../package.json').version;
915
const currentPublished = findCurrentPublishedVersion();
10-
const packageJson = require('../package.json');
11-
const newVersion = packageJson.version;
16+
const newVersion = IS_SNAPSHOT
17+
? `${packageJsonVersion}-snapshot.${process.env.BUILDKITE_BUILD_NUMBER}`
18+
: packageJsonVersion;
1219

13-
if (currentPublished !== newVersion) {
20+
if (currentPublished !== packageJsonVersion) {
1421
createNpmRc();
1522
versionTagAndPublish(currentPublished, newVersion);
1623
}
@@ -49,8 +56,13 @@ function tryPublishAndTag(version) {
4956
}
5057

5158
function tagAndPublish(newVersion) {
52-
console.log(`Trying to publish ${newVersion}...`);
53-
exec.execSync(`npm publish`);
59+
console.log(`trying to publish ${newVersion}...`);
60+
exec.execSync(`npm --no-git-tag-version version ${newVersion}`);
61+
exec.execSync(`npm publish --tag ${VERSION_TAG}`);
62+
if (!IS_SNAPSHOT) {
63+
exec.execSync(`git tag -a ${newVersion} -m "${newVersion}"`);
64+
}
65+
exec.execSyncSilent(`git push deploy ${newVersion} || true`);
5466
}
5567

5668
run();

0 commit comments

Comments
 (0)