Skip to content

Instantly share code, notes, and snippets.

@chilts

chilts/json-verify

Last active Sep 2, 2015
Embed
What would you like to do?
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