From 8a1d13c9236b2981ba92b69c9d54f0ecb2d42919 Mon Sep 17 00:00:00 2001 From: Igor Gnatyuk Date: Sun, 24 Oct 2021 12:00:43 +0300 Subject: [PATCH] hello buildkite --- .buildkite/pipeline.yml | 51 +++++++++++++++++++++++++++++++--------- .nvmrc | 1 + scripts/documentation.js | 2 +- scripts/release.js | 39 +++++++++++++++--------------- 4 files changed, 62 insertions(+), 31 deletions(-) create mode 100644 .nvmrc diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 33fe36824f4..036d007b0f0 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,19 +1,48 @@ -env: - CI: true - ANDROID_HOME: /usr/local/share/android-sdk/ - PATH: "$PATH:/usr/local/share/android-sdk/platform-tools/" steps: - - label: "Android :android:" + - 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' + required: false + - text: "BUILD_DOCUMENTATION_VERSION" + key: "build-documentation-version" + default: 'null' + hint: 'Leave NULL if no version is specified' + - text: "REMOVE_DOCUMENTATION_VERSION" + key: "remove-documentation-version" + default: 'null' + hint: 'Leave NULL if no version is specified' + + - label: ":android: Android" command: - - "env" + - "nvm install" - "npm install" - - "npm run clean" + - "npm run test-js" - "npm run test-unit-android -- --release" - "npm run test-e2e-android-multi -- --release --headless --verbose --ci" - - - label: "IOS :ios:" + key: "android_build" + + - label: ":ios: iOS" command: - - "env" + - "nvm install" - "npm install" - - "npm run clean" + - "npm run test-unit-ios -- --release" + - "npm run test-snapshot-ios -- --release" - "npm run test-e2e-ios -- --release --multi --ci" + key: "ios_build" + + - label: ":package: Publish" + env: + if: "build.pull_request.id == null" + command: + - "nvm install" + - "npm install" + - "npm run release" + depends_on: + - "android_build" + - "ios_build" diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000000..8351c19397f --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +14 diff --git a/scripts/documentation.js b/scripts/documentation.js index 96e7f92d7d6..231db403248 100644 --- a/scripts/documentation.js +++ b/scripts/documentation.js @@ -13,7 +13,7 @@ function release(version, removeVersion) { process.chdir(docsPath); exec.execSync(`npm install`); exec.execSync(`npm run docusaurus docs:version ${version}`); - exec.execSync(`git add website`); + exec.execSync(`git add ../website`); process.chdir(originalDir); } diff --git a/scripts/release.js b/scripts/release.js index 5a761f71d99..776a6446488 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -2,20 +2,27 @@ const exec = require('shell-utils').exec; const semver = require('semver'); const fs = require('fs'); +const cp = require('child_process'); const includes = require('lodash/includes'); const documentation = require('./documentation'); const packageJsonPath = `${process.cwd()}/package.json`; -// Workaround JS -const isRelease = process.env.RELEASE_BUILD === 'true'; - -const BUILD_DOCUMENTATION_VERSION = process.env.BUILD_DOCUMENTATION_VERSION; -const REMOVE_DOCUMENTATION_VERSION = process.env.REMOVE_DOCUMENTATION_VERSION; +// Export buildkite variables for Release build +// We cast toString() because 'buildkite-agent meta-data get' function returns 'object' +const BRANCH = process.env.BUILDKITE_BRANCH; +const isRelease = process.env.BUILDKITE_MESSAGE.match(/^release$/i); +let VERSION, VERSION_TAG, BUILD_DOCUMENTATION_VERSION, REMOVE_DOCUMENTATION_VERSION; +if (isRelease) { + VERSION = cp.execSync(`buildkite-agent meta-data get version`).toString(); + VERSION_TAG = cp.execSync(`buildkite-agent meta-data get npm-tag`).toString(); + BUILD_DOCUMENTATION_VERSION = cp.execSync(`buildkite-agent meta-data get build-documentation-version`).toString(); + REMOVE_DOCUMENTATION_VERSION = cp.execSync(`buildkite-agent meta-data get remove-documentation-version`).toString(); +} -const BRANCH = process.env.BRANCH; -let VERSION_TAG = process.env.NPM_TAG; -if (!VERSION_TAG) { +console.log(typeof (VERSION)); +// Workaround JS +if (VERSION_TAG == 'null') { VERSION_TAG = isRelease ? 'latest' : 'snapshot'; } const VERSION_INC = 'patch'; @@ -30,15 +37,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; } @@ -70,10 +71,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}`); @@ -107,7 +108,7 @@ function tryPublishAndTag(version) { function tagAndPublish(newVersion) { console.log(`trying to publish ${newVersion}...`); - if (BUILD_DOCUMENTATION_VERSION && BUILD_DOCUMENTATION_VERSION !== '') + if (BUILD_DOCUMENTATION_VERSION && BUILD_DOCUMENTATION_VERSION !== 'null') documentation.release(BUILD_DOCUMENTATION_VERSION, REMOVE_DOCUMENTATION_VERSION); exec.execSync(`npm --no-git-tag-version version ${newVersion}`); exec.execSync(`npm publish --tag ${VERSION_TAG}`);