diff --git a/.gitignore b/.gitignore index e8b08ae8..02b7c387 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,7 @@ npm* src/compression/ test/lib/ dist/ +dist/*.tgz +dist/*_debug.js openpgp.store/ doc/ diff --git a/Gruntfile.js b/Gruntfile.js index 8415c571..d7a24c0b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,4 +1,7 @@ module.exports = function(grunt) { + 'use strict'; + + var version = grunt.option('release'); // Project configuration. grunt.initConfig({ @@ -150,8 +153,36 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.registerTask('set_version', function() { + if (!version) { + throw new Error('You must specify the version: "--release=1.0.0"'); + } + + patchFile({ + fileName: 'package.json', + version: version + }); + + patchFile({ + fileName: 'bower.json', + version: version + }); + }); + + function patchFile(options) { + var fs = require('fs'), + path = './' + options.fileName, + file = require(path); + + if (options.version) { + file.version = options.version; + } + + fs.writeFileSync(path, JSON.stringify(file, null, 2)); + } + grunt.registerTask('default', 'Build OpenPGP.js', function() { - grunt.task.run(['clean', 'copy:zlib', 'browserify', 'replace', 'uglify', 'npm_pack']); + grunt.task.run(['clean', 'copy:zlib', 'browserify', 'replace', 'uglify']); //TODO jshint is not run because of too many discovered issues, once these are addressed it should autorun grunt.log.ok('Before Submitting a Pull Request please also run `grunt jshint`.'); }); @@ -168,25 +199,6 @@ module.exports = function(grunt) { mocha.stderr.pipe(process.stderr); }); - // Alias the `npm_pack` task to run `npm pack` - grunt.registerTask('npm_pack', 'npm pack', function () { - var done = this.async(); - var npm = require('child_process').exec('npm pack ../', { cwd: 'dist'}, function (err, stdout) { - var package = stdout; - if (err === null) { - var install = require('child_process').exec('npm install dist/' + package, function (err) { - done(err); - }); - install.stdout.pipe(process.stdout); - install.stderr.pipe(process.stderr); - } else { - done(err); - } - }); - npm.stdout.pipe(process.stdout); - npm.stderr.pipe(process.stderr); - }); - - // Test/Dev tasks + // Test/Dev tasks grunt.registerTask('test', ['copy:npm', 'mochaTest', 'mocha_phantomjs']); }; diff --git a/bower.json b/bower.json index 25813f5f..2746d15c 100644 --- a/bower.json +++ b/bower.json @@ -1,12 +1,17 @@ { - "name": "openpgpjs", - "version": "0.7.2", + "name": "openpgp", + "version": "0.10.0", "homepage": "http://openpgpjs.org/", "authors": [ "OpenPGP Development Team (https://github.com/openpgpjs/openpgpjs/graphs/contributors)" ], "description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.", - "main": "src/index.js", + "main": [ + "dist/openpgp.js", + "dist/openpgp.worker.js", + "dist/openpgp.min.js", + "dist/openpgp.worker.min.js" + ], "moduleType": [ "amd", "es6", @@ -23,13 +28,12 @@ "license": "LGPL 3.0 or any later version", "ignore": [ "**/.*", - "dist/openpgp*.tgz", + "dist/*.tgz", + "dist/*_debug.js", "node_modules", "bower_components", "test", "tests", - "dist", "doc" ] -} - +} \ No newline at end of file diff --git a/release.sh b/release.sh new file mode 100755 index 00000000..a0a2c171 --- /dev/null +++ b/release.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# abort if tests fail +set -e + +# go to root +cd `dirname $0` + +if [ "$#" -ne 1 ] ; then + echo 'Usage: ./release.sh 0.0.0' + exit 0 +fi + +# install dependencies +rm -rf node_modules/ +npm install + +# set version +grunt set_version --release=$1 + +# build and test +npm test + +# Add build files to git +sed -i "" '/dist/d' .gitignore +git add dist/ *.json +git commit -m "Release new version" +git checkout .gitignore +git tag v$1 +git push +git push --tag + +# publish to npm +npm publish