From 0b2d98569aa36d10c8d33e54bdab7ad0b98d9f9c Mon Sep 17 00:00:00 2001 From: Katherine Stanley Date: Tue, 9 Jan 2018 10:51:10 +0000 Subject: [PATCH] fix(build): Fix travis builds to deploy after first version Signed-off-by: Katherine Stanley --- README.md | 30 +++++++++++++++++++++++++++--- deploy.sh | 21 +++++---------------- npm/README.md | 14 +------------- prerelease.sh | 23 ++++++++++++++++------- 4 files changed, 49 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index bdf1351..461ed24 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,30 @@ # Module for common Java code generation utilities -[![Build Status](https://travis-ci.org/ibm-developer/java-codegen-common.svg?branch=master)](https://travis-ci.org/ibm-developer/java-codegen-common/branches) +[![Travis][img-travis-master]][url-travis-master] +[![Coveralls][img-coveralls-master]][url-coveralls-master] +[![Version][img-version]][url-npm] +[![License][img-license]][url-npm] -You can see builds for all branches here [https://travis-ci.org/ibm-developer/java-codegen-common/branches](https://travis-ci.org/ibm-developer/java-codegen-common/branches). +[img-travis-master]: https://travis-ci.org/ibm-developer/java-codegen-common.svg?branch=master +[url-travis-master]: https://travis-ci.org/ibm-developer/java-codegen-common/branches -This is a module that contains common Java code generation libraries used by various Java generators. \ No newline at end of file +[img-coveralls-master]: https://coveralls.io/repos/github/ibm-developer/java-codegen-common/badge.svg +[url-coveralls-master]: https://coveralls.io/github/ibm-developer/java-codegen-common + +[url-npm]: https://www.npmjs.com/package/ibm-java-codegen-common +[img-license]: https://img.shields.io/npm/l/ibm-java-codegen-common.svg +[img-version]: https://img.shields.io/npm/v/ibm-java-codegen-common.svg + +This is a module that contains common Java code generation libraries used by various Java generators. + +# Contribution + +In order to publish changes, you will need to fork the repository or ask to join the `ibm-developer` org and branch off the `master` branch. + +Make sure to follow the [conventional commit specification](https://conventionalcommits.org/) before contributing. To help you with commit a commit template is provide. +Run `config.sh` to initialize the commit template to your `.git/config` or you can use + +Once you are finished with your changes, run `npm test` to make sure all tests pass. + +Do a pull request against `master`, make sure the build passes. A team member will review and merge your pull request. +Once merged to `master` one pull request will be created against `master`. Make sure that the CHANGELOG.md and the package.json is correct before merging the auto generated pull request. After the autogenerated +pull request has been merged to `master` the version will be bumped and published to npm. diff --git a/deploy.sh b/deploy.sh index 3952d2a..109184e 100755 --- a/deploy.sh +++ b/deploy.sh @@ -4,29 +4,18 @@ echo "Checking if a new publish cycle is required ..." PKG_NAME=`node -e "console.log(require('./package.json').name);"` PKG_VER=`node -e "console.log(require('./package.json').version);"` NPM_VER=`npm show $PKG_NAME version --silent` -CHECK_REG=$(curl https://registry.npmjs.org/$PKG_NAME) -NOT_FOUND=$(node -e "console.log(Object.keys(JSON.parse(JSON.stringify($CHECK_REG))).length)") echo "$PKG_NAME : version = $PKG_VER, npm version = $NPM_VER" if [[ $TRAVIS_BRANCH == "master" ]]; then echo "Build targetting master - checking if this is a PR or not" if [[ $TRAVIS_PULL_REQUEST == "false" ]]; then echo "This is a build on master, performing additional steps" - if [ $NOT_FOUND == 0 ]; then - echo "$PKG_NAME is not in public registry so going to publish" - npm publish - elif [[ $PKG_VER == $NPM_VER ]]; then + if [[ $PKG_VER == $NPM_VER ]]; then echo "Version numbers match, so changing version and committing changes" - npm run prerelease - if [ $? == 0 ]; then - #If you are running a protected master branch then you *could* disable re-running the tests - echo "Tests passed, continuing release cycle" - ../prerelease.sh - if [ $? != 0 ]; then - exit $? - fi - else - exit $? + ../prerelease.sh + retval=$? + if [ $retval != 0 ]; then + exit $retval fi else echo "Version numbers don't match, so publishing to the registry" diff --git a/npm/README.md b/npm/README.md index 4af1210..925852b 100644 --- a/npm/README.md +++ b/npm/README.md @@ -28,16 +28,4 @@ [img-codacy]: https://api.codacy.com/project/badge/Grade/a5893a4622094dc8920c8a372a8d3588?branch=development [url-codacy]: https://www.codacy.com/app/ibm-developer/java-codegen-common - -# Contribution - -In order to publish changes, you will need to fork the repository or ask to join the `ibm-developer` org and branch off the `master` branch. - -Make sure to follow the [conventional commit specification](https://conventionalcommits.org/) before contributing. To help you with commit a commit template is provide. -Run `config.sh` to initialize the commit template to your `.git/config` or you can use - -Once you are finished with your changes, run `npm test` to make sure all tests pass. - -Do a pull request against `master`, make sure the build passes. A team member will review and merge your pull request. -Once merged to `master` one pull request will be created against `master`. Make sure that the CHANGELOG.md and the package.json is correct before merging the auto generated pull request. After the autogenerated -pull request has been merged to `master` the version will be bumped and published to npm. \ No newline at end of file +This is a module that contains common Java code generation libraries used by various IBM Java generators. For more information and to contribute see the [GitHub Repository](https://github.com/ibm-developer/java-codegen-common). diff --git a/prerelease.sh b/prerelease.sh index ce1305a..169f333 100755 --- a/prerelease.sh +++ b/prerelease.sh @@ -1,20 +1,29 @@ +#!/usr/bin/env bash git config user.email "travisci@travis.ibm.com" git config user.name "Travis CI" git config push.default simple + +echo "Running smoke test" +npm run prerelease +retval=$? +if [ $retval != 0 ]; then + exit $retval +fi echo "Upgrading using standard-version" npm run release -if [ $? != 0 ]; then - exit $? +retval=$? +if [ $retval != 0 ]; then + exit $retval fi -echo "Creating git branch" + +echo "Determining next version" PKG_VER_NEXT=`node -e "console.log(require('./package.json').version);"` + +echo "Creating git branch" BRANCH="updateTo${PKG_VER_NEXT}" git checkout -b $BRANCH - -git status -git commit -m "Update test coverage and code scan files" # this pull request through this branch will be needed to be reviewed as usual git remote rm origin git remote add origin $GITHUB_URL_SECURED -git push --follow-tags origin master +git push --follow-tags origin $BRANCH hub pull-request -b master -m "chore: Merging CHANGELOG and package.json changes"