From c4502158443eb3a1b1d9f92ca7bb1a8eb5b3c141 Mon Sep 17 00:00:00 2001 From: Alexandre Stanislawski Date: Thu, 22 Jun 2017 16:58:18 +0200 Subject: [PATCH] chore(build): Added release script for maintenance Fixes #2203 --- CONTRIBUTING.md | 14 +++++- package.json | 1 + scripts/release-maintenance.sh | 81 ++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100755 scripts/release-maintenance.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c8261e043..bdf418bd29 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,6 +27,7 @@ will be done on the maintenance version. To run this project, you will need: - Node.js >= v7.10.0 and <= 8, use nvm - [install instructions](https://github.com/creationix/nvm#install-script) +- yarn https://yarnpkg.com/en/ ## Development @@ -67,8 +68,19 @@ Files are automatically formatted with prettier. ## Release +### Main version +For the main version, go on master (`git checkout master`) and use: + +```sh +yarn run release +``` + +### Maintenance version + +For the maintenance version, go on maintenance (`git checkout maintenance`) and use: + ```sh -npm run release +yarn run release-maintenance ``` ## Update docs diff --git a/package.json b/package.json index 1c1350899a..259709d857 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "finish-release": "./scripts/finish-release.sh", "view-changelog": "conventional-changelog -p angular", "release": "./scripts/release.sh", + "release-maintenance": "./scripts/release-maintenance.sh", "test": "BABEL_ENV=test mocha --opts scripts/mocha.opts --reporter dot && npm run lint", "test:watch": "BABEL_ENV=test mocha --opts scripts/mocha.opts --reporter min --watch", "test:functional": "wdio functional-tests/wdio.conf.js", diff --git a/scripts/release-maintenance.sh b/scripts/release-maintenance.sh new file mode 100755 index 0000000000..c628cbd3a5 --- /dev/null +++ b/scripts/release-maintenance.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +[ -z $HOTFIX ] && HOTFIX='0' + +set -e # exit when error + +if [[ -n $(npm owner add `npm whoami`) ]]; then + printf "Release: Not an owner of the npm repo, ask for it\n" + exit 1 +fi + +currentBranch=`git rev-parse --abbrev-ref HEAD` +if [ $currentBranch != 'maintenance' ]; then + printf "Release: You must be on maintenance\n" + exit 1 +fi + +if [[ -n $(git status --porcelain) ]]; then + printf "Release: Working tree is not clean (git status)\n" + exit 1 +fi + +printf "Release: install dependencies" +yarn + +currentVersion=`cat package.json | json version` + +# header +printf "\n\nRelease: current version is $currentVersion" +printf "\nRelease: a changelog will be generated only if a fix/feat/performance/breaking token is found in git log" +printf "\nRelease: you must choose a new ve.rs.ion (semver)" +printf "\nRelease: press q to exit the next screen\n\n" + +# preview changelog +read -p "=> Release: press [ENTER] to view changes since latest version.." + +conventional-changelog --preset angular --output-unreleased | less + +# choose and bump new version +# printf "\n\nRelease: Please enter the new chosen version > " +printf "\n=> Release: please type the new chosen version > " +read -e newVersion +VERSION=$newVersion babel-node ./scripts/bump-package-version.js + +# build new version +NODE_ENV=production VERSION=$newVersion npm run build + +# update changelog +printf "\n\nRelease: update changelog" +changelog=`conventional-changelog -p angular` +conventional-changelog --preset angular --infile CHANGELOG.md --same-file + +# regenerate readme TOC +printf "\n\nRelease: generate TOCS" +npm run doctoc + +# regenerate widgets jsdoc +printf "\n\nRelease: regenerate widgets jsdoc" +npm run docs:jsdoc + +# regenerate yarn.lock +printf "Release: update yarn.lock" +yarn + +# git add and tag +commitMessage="v$newVersion\n\n$changelog" +git add src/lib/version.js yarn.lock package.json CHANGELOG.md README.md CONTRIBUTING.md docs/_includes/widget-jsdoc +printf "$commitMessage" | git commit --file - +git tag "v$newVersion" + +printf "\n\nRelease: almost done, check everything in another terminal tab.\n" +read -p "=> Release: when ready, press [ENTER] to push to github and publish the package" + +printf "\n\nRelease: push to github, publish on npm" +git push origin maintenance +git push origin --tags +npm publish + +printf "Release: +Package was published to npm. +A job on travis-ci will be automatically launched to finalize the release."