Skip to content

Commit

Permalink
build: automate release
Browse files Browse the repository at this point in the history
Added semantic-release to help with app versioning, release changes, git tagging and npm publishing.
Also added commit message linting and commitizen to help with writing commits

closes #83
  • Loading branch information
Jeremy Trujillo committed Jun 13, 2018
1 parent 402b371 commit 9cf8bd8
Show file tree
Hide file tree
Showing 10 changed files with 7,097 additions and 3,238 deletions.
23 changes: 23 additions & 0 deletions .releaserc.json
@@ -0,0 +1,23 @@
{
"pkgRoot": "dist/cashmere",
"prepare": [
{
"path": "@semantic-release/changelog",
"changelogFile": "CHANGELOG.md"
},
"@semantic-release/npm",
"@semantic-release/git"
],
"verifyConditions": ["@semantic-release/changelog", "@semantic-release/npm", "@semantic-release/git", "@semantic-release/github"],
"publish": [
{
"path": "@semantic-release/npm",
"tarballDir": "dist/*.tgz"
},
"@semantic-release/git",
{
"path": "@semantic-release/github",
"assets": "dist/*.tgz"
}
]
}
5 changes: 4 additions & 1 deletion .travis.yml
Expand Up @@ -29,8 +29,11 @@ jobs:
on:
branch: master

before_install:
- dpkg --compare-versions `npm -v` ge 5.8 || npm i -g npm@^5.8

install:
- npm install
- npm ci

script:
- ./scripts/travis-script.sh
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']};
10,238 changes: 7,023 additions & 3,215 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 25 additions & 3 deletions package.json
@@ -1,8 +1,16 @@
{
"name": "@healthcatalyst/cashmere-docs",
"version": "0.0.9",
"version": "0.0.0-development",
"license": "Apache-2.0",
"description": "Cashmere documentation website",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"tag": "alpha"
},
"repository": {
"type": "git",
"url": "https://github.com/HealthCatalyst/Fabric.Cashmere.git"
},
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -15,7 +23,11 @@
"postbuild:lib": "node scripts/postbuild.js",
"build:user": "ng build user-guide --prod",
"build": "npm run build:lib && npm run build:user",
"precommit": "lint-staged"
"postpublish": "./scripts/replace-package-version.sh",
"precommit": "lint-staged",
"commitmsg": "commitlint -e $GIT_PARAMS",
"cm": "git-cz",
"semantic-release": "semantic-release"
},
"lint-staged": {
"*.{js,scss,css,md,json}": ["prettier --write", "git add"],
Expand Down Expand Up @@ -49,15 +61,20 @@
"@angular/cli": "^6.0.3",
"@angular/compiler-cli": "6.0.3",
"@angular/language-service": "6.0.3",
"@commitlint/cli": "^6.2.0",
"@commitlint/config-conventional": "^6.1.3",
"@commitlint/travis-cli": "^6.2.0",
"@types/d3": "^5.0.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.2",
"@types/node": "9.6.2",
"@types/popper.js": "^1.11.0",
"chalk": "^2.3.0",
"codelyzer": "~4.2.1",
"commitizen": "^2.10.1",
"coveralls": "^3.0.1",
"cp": "^0.2.0",
"cz-conventional-changelog": "^2.1.0",
"fs-extra": "^6.0.1",
"glob": "^7.1.2",
"husky": "^0.14.3",
Expand All @@ -75,7 +92,7 @@
"prettier": "^1.12.1",
"protractor": "~5.3.1",
"rxjs-tslint": "^0.1.4",
"tar": "^4.4.3",
"semantic-release": "^15.5.2",
"ts-node": "~5.0.1",
"tsickle": ">=0.25.5",
"tslib": "^1.7.1",
Expand All @@ -84,5 +101,10 @@
"typescript": "2.7.2",
"typescript-formatter": "^7.0.1",
"uglify-js": "3.3.18"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
2 changes: 1 addition & 1 deletion projects/cashmere/package.json
@@ -1,6 +1,6 @@
{
"name": "@healthcatalyst/cashmere",
"version": "0.0.9",
"version": "0.0.0-development",
"license": "Apache-2.0",
"description": "Reusable Health Catalyst Components",
"repository": {
Expand Down
16 changes: 1 addition & 15 deletions scripts/postbuild.js 100644 → 100755
@@ -1,6 +1,5 @@
#!/usr/bin/env node

const tar = require('tar');
const fse = require('fs-extra');
const path = require('path');

Expand All @@ -18,7 +17,7 @@ const assets = [
];

Promise.all(copyAssets(resolveSrcDestPaths(assets)))
.then(_ => tarProject())
.then(_ => fse.remove('dist/cashmere.tgz'))
.then(_ => console.log('Finished copying assets'))
.catch(e => console.log(e));

Expand All @@ -36,16 +35,3 @@ function copyAssets(files) {
return fse.copy(srcDest[0], srcDest[1]);
});
}

function tarProject() {
return tar.create(
{
gzip: true,
strict: true,
portable: true,
cwd: resolvePath('../dist'),
file: `${resolvePath('../dist')}/${projectName}.tgz`
},
[projectName]
);
}
6 changes: 4 additions & 2 deletions scripts/publish.sh
Expand Up @@ -7,15 +7,17 @@ set -e
cd $(dirname $0)/..

# Build project
echo "Building app"
npm run build

echo "Generating code coverage"
#Generating code coverage
npm run test:unit

# Publish code coverage to Coveralls
cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

# Publishing to NPM
npx semantic-release

# Copy redirection error page for Github Pages
cp dist/user-guide/index.html dist/user-guide/404.html

Expand Down
14 changes: 14 additions & 0 deletions scripts/replace-package-version.sh
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Grab package version set by semantic release
PACKAGE_VERSION=$(cat dist/cashmere/package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')

# Replace package.json version with generated version
sed -i "" -E "s/(\"version\":[[:space:]]*\").+(\")/\1${PACKAGE_VERSION}\2/g" package.json

# Update package-lock.json version also
npm install --package-lock-only
2 changes: 1 addition & 1 deletion scripts/travis-script.sh
Expand Up @@ -9,7 +9,7 @@ cd $(dirname $0)/..
source scripts/travis-mode.sh

if is_lint; then
npm run lint
npm run lint && commitlint-travis
elif is_unit; then
npm run test:unit
elif is_build; then
Expand Down

0 comments on commit 9cf8bd8

Please sign in to comment.