Skip to content

Commit 65c73a3

Browse files
authored
Merge pull request #1 from igorgn/buildkite-integration
prepare for buildkite
2 parents 9cb9411 + 1ac3127 commit 65c73a3

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

.buildkite/pipeline.yml

Whitespace-only changes.

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)