Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hello buildkite #7326

Merged
merged 1 commit into from
Oct 24, 2021
Merged
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
51 changes: 40 additions & 11 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14
2 changes: 1 addition & 1 deletion scripts/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
39 changes: 20 additions & 19 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}

Expand Down Expand Up @@ -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}`);

Expand Down Expand Up @@ -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}`);
Expand Down