Skip to content

Commit

Permalink
Implement change log generation on publishing
Browse files Browse the repository at this point in the history
Closes #409
  • Loading branch information
LeoNatan committed Nov 15, 2017
1 parent f67cda0 commit a48744c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 32 deletions.
8 changes: 8 additions & 0 deletions .github_changelog_generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
issues-wo-labels=false
exclude-labels=stack overflow,not a bug,apple bug,duplicate,question,invalid,wontfix
bugs-label=**Fixed Bugs**
enhancement-label=**Enhancements**
issues-label=**Closed Issues**
pr-label=**Merged Pull Requests**
verbose=false
bug-labels=documentation,bug,Bug
3 changes: 2 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
npm install -g lerna@2.4.0 >/dev/null 2>&1
npm install -g react-native-cli >/dev/null 2>&1
npm install -g detox-cli >/dev/null 2>&1
gem install xcpretty >/dev/null 2>&1
gem install xcpretty >/dev/null 2>&1
gem install github_changelog_generator
15 changes: 15 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash -e

VERSION_TYPE="$1"
if [ -z "$VERSION_TYPE" ]; then
VERSION_TYPE="patch"
fi

lerna publish --cd-version "$VERSION_TYPE" --yes --skip-git
VERSION=`node -p "require('./detox/package.json').version"`
github_changelog_generator --future-release "$VERSION" --bugs-label "**Fixed Bugs**" --enhancement-label "**Enhancements**" --issues-label "**Closed Issues**" --pr-label "**Merged Pull Requests**" --no-verbose
git add -A
git commit -m "[skip ci] Publish $VERSION"
git tag "$VERSION"
git push
git push --tags
62 changes: 31 additions & 31 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,62 @@ const cp = require('child_process');
const p = require('path');

function execSync(cmd) {
cp.execSync(cmd, { stdio: ['inherit', 'inherit', 'inherit'] });
cp.execSync(cmd, { stdio: ['inherit', 'inherit', 'inherit'] });
}

function execSyncRead(cmd) {
return String(cp.execSync(cmd, { stdio: ['inherit', 'pipe', 'inherit'] })).trim();
return String(cp.execSync(cmd, { stdio: ['inherit', 'pipe', 'inherit'] })).trim();
}

function execSyncSilently(cmd) {
cp.execSync(cmd, { stdio: ['ignore', 'ignore', 'ignore'] });
cp.execSync(cmd, { stdio: ['ignore', 'ignore', 'ignore'] });
}

function validateEnv() {
if (!process.env.CI || !process.env.TRAVIS) {
throw new Error(`releasing is only available from Travis CI`);
}
if (!process.env.CI || !process.env.TRAVIS) {
throw new Error(`releasing is only available from Travis CI`);
}

if (process.env.TRAVIS_BRANCH !== 'master') {
console.error(`not publishing on branch ${process.env.TRAVIS_BRANCH}`);
return false;
}
if (process.env.TRAVIS_BRANCH !== 'master') {
console.error(`not publishing on branch ${process.env.TRAVIS_BRANCH}`);
return false;
}

if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
console.error(`not publishing as triggered by pull request ${process.env.TRAVIS_PULL_REQUEST}`);
return false;
}
if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
console.error(`not publishing as triggered by pull request ${process.env.TRAVIS_PULL_REQUEST}`);
return false;
}

return true;
return true;
}

function setupGit() {
execSyncSilently(`git config --global push.default simple`);
execSyncSilently(`git config --global user.email "${process.env.GIT_EMAIL}"`);
execSyncSilently(`git config --global user.name "${process.env.GIT_USER}"`);
const remoteUrl = new RegExp(`https?://(\\S+)`).exec(execSyncRead(`git remote -v`))[1];
execSyncSilently(`git remote remove origin`);
execSyncSilently(`git remote add origin "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
execSync(`git checkout master`);
execSyncSilently(`git config --global push.default simple`);
execSyncSilently(`git config --global user.email "${process.env.GIT_EMAIL}"`);
execSyncSilently(`git config --global user.name "${process.env.GIT_USER}"`);
const remoteUrl = new RegExp(`https?://(\\S+)`).exec(execSyncRead(`git remote -v`))[1];
execSyncSilently(`git remote remove origin`);
execSyncSilently(`git remote add origin "https://${process.env.GIT_USER}:${process.env.GIT_TOKEN}@${remoteUrl}"`);
execSync(`git checkout master`);
}

function copyNpmRc() {
const npmrcPath = p.resolve(`${__dirname}/.npmrc`);
execSync(`cp -rf ${npmrcPath} .`);
const npmrcPath = p.resolve(`${__dirname}/.npmrc`);
execSync(`cp -rf ${npmrcPath} .`);
}

function release() {
execSync(`lerna publish -m "[skip ci] Publish" --cd-version patch --yes`);
execSync(`scripts/publish.sh`);
}

function run() {
if (!validateEnv()) {
return;
}
setupGit();
copyNpmRc();
if (!validateEnv()) {
return;
}
setupGit();
copyNpmRc();

release();
release();
}

run();

0 comments on commit a48744c

Please # to comment.