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

chore(build): Add release script for maintenance #2208

Merged
merged 1 commit into from
Jun 22, 2017
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
14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The run can be left out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it works too ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late to the party: I never managed to run a scrip with yarn that will use "npm publish" at some point. I got credentials not being read for publishing to npm. I believe this is still an issue (and that's why previous command was npm run release).

To me that's one of yarn drawbacks that could make us switch back to npm (because if we need to use both yarn and npm, it's a struggle)

```

## Update docs
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
81 changes: 81 additions & 0 deletions scripts/release-maintenance.sh
Original file line number Diff line number Diff line change
@@ -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."