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/.nvmrc b/.nvmrc new file mode 100644 index 000000000..da2d3988d --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +14 \ No newline at end of file diff --git a/package.json b/package.json index 54a935476..e79dd3233 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@types/react-native": "0.66.12", "@types/react-test-renderer": "16.9.2", "babel-eslint": "10.0.3", - "detox": "^17.5.7", + "detox": "^19.4.2", "github-release-notes": "https://github.com/yogevbd/github-release-notes/tarball/e601b3dba72dcd6cba323c1286ea6dd0c0110b58", "jest": "24.9.0", "lodash": "4.17.21", diff --git a/scripts/release.js b/scripts/release.js index 1076edc30..4ee65ad73 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}`);