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

Commit

Permalink
feat(build): added semantic versioning for release and prelease
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerex committed Mar 26, 2018
1 parent 261b081 commit 7ffdd26
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 55 deletions.
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/
33 changes: 16 additions & 17 deletions .travis.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
language: node_js

node_js:
- '8'

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

before_install:
- npm i -g makeshift && makeshift -r https://registry.npmjs.org
- 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

- development
- master
notifications:
slack:
rooms:
- $SLACK_ARF_DEVOPS

deploy:
provider: npm
email: $NPM_EMAIL
api_key: $NPM_TOKEN
on:
branch: master
slack:
secure: y00hcpzZCTngonvGE8QvJH0ObjMpvGvNDEZS4ViVP6p2CDcNkRtrKjKxHVepxuTnHPLRxQu04+06MN1ORfhy1pLdSXgPNkVF9HGLXGdjDw9eu7njPykLkMIijo//sZI0oOR/cr1CbQN8MuEJ4Yru6B/FA10r9/gXqi7avDuRfjUeeJkwFlpndvKs52waIRGkRLzDo4LuJ55u85ufZoXkbPKyVs/0hZgaazWJHQP8K54gCCbigq0c9sFVU22vmFKOrTRoSh4PYEjy2dyRB2ToPeD+K695S0p/J7rYyiWgdEz1ihVmiUTvvUPR0Qz1Qj63Khj5cAO0UIV2v+tuTGUWyuJRuHWjlOlefXDfCPky4QsdNfyvA8NQ2YGfonL7mVFjKMJlL2Kz8eB6cylb9zEGfqqT3wz6+hDI2sWv5ZX3cS9bSbY7enxkPT+0Be5BWRU36bkvHz89Ejlw6yet8OKRSOfdqNip0OgJ19Hw76YQTIQCvNLVUHEOyojpYT6wkN8NZGh0Ddw3/DNyTfqJRctP8NwT1x57L7UzBzgJskBNb/yQjvdMkAf/b1r48BKjPUEC9g9rORj6hFMTw297KvmlGDu4c+wyNmWlTxmHcDXQV3+8K4/V5VQqblrnhm8CP7+rKcFlElCZs4f47mFv3T0o6Oo41l+76KYi3WuYYcw1tcg=
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
38 changes: 0 additions & 38 deletions npm_patch.sh

This file was deleted.

32 changes: 32 additions & 0 deletions npm_version_upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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);"`
export PKG_VER=`node -e "console.log(require('./package.json').version);"`
export 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
else
npm publish
node /tmp/changelog-generator-slack-notification/index.js --html "$HTML" --name "$PKG_NAME" --api "$SLACK_WEBHOOK" --v "$PKG_VER"
fi


fi

fi
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"test": "npm run lint && npm run mocha",
"lint": "eslint .",
"mocha": "nyc --reporter=lcov mocha --recursive -R xunit-file",
"version": "standard-version",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"devDependencies": {
Expand All @@ -37,6 +38,7 @@
"mocha": "^3.2.0",
"nyc": "^10.3.0",
"xunit-file": "^1.0.0",
"standard-version": "^4.3.0",
"yeoman-assert": "^2.2.2",
"yeoman-test": "^1.6.0"
},
Expand Down
26 changes: 26 additions & 0 deletions prerelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/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}"

USER_EMAIL=$(git --no-pager show -s --format='%ae' "${TRAVIS_COMMIT}")
USER_NAME=$(git --no-pager show -s --format='%an' "${TRAVIS_COMMIT}")
git config user.email "${USER_EMAIL}"
git config user.name "${USER_NAME}"

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

npm run version
git remote rm origin
git remote add origin $GITHUB_URL_SECURED
git push --follow-tags --set-upstream origin $BRANCH
hub pull-request -b master -m "chore: Merging CHANGELOG and package.json changes"

0 comments on commit 7ffdd26

Please sign in to comment.