Skip to content

Commit 4b8a0b2

Browse files
authored
Merge pull request #1709 from igorgn/master
Buildkite integration
2 parents 9a6bc36 + d25d91e commit 4b8a0b2

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

.buildkite/pipeline.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
env:
2+
LC_ALL: 'en_US'
3+
steps:
4+
- block: ":rocket: Release!"
5+
prompt: "Fill out the details for release"
6+
if: 'build.message =~ /^release\$/i'
7+
fields:
8+
- select: "IS_SNAPSHOT_BUILD"
9+
key: "is-snapshot"
10+
hint: "Publish snapshot version"
11+
default: 'false'
12+
options:
13+
- label: "True"
14+
value: true
15+
- label: "False"
16+
value: false
17+
18+
- label: "Build"
19+
command: |
20+
nvm install
21+
npm install
22+
npm run test
23+
npm run build:ts
24+
if [[ $(echo $BUILDKITE_MESSAGE | tr '[:upper:]' '[:lower:]') =~ release ]];then
25+
npm run release
26+
fi

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.17.0
1+
14

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535
</developer>
3636
</developers>
3737
</project>
38+

scripts/release.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ const _ = require('lodash');
33
const fs = require('fs');
44
const semver = require('semver');
55
const exec = require('shell-utils').exec;
6+
const cp = require('child_process');
67

8+
let IS_SNAPSHOT;
9+
if (process.env.BUILDKITE_MESSAGE.match(/^release$/i)){
10+
IS_SNAPSHOT = cp.execSync(`buildkite-agent meta-data get is-snapshot`).toString();
11+
}
712
const ONLY_ON_BRANCH = 'origin/release';
8-
const isSnapshotBuild = process.env.RELEASE_SNAPSHOT_VERSION === 'true';
13+
const isSnapshotBuild = IS_SNAPSHOT === 'true';
914
const VERSION_TAG = isSnapshotBuild ? 'snapshot' : 'latest';
1015
const VERSION_INC = 'minor';
1116

@@ -20,17 +25,12 @@ function run() {
2025
}
2126

2227
function validateEnv() {
23-
if (!process.env.JENKINS_CI) {
28+
if (!process.env.CI) {
2429
throw new Error('releasing is only available from CI');
2530
}
2631

27-
if (!process.env.JENKINS_MASTER) {
28-
console.log('not publishing on a different build');
29-
return false;
30-
}
31-
32-
if (process.env.GIT_BRANCH !== ONLY_ON_BRANCH && !isSnapshotBuild) {
33-
console.log(`not publishing on branch ${process.env.GIT_BRANCH}`);
32+
if (process.env.BUILDKITE_BRANCH !== ONLY_ON_BRANCH && !isSnapshotBuild) {
33+
console.log(`not publishing on branch ${process.env.BUILDKITE_BRANCH}`);
3434
return false;
3535
}
3636

@@ -43,7 +43,7 @@ function setupGit() {
4343
exec.execSyncSilent(`git config --global user.name "${process.env.GIT_USER}"`);
4444
const remoteUrl = new RegExp('https?://(\\S+)').exec(exec.execSyncRead('git remote -v'))[1];
4545
exec.execSyncSilent(`git remote add deploy "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
46-
exec.execSync(`git checkout ${process.env.GIT_BRANCH}`);
46+
exec.execSync(`git checkout ${process.env.BUILDKITE_BRANCH}`);
4747
}
4848

4949
function createNpmRc() {
@@ -64,7 +64,7 @@ function versionTagAndPublish() {
6464

6565
let version;
6666
if (isSnapshotBuild) {
67-
version = `${currentPublished}-snapshot.${process.env.BUILD_ID}`;
67+
version = `${currentPublished}-snapshot.${process.env.BUILDKITE_BUILD_NUMBER}`;
6868
} else {
6969
version = semver.gt(packageVersion, currentPublished) ? packageVersion : semver.inc(currentPublished, VERSION_INC);
7070
}

0 commit comments

Comments
 (0)