From 8b67c9ceb7eb870ab3e3fceec8a6810c05e594ba Mon Sep 17 00:00:00 2001 From: Joshua Wiens Date: Sat, 14 Jan 2017 14:19:37 -0600 Subject: [PATCH] chore(release): simplify karma-webpack release (#200) * chore(scripts): remove legacy release scripting * chore(package): add standard-version and supporting scripts * docs(release): updates release documentation --- RELEASE.md | 51 +++++++++++++++++++++++++++ package.json | 18 ++++------ scripts/release/README.md | 16 --------- scripts/release/generate-changelog.js | 42 ---------------------- scripts/release/npm-publish.sh | 24 ------------- 5 files changed, 57 insertions(+), 94 deletions(-) create mode 100644 RELEASE.md delete mode 100644 scripts/release/README.md delete mode 100644 scripts/release/generate-changelog.js delete mode 100644 scripts/release/npm-publish.sh diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 00000000..fae85fb5 --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,51 @@ +###Tag and Release process + +> Starting from a state where everything is in master that we want released. + +*The GitHub Portion* + +#### Standard release tag + +```bash +# npm run script +npm run release +``` + +_This will ..._ + +1. bumps the version in _package.json (based on the commit history) +2. updates _CHANGELOG.md_ for the currnet version +3. commits _package.json_ and _CHANGELOG.md_ +4. tags a new release + +#### Pre-Release tag + +```bash +# npm run script +npm run release -- --prerelease +``` + +_this does the above but tags the version `1.0.1-alpha.0`, `1.0.1-beta.0`, `1.0.1-rc.0`_ + +#### Push new tag to GitHub + +```bash +# npm run script +npm run release:tag:v1 +``` + +_this pushes the newly created tag to github_ + +#### Publish to NPM + +```bash +# npm run script +npm login +``` + +```bash +# npm run script +npm run release:publish +``` + +_this runs the build ( with clean & linting ) and publishes karma-webpack to npm using the latest github tag (created above)_ diff --git a/package.json b/package.json index 908081b2..e4a82062 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,11 @@ "test.unit": "mocha --compilers js:babel-register --full-trace --check-leaks test/unit", "test.integration": "npm run build && karma start --single-run", "travis": "npm run test.unit && npm run test.integration", - "generate.changelog": "node scripts/release/generate-changelog.js", - "publish.version": "npm run build && sh scripts/release/npm-publish.sh", + "release": "standard-version", + "release:tag:v1": "git push --follow-tags origin v1", + "release:publish": "npm run build:release && npm publish --access public --tag", "build:watch": "gulp build.watch", + "build:release": "gulp", "build": "gulp build" }, "files": [ @@ -38,7 +40,6 @@ "webpack-dev-middleware": "^1.0.11" }, "devDependencies": { - "add-stream": "^1.0.0", "babel-cli": "^6.11.4", "babel-core": "^6.11.4", "babel-plugin-transform-runtime": "^6.12.0", @@ -48,9 +49,6 @@ "babel-register": "^6.11.6", "chai": "^3.5.0", "chai-as-promised": "^5.3.0", - "conventional-changelog": "^1.1.0", - "cross-env": "^2.0.0", - "cz-conventional-changelog": "^1.1.6", "del": "^2.2.1", "eslint": "^3.1.1", "eslint-plugin-babel": "^3.3.0", @@ -64,11 +62,7 @@ "karma-chrome-launcher": "~1.0.1", "karma-mocha": "~1.1.1", "karma-spec-reporter": "~0.0.22", - "mocha": "^2.5.3" - }, - "config": { - "commitizen": { - "path": "./node_modules/cz-conventional-changelog" - } + "mocha": "^2.5.3", + "standard-version": "^4.0.0" } } diff --git a/scripts/release/README.md b/scripts/release/README.md deleted file mode 100644 index 40714bda..00000000 --- a/scripts/release/README.md +++ /dev/null @@ -1,16 +0,0 @@ -###Tag and Release process - -> Starting from a state where everything is in master that we want released. - -*The GitHub Portion* -* Increment the version in the package.json and save. -* Generate the changelog for the new release version `npm run generate.changelog`. -* Run `git add .` to stage the changes. -* Commit changelog & package version updates as `chore(release): karma-webpack `. -* Run `git push` to send the changes to origin. -* Run `git tag ` to create our release tag. -* Run `git push --tags` to send the tag to origin. - -*The NPM Portion* -* `npm login` to the user with rights to publish to NPM -* `npm run publish.version` which executes the build and publishes using the tag created above. diff --git a/scripts/release/generate-changelog.js b/scripts/release/generate-changelog.js deleted file mode 100644 index 5162a0a1..00000000 --- a/scripts/release/generate-changelog.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict' // eslint-disable-line strict - -const fs = require('fs') -const addStream = require('add-stream') -const cl = require('conventional-changelog') - -const inStream = fs.createReadStream('CHANGELOG.md') -const isForce = process.argv.indexOf('--force') !== -1 - -/** - * Creates and prepends the changelog from the latest tag to head. - * Passing the arg `--force` will rewrite the entire changelog. - */ - -inStream.on('error', function(err) { - console.error(`Error: failed to read the previous changelog file. - If this is the initial run, use the --force flag. ${err}`) - process.exit(1) -}) - -const config = { - preset: 'angular', - releaseCount: isForce ? 0 : 1 -} - -const getOutputStream = function() { - return fs.createWriteStream('CHANGELOG.md') -} - -const stream = cl(config) - .on('error', function(err) { - console.error(`An error occurred while generating the changelog: ${err}`) - }) - .pipe(!isForce && addStream(inStream) || getOutputStream()) - -if (!isForce) { - inStream.on('end', function() { - stream.pipe(getOutputStream()) - }) -} - -/*eslint no-console: ["error", { allow: ["warn", "error"] }] */ diff --git a/scripts/release/npm-publish.sh b/scripts/release/npm-publish.sh deleted file mode 100644 index f4c315dc..00000000 --- a/scripts/release/npm-publish.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -# Accepts a single argument as the tag for the release (such as "next"). -# Run this script from the root of the repo. - -# `npm whoami` errors and dies if you're not logged in, -# so we redirect the stderr output to /dev/null since we don't care. -NPM_USER=$(npm whoami 2> /dev/null) - -if [ "${NPM_USER}" != "mikaak" ]; then - echo "Publishing limited to 'mikaak'. Did you forget to 'npm login'." - exit -fi - -# Defaults to latest github tag -NPM_TAG="latest" -if [ "$1" ] ; then - NPM_TAG=${1} -fi - -# Sets the above -set -ex - -# Publishing the defined tag to npm -npm publish --access public --tag ${NPM_TAG}