Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

feat: added standard version #102

Merged
merged 1 commit into from
Nov 2, 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
2 changes: 2 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[commit]
template = .gittemplate
20 changes: 20 additions & 0 deletions .gittemplate
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Type(<scope>): <subject>
# <body>
# <footer>

# Type should be one of the following:
# * BREAKING CHANGES (breaking change) [major release -- 1.x.x]
# * feat (new feature) [minor release -- x.1.x]
# * fix (bug fix) [patch release -- 0.0.x]
# * docs (changes to documentation)
# * style (formatting, missing semi colons, etc; no code change)
# * refactor (refactoring production code)
# * test (adding missing tests, refactoring tests; no production code change)
# * chore (updating grunt tasks etc; no production code change)
# Scope is just the scope of the change. Something like (admin) or (teacher).
# Subject should use clear words and say what you did.
# The body should go into detail about changes made.
# The footer should contain any Github (or other tool) issue references or actions.

# For a full example of how to write a good commit message, check out
# https://conventionalcommits.org/
31 changes: 17 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
language: node_js

node_js:
- '8'

script: npm test && npm run coveralls && ./npm_patch.sh

before_install:
- npm i -g markdown-to-html
- wget https://github.com/github/hub/releases/download/v2.2.9/hub-linux-386-2.2.9.tgz
- tar -xvzf hub-linux-386-2.2.9.tgz
- export PATH=${PATH}:$PWD/hub-linux-386-2.2.9/bin/
before_script:
- cd /tmp
- git clone -b master https://github.com/ibm-developer/changelog-generator-slack-notification.git
- npm install changelog-generator-slack-notification
- cd -
script: npm test && npm run coveralls && ./npm_version_upgrade.sh
branches:
only:
- development
- master

notifications:
email:
on_success: always
on_failure: always
slack:
rooms:
- "$SLACK_ARF_DEVOPS"

secure: YsSIB1nMQvcgqDsjMcgIkRAPh3LB9xqxW8+237kPVIW2itSUvLr4VQqTcHOOKmG7U2vySQoC7Kcb+lm+8w98xv8OGOe2ikCDaB05ExyONivL0D0gbVEwbdIMuWg72SanIuSXcbDtaFnbn6sCPqHVZpXB3jSd9wKN8YOb0MWz3s1TG0AR0L9DRMrj0K9kGDpIkAqsKO5Tbm4AyXIafzih1gRXldLBvBCR+/W0tvhaPVIhuvNjXGRVs+1kp7daJKtdXDpUWjTx4w64nbr8ljmh50J3rLCdbh4TTlO/TVT3k3RD9IsfwaEeWS6j7/SMXdpT35DFxK1GetCHzJxQcKbMDR9O+6VgQRm24z1456mw4ayf860GtC8oU0+x7b9ndY3KQd6/qoXwFx0ngJN479KVpo5T96zEKkQ1XVCh2Jlx0Zw2iThzH/Ks9G+q7zNIYP3+9US6ogzszZPCHbJzCkllrL4C9FP3LBqSlnS7uon8D9/8RSd0MEA1fTWsF5LBKZdntIo2Ma6QlEB5yelbeP/XUE+AHKveDUCd1b7mq7u6Cnx9z8rS4O++Y3Otd2idITDArfvkncnWiOYTWUlYA/UNeBznZ7u2B7yCzKymp4t1u6Es/Kdh8xhzTVRDSQTKcUinyOitaRLb0vHtivJM2MjaLPeYqL5TudQPHKPuvaAMHjU=
deploy:
provider: npm
email: $NPM_EMAIL
api_key: $NPM_TOKEN
email: "$NPM_EMAIL"
api_key: "$NPM_TOKEN"
on:
branch: master

condition: $NPM_VER != $PKG_VER
after_deploy:
- node /tmp/changelog-generator-slack-notification/index.js --html "$HTML" --name "$PKG_NAME" --api "$SLACK_WEBHOOK" --v "$PKG_VER"
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,13 @@ To run integration tests

}
```
## Publishing Changes

In order to publish changes, you will need to fork the repository or ask to join the `ibm-developer` org and branch off the development branch.

Once you are finished with your changes, run `npm test` to make sure all tests pass.

Do a pull request against `development`, make sure the build passes. A team member will review and merge your pull request.
Once merged to development to master, the version will be auto-incremented and published according to the commit. Please 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`.

8 changes: 8 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

CMD=$(cat .git/config | grep "commit")
if [ -z $CMD ]; then
echo "$(cat .git/config)\n$(cat .gitconfig)" > ./.git/config
else
echo "commit file template already saved"
fi
26 changes: 26 additions & 0 deletions npm_version_upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -ev

echo "Auto version updating script : version 0.0.1"
echo "Checking if a new version update 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`
echo "$PKG_NAME : version = $PKG_VER, npm version = $NPM_VER"
HTML=$(markdown CHANGELOG.md)

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 [ $NPM_VER == $PKG_VER ]; then
echo "Version numbers match, so changing version and committing changes"
./prerelease.sh
retval=$?
if [[ $retval != 0 ]]; then
exit $retval
fi
fi
fi
fi
24 changes: 24 additions & 0 deletions prerelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -x

echo "Running pre-release checks and scans"
CURRENT_PKG_VER=`node -e "console.log(require('./package.json').version);"`
echo "Determining current version: ${CURRENT_PKG_VER}"
LINE="bumping version in package.json from ${CURRENT_PKG_VER} to"
PKG_VER_NEXT=$(standard-version --dry-run | grep 'package.json from' | awk -v FS="${LINE}" -v OFS="" '{$1 = ""; print}')
PKG_VER_NEXT="$(echo -e "${PKG_VER_NEXT}" | tr -d '[:space:]')"

echo "Determining next version: ${PKG_VER_NEXT}"

git config user.email "travisci@travis.com"
git config user.name "Travis CI"
git config push.default simple

echo "Creating git branch"
BRANCH="updateTo${PKG_VER_NEXT}"
git checkout -b $BRANCH

npm run version
git push --follow-tags origin $BRANCH
hub pull-request -b development -m "chore: Merging CHANGELOG and package.json changes"
hub pull-request -b master -m "chore: Merging CHANGELOG and package.json changes"