Skip to content
Merged

Bk #2

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .buildkite/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
steps:
- block: ":rocket: Release!"
prompt: "Fill out the details for release"
if: 'build.message =~ /^release\$/i'
fields:
- text: "VERSION"
key: "version"
- text: "NPM_TAG"
key: "npm-tag"
default: 'null'
hint: 'Leave NULL if no version is specified'
required: false

- label: "Android"
command:
- "nvm install"
- "npm install"
- "npm run test-js"
- "npm run clean"
- "npm run test-unit-android -- --release"
key: android

- label: "iOS"
command:
- "nvm install"
- "npm install"
- "npm run test-unit-ios -- --release"
- "npm run test-e2e-ios -- --release --multi"
key: ios

- label: ":package: Publish"
if: "build.pull_request.id == null"
command:
- "nvm install"
- "npm install"
- "npm run release"
depends_on:
- "android"
- "ios"
29 changes: 16 additions & 13 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ const semver = require('semver');
const fs = require('fs');
const _ = require('lodash');
const grenrc = require('../.grenrc');
const cp = require('child_process');

// Workaround JS
const isRelease = process.env.RELEASE_BUILD === 'true';
const isRelease = process.env.BUILDKITE_MESSAGE.match(/^release$/i);
const BRANCH = process.env.BUILDKITE_BRANCH;

const BRANCH = process.env.BRANCH;
const VERSION_TAG = process.env.NPM_TAG || isRelease ? 'latest' : 'snapshot';
let VERSION, VERSION_TAG;
if (isRelease) {
VERSION = cp.execSync(`buildkite-agent meta-data get version`).toString();
VERSION_TAG = cp.execSync(`buildkite-agent meta-data get npm-tag`).toString();
}

if (VERSION_TAG == 'null') {
VERSION_TAG = isRelease ? 'latest' : 'snapshot';
}
const VERSION_INC = 'patch';

function run() {
Expand All @@ -22,15 +31,9 @@ function run() {
}

function validateEnv() {
if (!process.env.JENKINS_CI) {
if (!process.env.CI) {
throw new Error(`releasing is only available from CI`);
}

if (!process.env.JENKINS_MASTER) {
console.log(`not publishing on a different build`);
return false;
}

return true;
}

Expand Down Expand Up @@ -60,10 +63,10 @@ function versionTagAndPublish() {
console.log(`current published version: ${currentPublished}`);

const version = isRelease
? process.env.VERSION
? VERSION
: semver.gt(packageVersion, currentPublished)
? `${packageVersion}-snapshot.${process.env.BUILD_ID}`
: `${currentPublished}-snapshot.${process.env.BUILD_ID}`;
? `${packageVersion}-snapshot.${process.env.BUILDKITE_BUILD_NUMBER}`
: `${currentPublished}-snapshot.${process.env.BUILDKITE_BUILD_NUMBER}`;

console.log(`Publishing version: ${version}`);

Expand Down