Skip to content

Instantly share code, notes, and snippets.

@chilts
Last active September 2, 2015 10:25
Show Gist options
  • Save chilts/9369785779c6a2e9a075 to your computer and use it in GitHub Desktop.
Save chilts/9369785779c6a2e9a075 to your computer and use it in GitHub Desktop.
My Release Procedures

ReadMe

  1. Make sure nothing in your repo is currently edited.
  2. Update package.json - either check it in with your own commit message, or the release script will do it for you with a generic message.
  3. run release.sh
  4. then do git tag vx.y.z being the same as package.json
  5. git push vx.y.z

This doesn't yet really work for release branches, but with npm modules I find I don't use them much, just tag master with the release number.

That's it.

(Ends)

#!/usr/bin/env node
// core
var fs = require('fs');
try {
var json = fs.readFileSync(process.argv[2]).toString('utf8');
} catch (e) {
console.log('json-verify: ' + e);
process.exit(2);
}
try {
JSON.parse(json);
} catch (e) {
console.log('json-verify: ' + e);
process.exit(2);
}
#!/bin/bash
set -e
echo "Checking package.json"
json-verify package.json
echo "Firstly, see if package.json needs to be checked in"
LINES_CHANGED=`git diff package.json | wc -l`
if [ $LINES_CHANGED == "0" ]; then
echo "package.json hasn't changed, trying to release anyway"
else
echo "Commiting the latest package.json ..."
git commit -m 'Bump the version number' package.json
BRANCH=`git branch --no-color 2> /dev/null | egrep '^\*' | cut -c3-`
git push origin $BRANCH
echo
fi
echo "Getting dir information ..."
CURRENT_DIR=`pwd`
DIR_NAME=`basename $CURRENT_DIR`
echo
echo "Cloning the repo to /tmp/$DIR_NAME ..."
cd /tmp/
git clone $CURRENT_DIR
echo
echo "Publishing the package ..."
cd $DIR_NAME
npm publish
echo
echo "Tidying up the freshly cloned repo ..."
cd ../
rm -rf $DIR_NAME
cd $CURRENT_DIR
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment