Skip to content

Commit

Permalink
feat(build): added release support. Closes NationalBankBelgium#54. Cl…
Browse files Browse the repository at this point in the history
  • Loading branch information
dsebastien committed Apr 23, 2018
1 parent 75ff9c5 commit 5790ac7
Show file tree
Hide file tree
Showing 13 changed files with 369 additions and 71 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ dist/
dist/
.tmp/
/.tmp/
tmp/


# Reports directory
reports/
Expand Down
47 changes: 47 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"non-interactive": false,
"dry-run": false,
"verbose": false,
"force": false,
"pkgFiles": ["package.json"],
"increment": "patch",
"buildCommand": false,
"safeBump": true,
"beforeChangelogCommand": false,
"requireCleanWorkingDir": true,
"requireUpstream": true,
"src": {
"commit": true,
"commitMessage": "chore(release): release %s",
"commitArgs": "",
"tag": true,
"tagName": "%s",
"tagAnnotation": "%s",
"push": true,
"pushArgs": "",
"pushRepo": null,
"beforeStartCommand": false,
"afterReleaseCommand": false
},
"npm": {
"publish": false
},
"github": {
"release": true,
"releaseName": "Release %s",
"draft": false,
"tokenRef": "GITHUB_TOKEN",
"assets": null,
"host": null
},
"prompt": {
"src": {
"status": false,
"commit": true,
"tag": true,
"push": true,
"release": true,
"publish": true
}
}
}
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
language: node_js
node_js:
- "6"
- "8"
- "6"

dist: trusty
sudo: false # better for performance

before_install:
- export TZ=Europe/Brussels
# TODO remove this variable as it's probably not needed (defined by travis by default?): https://docs.travis-ci.com/user/environment-variables/
- TRAVIS=1 # used by build.sh
- npm i -g npm@5.8.0
# This ensures that we are authenticated without requiring to have an actual .npmrc file within the project
- 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'

install:
# Create file & folder for Travis logs
Expand Down Expand Up @@ -42,5 +46,9 @@ cache:
script:
- npm run lint:all
- npm run test:ci:all
- npm run release:publish
# add publish-nightly
- ./scripts/ci/print-logs.sh

after_success:
- npm run test:ci:coveralls:stark-core
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<a name="10.0.0-alpha.1"></a>
# 10.0.0-alpha.1 (2018-03-29)


### Bug Fixes

* **build:** fixed issue with prettier config name with webpack plugin and added new scripts at root ([51be4f6](https://github.com/nationalbankbelgium/stark/commit/51be4f6))
* **http:** fix unit tests. Enhance http demo in Starter ([#268](https://github.com/nationalbankbelgium/stark/issues/268)) ([6d609b8](https://github.com/nationalbankbelgium/stark/commit/6d609b8)), closes [#68](https://github.com/nationalbankbelgium/stark/issues/68) [#68](https://github.com/nationalbankbelgium/stark/issues/68) [#84](https://github.com/nationalbankbelgium/stark/issues/84) [#93](https://github.com/nationalbankbelgium/stark/issues/93) [angular/zone.js#1015](https://github.com/angular/zone.js/issues/1015) [#96](https://github.com/nationalbankbelgium/stark/issues/96)
* **lazy-loading:** Remove PreloadAllModules preloading strategy from routing coneiguration to make lazy-loaded modules to be actually lazy loaded :) ([9634dac](https://github.com/nationalbankbelgium/stark/commit/9634dac))
* **lazy-loading:** Remove PreloadAllModules preloading strategy from routing coneiguration tz makz lazz-loaded modules to be actually lazy loaded :) ([80d09ce](https://github.com/nationalbankbelgium/stark/commit/80d09ce))
* **linting:** clean stark-build/tslint.json. Remove obsolete options for 'ban' rule ([86ed26c](https://github.com/nationalbankbelgium/stark/commit/86ed26c))
* **linting:** fix some TS linting issues ([8d5d6a8](https://github.com/nationalbankbelgium/stark/commit/8d5d6a8))


### Features

* **build:** added .gitattributes. Closes [#144](https://github.com/nationalbankbelgium/stark/issues/144). ([b4c3ef2](https://github.com/nationalbankbelgium/stark/commit/b4c3ef2))
* **build:** added support for building a subset of the packages ([55ec4c1](https://github.com/nationalbankbelgium/stark/commit/55ec4c1))
* **http:** create StarkHttp module. Fixed imports. Implemented small demo in Starter [[#96](https://github.com/nationalbankbelgium/stark/issues/96)] ([201edb8](https://github.com/nationalbankbelgium/stark/commit/201edb8))
* **http:** implement Stark Http in stark-core (unit tests to be completed) [[#96](https://github.com/nationalbankbelgium/stark/issues/96)] ([579c59b](https://github.com/nationalbankbelgium/stark/commit/579c59b))
* **http:** implement Stark Http in stark-core (unit tests to be completed) [[#96](https://github.com/nationalbankbelgium/stark/issues/96)] ([719d92d](https://github.com/nationalbankbelgium/stark/commit/719d92d))
* **polyfills:** Update polyfills.browser.ts with the relevant polyfills needed only for IE11 and some special features from Angular. Add needed npm dependencies for those polyfils ([2b6a160](https://github.com/nationalbankbelgium/stark/commit/2b6a160))
* **routing:** adapt CSP style-src directive to allow inline styles from UI Router visualizer ([8a1a8fa](https://github.com/nationalbankbelgium/stark/commit/8a1a8fa))
* **routing:** add UI Router visualizer. Adapt CSP img-src directive to allow png images from UI Router visualizer ([3bc995b](https://github.com/nationalbankbelgium/stark/commit/3bc995b))
* **routing:** replace Angular Router by UI Router ([24b70d4](https://github.com/nationalbankbelgium/stark/commit/24b70d4))
* **stark-testing:** create separate stark-testing package and use it in all stark packages and starter ([#267](https://github.com/nationalbankbelgium/stark/issues/267)) ([204dc35](https://github.com/nationalbankbelgium/stark/commit/204dc35)), closes [#68](https://github.com/nationalbankbelgium/stark/issues/68) [#68](https://github.com/nationalbankbelgium/stark/issues/68) [#84](https://github.com/nationalbankbelgium/stark/issues/84) [#93](https://github.com/nationalbankbelgium/stark/issues/93) [angular/zone.js#1015](https://github.com/angular/zone.js/issues/1015)



3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ TODO add links to developer guide sections
### Contributing
Please follow our [contribution guidelines](/CONTRIBUTING.md)

### Releaseing Stark
See [this page](/RELEASE.md)

## Authors

### Sebastien Dubois
Expand Down
44 changes: 44 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Releasing Stark

## Pre-reqs
### Local
On your local machine, you must configure the `GITHUB_TOKEN` environment variable.
It will be used by release-it to push to and create the release page on GitHub (cfr release:prepare section below).

### Travis
On Travis, the following should be configured:
* NPM_TOKEN environment variable
* if 2FA is enabled for the account the only auth-only level can be used: https://docs.npmjs.com/getting-started/using-two-factor-authentication#levels-of-authentication
* that variable MUST NEVER be logged/exposed. If exposed then the token MUST be revoked and the account password changed ASAP

## Changelog
First of all: *Never* edit CHANGELOG.md manually!

The changelog will be updated automatically as part of the release process and based on the commit log using conventional-changelog (https://github.com/conventional-changelog)
We use the Angular format for our changelog and for it to work properly, please make sure to respect our commit conventions (see CONTRIBUTING guide).

## Creating a release
Make sure that:
* all changes have merged into master
* everything is up to date locally
* everything is clean locally
* execute `npm run release`

Enjoy the show.

## Publishing the release on npm
Once you have pushed the tag, Travis will handle things from there

## What happens once a release is triggered

### release
* first we make sure that there are no local changes (if there are we stop right there)
* then we execute release-it: https://github.com/webpro/release-it which
* bumps the version in the root package.json automatically (determines the bump type to use depending on the commit message logs)
* that version number will be used as basis in the build to adapt all other package.json files
* generates/updates the CHANGELOG.md file using: conventional-changelog: https://github.com/conventional-changelog
* commits both package.json and CHANGELOG.md
* creates a new git tag and pushes it

### publish
TODO doc what happens during publish: https://github.com/NationalBankBelgium/stark/issues/54
48 changes: 0 additions & 48 deletions build-functions.sh
Original file line number Diff line number Diff line change
@@ -1,53 +1,5 @@
#!/usr/bin/env bash

# Three-Fingered Claw technique :)
# Reference: https://stackoverflow.com/questions/1378274/in-a-bash-script-how-can-i-exit-the-entire-script-if-a-certain-condition-occurs
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }

#######################################
# Echo the passed message if verbose mode is enabled
# Arguments:
# param1 - message to log if verbose mode is enabled
# param2 - depth: spaces to add before the string
#######################################
logDebug() {
if [[ ${VERBOSE} == true ]] || [[ ${TRACE} == true ]]; then
logInfo "$@"
fi
}

#######################################
# Echo the passed message if trace mode is enabled
# Arguments:
# param1 - message to log if trace mode is enabled
# param2 - depth: spaces to add before the string
#######################################
logTrace() {
if [[ ${TRACE} == true ]]; then
logInfo "$@"
fi
}

#######################################
# Echo the passed message
# Arguments:
# param1 - message to log if verbose mode is enabled
# param2 - (optional) depth: spaces to add before the string (defaults to 0)
#######################################
#log() {
# local message=${1:-NO MESSAGE TO LOG GIVEN TO log function (this is probably a mistake)}
# local numSpaces=${2:-0}
# printf "%${numSpaces}s$message\n"
#}
logInfo() {
local message="${1:-NO MESSAGE TO LOG GIVEN TO log function (this is probably a mistake)}"
local numSpaces="${2:-0}"
printf -v spacing '%*s' "$numSpaces"
printf "${spacing}%s\n" "$message"
}

#######################################
# Verifies a directory isn't in the ignored list
# Arguments:
Expand Down
36 changes: 23 additions & 13 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readonly currentDir=$(cd $(dirname $0); pwd)
export NODE_PATH=${NODE_PATH:-}:${currentDir}/node_modules

source ${currentDir}/scripts/ci/_travis-fold.sh
source ${currentDir}/util-functions.sh
source ${currentDir}/build-functions.sh

cd ${currentDir}
Expand All @@ -27,12 +28,12 @@ TSC_PACKAGES=()
# Packages that should not be compiled at all
NODE_PACKAGES=(stark-build stark-testing)

ALL_PACKAGES=(stark-build stark-testing stark-core)
# We read from a file because the list is also shared with release-publish.sh
readarray -t ALL_PACKAGES < ./modules.txt

BUILD_ALL=true
BUNDLE=true
VERSION_PREFIX=$(node -p "require('./package.json').version")
VERSION_SUFFIX="-$(git log --oneline -1 | awk '{print $1}')" # last commit id
COMPILE_SOURCE=true
TYPECHECK_ALL=true

Expand All @@ -41,13 +42,6 @@ TRAVIS=${TRAVIS:-}
VERBOSE=false
TRACE=false

PROJECT_ROOT_DIR=`pwd`
logTrace "PROJECT_ROOT_DIR: ${PROJECT_ROOT_DIR}" 1
ROOT_DIR=${PROJECT_ROOT_DIR}/packages
logTrace "ROOT_DIR: ${ROOT_DIR}" 1
ROOT_OUT_DIR=${PROJECT_ROOT_DIR}/dist/packages
logTrace "ROOT_OUT_DIR: ${ROOT_OUT_DIR}" 1

for ARG in "$@"; do
case "$ARG" in
--quick-bundle=*)
Expand All @@ -60,7 +54,6 @@ for ARG in "$@"; do

# parse to identify the packages to build
PACKAGES_STR=${ARG#--packages=}
PACKAGES_STR=${ARG#--packages=}
PACKAGES_STR="${PACKAGES_STR//,/ }" # replace , by ' '
PACKAGES_STR="${PACKAGES_STR//;/ }" # replace ; by ' '
PACKAGES_STR="${PACKAGES_STR// /_}" # replace all spaces by '_'
Expand Down Expand Up @@ -113,9 +106,6 @@ for ARG in "$@"; do
--bundle=*)
BUNDLE=( "${ARG#--bundle=}" )
;;
--publish)
VERSION_SUFFIX=""
;;
--compile=*)
COMPILE_SOURCE=${ARG#--compile=}
;;
Expand All @@ -139,6 +129,26 @@ for ARG in "$@"; do
esac
done

PROJECT_ROOT_DIR=`pwd`
logTrace "PROJECT_ROOT_DIR: ${PROJECT_ROOT_DIR}" 1
ROOT_DIR=${PROJECT_ROOT_DIR}/packages
logTrace "ROOT_DIR: ${ROOT_DIR}" 1
ROOT_OUT_DIR=${PROJECT_ROOT_DIR}/dist/packages
logTrace "ROOT_OUT_DIR: ${ROOT_OUT_DIR}" 1

# Making sure the variable exists
if [[ -z ${TRAVIS_TAG+x} ]]; then
TRAVIS_TAG=""
fi

if [[ ${TRAVIS_TAG} == "" ]]; then
logTrace "Setting the version suffix to the latest commit hash" 1
VERSION_SUFFIX="-$(git log --oneline -1 | awk '{print $1}')" # last commit id
else
logTrace "Build executed for a tag. Not using a version suffix!" 1
VERSION_SUFFIX="" # last commit id
fi

VERSION="${VERSION_PREFIX}${VERSION_SUFFIX}"

logInfo "============================================="
Expand Down
3 changes: 3 additions & 0 deletions modules.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stark-build
stark-testing
stark-core
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stark-srcs",
"version": "10.0.0-alpha.0",
"version": "10.0.0-alpha.1",
"private": true,
"description": "Stark - a framework for Angular apps",
"author": "Stark Team <sebastien.dubois@nbb.be>",
Expand All @@ -26,6 +26,7 @@
"husky": "0.14.3",
"lint-staged": "7.0.4",
"prettier": "1.12.1",
"release-it": "7.2.1",
"rollup": "0.58.1",
"rollup-plugin-commonjs": "9.1.0",
"rollup-plugin-node-resolve": "3.3.0",
Expand All @@ -38,19 +39,11 @@
"uglify-es": "3.3.9"
},
"scripts": {
"precommit": "lint-staged",
"prettier-check": "prettier **/*.{css,js,json,pcss,scss,ts} --write",
"stylelint-check": "stylelint-config-prettier-check",
"tsc": "tsc",
"ngc": "ngc",
"build": "bash ./build.sh",
"build:trace": "npm run build -- --trace",
"build:stark-build": "npm run build -- --packages=stark-build",
"build:stark-core": "npm run build -- --packages=stark-core",
"build:stark-testing": "npm run build -- --packages=stark-testing",
"preupdate:starter": "npm run clean:starter",
"update:starter": "cd starter && npm install && cd ..",
"starter": "cd starter && npm start && cd ..",
"clean": "rimraf ./dist",
"clean:all": "npm run clean && npm run clean:stark-build && npm run clean:stark-core && npm run clean:stark-testing && npm run clean:starter",
"clean:stark-build": "cd packages/stark-build && npm run clean && cd ../..",
Expand All @@ -63,6 +56,9 @@
"clean:modules:stark-core": "cd packages/stark-core && npm run clean:modules && cd ../..",
"clean:modules:stark-testing": "cd packages/stark-testing && npm run clean:modules dist && cd ../..",
"clean:modules:starter": "cd starter && npm run clean:modules dist && cd ..",
"preupdate:starter": "npm run clean:starter",
"update:starter": "cd starter && npm install && cd ..",
"starter": "cd starter && npm start && cd ..",
"lint": "tslint --config tslint.json --project ./tsconfig.json --format codeFrame",
"lint:stark-core": "cd packages/stark-core && npm run lint && cd ../..",
"lint:starter": "cd starter && npm run lint && cd ..",
Expand All @@ -77,13 +73,20 @@
"install:ci:stark-testing": "cd packages/stark-testing && npm ci && cd ../..",
"install:ci:starter": "cd starter && npm ci && cd ..",
"install:travis:all": "npm run install:stark-build && npm run install:stark-testing && npm run install:stark-core && npm run build:trace && npm run update:starter",
"ngc": "ngc",
"precommit": "lint-staged",
"prettier-check": "prettier **/*.{css,js,json,pcss,scss,ts} --write",
"release": "release-it",
"release:publish": "bash ./release-publish.sh --trace",
"stylelint-check": "stylelint-config-prettier-check",
"test:stark-core": "cd packages/stark-core && npm run test-fast && cd ../..",
"test:starter": "cd starter && npm run test-fast && cd ../..",
"test:all": "npm run test:stark-core && npm run test:starter",
"test:ci:stark-core": "cd packages/stark-core && npm run test-fast:ci && cd ../..",
"test:ci:starter": "cd starter && npm run test-fast:ci && cd ../..",
"test:ci:all": "npm run test:ci:stark-core && npm run test:ci:starter",
"test:ci:coveralls:stark-core": "cd packages/stark-core && cat ./reports/coverage/packages/lcov.info | ../stark-testing/node_modules/coveralls/bin/coveralls.js",
"tsc": "tsc",
"tslint": "tslint",
"tslint-check": "tslint-config-prettier-check ./tslint.json"
},
Expand Down
Loading

0 comments on commit 5790ac7

Please sign in to comment.