diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml new file mode 100644 index 000000000..4d6b15909 --- /dev/null +++ b/.buildkite/pipeline.yaml @@ -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" diff --git a/scripts/release.js b/scripts/release.js index 60ab727c9..be23358be 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -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() { @@ -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; } @@ -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}`);