diff --git a/.npmignore b/.npmignore index ad3e328..211cc09 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,13 @@ -example/ +example +scripts +src +test +.github .gitattributes +.babelrc +.editorconfig +.eslintignore +.eslintrc +.travis.yml +CONTRIBUTING.md +webpack.config.babel.js diff --git a/package.json b/package.json index 2d5816c..956ff84 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,9 @@ "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:dist && sh scripts/release/npm-publish.sh", "build:dev": "webpack", - "build:dist": "NODE_ENV='production' webpack" + "build:dist": "cross-env NODE_ENV=production webpack" }, "repository": { "type": "git", diff --git a/scripts/release/README.md b/scripts/release/README.md new file mode 100644 index 0000000..6c61a7c --- /dev/null +++ b/scripts/release/README.md @@ -0,0 +1,16 @@ +###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 a `dist` build and publishes using the tag created above. diff --git a/scripts/release/npm-publish.sh b/scripts/release/npm-publish.sh new file mode 100644 index 0000000..644ecee --- /dev/null +++ b/scripts/release/npm-publish.sh @@ -0,0 +1,27 @@ +#!/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} + +# Logs out of npm when publish is complete. +npm logout