Skip to content

Commit

Permalink
Allow releasing prereleases from different branches (wix#2447)
Browse files Browse the repository at this point in the history
* lerna 3.22.1

* fingers crossed

* env var name change

* Back to lerna 2.11.0

* Fix log

* tweaks

* Publish 17.10.7-alpha.0 [ci skip]

* Revert "Publish 17.10.7-alpha.0 [ci skip]"

This reverts commit 1179988.

* trying to update lerna through scripts

* update script to new lerna API

* --no-ci

* --no-ci

* lerna install now verbose

* verbose++

* remove detox cli

* npm global installation permission workaround

* remove commented out code

* prerelease version alignment with npmjs

* revert back to 17.10.7

Co-authored-by: wixmobile <[email protected]>
  • Loading branch information
rotemmiz and mobile1-internal authored Nov 3, 2020
1 parent dc1d85b commit 60fd09a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 39 deletions.
2 changes: 1 addition & 1 deletion detox-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "detox-cli",
"version": "17.4.3",
"version": "17.10.7",
"description": "detox CLI tool wrapper",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion generation/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generation",
"version": "17.8.5",
"version": "17.10.7",
"description": "Generate wrapper code for native dependencies",
"main": "index.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "2.4.0",
"lerna": "3.22.1",
"packages": [
"detox",
"detox-cli",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"devDependencies": {
"chalk": "^2.4.2",
"lerna": "3.22.1",
"lodash": "4.17.x",
"semver": "5.x.x",
"shell-utils": "1.x.x"
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci.android-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {log, logSection, getVersionSafe} = require('./ci.common');

function run() {
logSection('Initializing');
exec.execSync('lerna bootstrap');
exec.execSync('lerna bootstrap --no-ci');

const versionType = process.env.RELEASE_VERSION_TYPE;
logSection(`Pre-calculating future version... (versionType=${versionType})`);
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci.android.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash -ex

# Approve unapproved SDK licenses
yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci.ios.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash -ex

source $(dirname "$0")/ci.sh

Expand Down
23 changes: 9 additions & 14 deletions scripts/ci.publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ const exec = require('shell-utils').exec;

const {log, logSection, getVersionSafe} = require('./ci.common');

function publishNewVersion(packageVersion) {
function publishNewVersion(packageVersion, npmTag) {
validatePrerequisites();
projectSetup();
publishToNpm();
publishToNpm(npmTag);

const newVersion = getVersionSafe();
if (newVersion === packageVersion) {
log(`Stopping: Lerna\'s completed without upgrading the version - nothing to publish (version is ${newVersion})`);
log(`Stopping: Lerna completed without upgrading the version - nothing to publish (version is ${newVersion})`);
return false;
}

Expand All @@ -23,20 +23,15 @@ function validatePrerequisites() {
if (!lernaBin) {
throw new Error(`Cannot publish: lerna not installed!`);
}

const lernaVersion = exec.execSyncRead('lerna --version');
if (!lernaVersion.startsWith('2.')) {
throw new Error(`Cannot publish: lerna version isn't 2.x.x (actual version is ${lernaVersion})`);
}
}

function projectSetup() {
logSection('Project setup');
exec.execSync(`lerna bootstrap`);
exec.execSync(`git checkout master`);
exec.execSync(`git checkout ${process.env.GIT_BRANCH}`);
exec.execSync(`lerna bootstrap --no-ci`);
}

function publishToNpm() {
function publishToNpm(npmTag) {
logSection('Lerna publish');

const versionType = process.env.RELEASE_VERSION_TYPE;
Expand All @@ -49,7 +44,7 @@ function publishToNpm() {
log('SKIP NPM is set: Lerna-publishing without publishing to NPM');
}

exec.execSync(`lerna publish --cd-version "${versionType}" --yes --skip-git ${(dryRun || skipNpm) ? '--skip-npm' : ''}`);
exec.execSync(`lerna publish --cd-version "${versionType}" --yes --dist-tag ${npmTag} ${npmTag === 'latest'? '': '--preid=alpha'} --skip-git ${(dryRun || skipNpm) ? '--skip-npm' : ''}`);
exec.execSync('git status');
}

Expand All @@ -64,8 +59,8 @@ function updateGit(newVersion) {
if (dryRun) {
log('DRY RUN: not pushing to git');
} else {
exec.execSync(`git push deploy master`);
exec.execSync(`git push --tags deploy master`);
exec.execSync(`git push deploy ${process.env.GIT_BRANCH}`);
exec.execSync(`git push --tags deploy ${process.env.GIT_BRANCH}`);
}
}

Expand Down
27 changes: 15 additions & 12 deletions scripts/ci.release.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ const {log, logSection, getVersionSafe} = require('./ci.common');

const isRelease = (process.env.RELEASE_VERSION_TYPE && process.env.RELEASE_VERSION_TYPE !== 'none');

const ONLY_ON_BRANCH = 'origin/master';

function run() {
logSection('Script started');
if (!validateEnv()) {
if (!isEnvValid()) {
return;
}

Expand All @@ -19,7 +17,7 @@ function run() {
versionTagAndPublish();
}

function validateEnv() {
function isEnvValid() {
if (!process.env.JENKINS_CI) {
throw new Error(`Release blocked: Not on a CI build machine!`);
}
Expand All @@ -29,11 +27,6 @@ function validateEnv() {
return false;
}

if (process.env.GIT_BRANCH !== ONLY_ON_BRANCH) {
log(`Release blocked: Not publishing on branch ${process.env.GIT_BRANCH}, which isn't ${ONLY_ON_BRANCH}`);
return false;
}

return true;
}

Expand Down Expand Up @@ -65,11 +58,11 @@ function versionTagAndPublish() {
log(` package version: ${packageVersion}`);

const currentPublished = findCurrentPublishedVersion();
log(` current published version: ${currentPublished}`);
log(` current published version from ${process.env.GIT_BRANCH}: ${currentPublished}`);

if (isRelease) {
const publishNewVersion = require('./ci.publish');
publishNewVersion(packageVersion);
publishNewVersion(packageVersion, releaseNpmTag());
} else {
// Disabled for the time being
// const tagVersion = require('./ci.tagversion');
Expand All @@ -79,8 +72,18 @@ function versionTagAndPublish() {
log(`Great success, much amaze`);
}

function releaseNpmTag() {
if (process.env.GIT_BRANCH === 'master') {
return 'latest';
} else if (process.env.RELEASE_NPM_TAG) {
return process.env.RELEASE_NPM_TAG;
} else {
return process.env.GIT_BRANCH;
}
}

function findCurrentPublishedVersion() {
return exec.execSyncRead(`npm view detox dist-tags.latest`);
return exec.execSyncRead(`npm view detox dist-tags.${releaseNpmTag()}`);
}

run();
4 changes: 2 additions & 2 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash -e

source $(dirname "$0")/logger.sh
source $(dirname "$0")/install.sh

if [ ! -z ${REACT_NATIVE_VERSION} ]; then
node scripts/change_react_native_version.js "detox/test" ${REACT_NATIVE_VERSION}
fi

run_f "lerna bootstrap"

run_f "lerna bootstrap --no-ci"
run_f "lerna run build"
run_f "lerna run test"
3 changes: 2 additions & 1 deletion scripts/demo-projects.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash

source $(dirname "$0")/logger.sh
source $(dirname "$0")/install.sh

# Only update the demo-react-native project; others will use this binary
node scripts/change_react_native_version.js "examples/demo-react-native" ${REACT_NATIVE_VERSION}

run_f "lerna bootstrap"
run_f "lerna bootstrap --no-ci"
2 changes: 1 addition & 1 deletion scripts/install.android.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e

$(dirname "$0")/install.sh
source $(dirname "$0")/install.sh

2 changes: 1 addition & 1 deletion scripts/install.ios.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

$(dirname "$0")/install.sh
source $(dirname "$0")/install.sh

gem install xcpretty >/dev/null 2>&1

Expand Down
7 changes: 5 additions & 2 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash -e

npm install -g [email protected] >/dev/null 2>&1
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH

npm install -g [email protected]
npm install -g react-native-cli >/dev/null 2>&1
npm install -g detox-cli >/dev/null 2>&1

0 comments on commit 60fd09a

Please sign in to comment.