From 7b87885731feae3667e1e2104942b451b6cc7ced Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 29 Jun 2014 22:48:39 -0700 Subject: [PATCH] add beta and noupdate versions to build script --- Gruntfile.coffee | 79 +++++++++++++++++--------------- package.json | 8 ++-- src/General/meta/manifest-w.json | 24 ---------- src/General/meta/manifest.json | 4 +- src/General/meta/metadata.js | 4 +- src/General/meta/updates.xml | 2 +- 6 files changed, 52 insertions(+), 69 deletions(-) delete mode 100755 src/General/meta/manifest-w.json diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 60c509a29..4052400e1 100755 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -49,16 +49,9 @@ module.exports = (grunt) -> 'LICENSE': 'src/General/meta/banner.js' crx: files: - 'testbuilds/crx/manifest.json': 'src/General/meta/manifest.json' - 'testbuilds/updates.xml': 'src/General/meta/updates.xml' - 'testbuilds/crx/script.js': [ - 'src/General/meta/botproc.js' - 'src/General/meta/banner.js' - 'src/General/meta/usestrict.js' - 'tmp-<%= pkg.type %>/script.js' - ] - 'testbuilds/wcrx/manifest.json': 'src/General/meta/manifest-w.json' - 'testbuilds/wcrx/script.js': [ + 'testbuilds/updates<%= pkg.meta.suffix[pkg.channel] %>.xml': 'src/General/meta/updates.xml' + 'testbuilds/crx<%= pkg.meta.suffix[pkg.channel] %>/manifest.json': 'src/General/meta/manifest.json' + 'testbuilds/crx<%= pkg.meta.suffix[pkg.channel] %>/script.js': [ 'src/General/meta/botproc.js' 'src/General/meta/banner.js' 'src/General/meta/usestrict.js' @@ -66,8 +59,8 @@ module.exports = (grunt) -> ] userscript: files: - 'testbuilds/<%= pkg.name %>.meta.js': 'src/General/meta/metadata.js' - 'testbuilds/<%= pkg.name %>.user.js': [ + 'testbuilds/<%= pkg.name %><%= pkg.meta.suffix[pkg.channel] %>.meta.js': 'src/General/meta/metadata.js' + 'testbuilds/<%= pkg.name %><%= pkg.meta.suffix[pkg.channel] %>.user.js': [ 'src/General/meta/botproc.js' 'src/General/meta/metadata.js' 'src/General/meta/banner.js' @@ -78,19 +71,15 @@ module.exports = (grunt) -> copy: crx: src: 'src/General/img/*.png' - dest: 'testbuilds/crx/' - expand: true - flatten: true - wcrx: - src: 'src/General/img/*.png' - dest: 'testbuilds/wcrx/' + dest: 'testbuilds/crx<%= pkg.meta.suffix[pkg.channel] %>/' expand: true flatten: true builds: cwd: 'testbuilds/' - src: '**' + src: '*' dest: 'builds/' expand: true + filter: 'isFile' coffee: script: @@ -119,8 +108,6 @@ module.exports = (grunt) -> failOnError: true checkout: command: 'git checkout <%= pkg.meta.mainBranch %>' - pack: - command: 'chromium --pack-extension=testbuilds/crx --pack-extension-key=$HOME/.ssh/<%= pkg.name %>.pem' commit: command: """ git commit -am "Release <%= pkg.meta.name %> v<%= pkg.version %>." @@ -147,6 +134,12 @@ module.exports = (grunt) -> ] tasks: 'build' + crx: + prod: + src: 'testbuilds/crx<%= pkg.meta.suffix[pkg.channel] %>/' + dest: 'testbuilds/<%= pkg.name %><%= pkg.meta.suffix[pkg.channel] %>.crx' + privateKey: '~/.ssh/<%= pkg.name %>.pem' + compress: crx: options: @@ -155,14 +148,14 @@ module.exports = (grunt) -> pretty: true expand: true flatten: true - src: 'testbuilds/wcrx/*' + src: 'testbuilds/crx<%= pkg.meta.suffix.noupdate %>/*' dest: '/' clean: builds: 'builds' testbuilds: 'testbuilds' - tmpcrx: 'tmp-crx' - tmpuserscript: 'tmp-userscript' + tmpcrx: ['tmp-crx', 'testbuilds/updates<%= pkg.meta.suffix.noupdate %>.xml'] + tmpuserscript: ['tmp-userscript', 'testbuilds/<%= pkg.name %><%= pkg.meta.suffix.noupdate %>.meta.js'] require('load-grunt-tasks') grunt @@ -186,6 +179,11 @@ module.exports = (grunt) -> grunt.log.ok 'pkg.type = %s', type + grunt.registerTask 'set-channel', 'Set the update channel', (channel) -> + pkg = grunt.config 'pkg' + pkg.channel = channel + grunt.config 'pkg', pkg + grunt.registerTask 'enable-tests', 'Include testing code', () -> pkg = grunt.config 'pkg' pkg.tests_enabled = true @@ -195,13 +193,23 @@ module.exports = (grunt) -> 'concurrent:build' ] + grunt.registerTask 'build-crx-channel', [ + 'concat:crx' + 'copy:crx' + 'crx:prod' + ] + grunt.registerTask 'build-crx', [ 'set-build:crx' 'concat:coffee' 'coffee:script' - 'concat:crx' - 'copy:crx' - 'copy:wcrx' + 'set-channel:stable' + 'build-crx-channel' + 'set-channel:beta' + 'build-crx-channel' + 'set-channel:noupdate' + 'build-crx-channel' + 'compress:crx' 'clean:tmpcrx' ] @@ -209,6 +217,11 @@ module.exports = (grunt) -> 'set-build:userscript' 'concat:coffee' 'coffee:script' + 'set-channel:stable' + 'concat:userscript' + 'set-channel:beta' + 'concat:userscript' + 'set-channel:noupdate' 'concat:userscript' 'clean:tmpuserscript' ] @@ -219,23 +232,15 @@ module.exports = (grunt) -> 'build-crx' ] - grunt.registerTask 'testing', [ + grunt.registerTask 'tag', [ 'build' - 'shell:pack' - 'compress:crx' 'concat:meta' 'copy:builds' 'shell:commit' - 'shell:push' ] grunt.registerTask 'release', [ - 'build' - 'shell:pack' - 'compress:crx' - 'concat:meta' - 'copy:builds' - 'shell:commit' + 'tag' 'shell:stable' 'shell:push' ] diff --git a/package.json b/package.json index c2c29d4ac..21f021fae 100755 --- a/package.json +++ b/package.json @@ -17,9 +17,10 @@ "*://a.4cdn.org/*", "*://i.4cdn.org/*" ], - "files": { - "metajs": "4chan-X.meta.js", - "userjs": "4chan-X.user.js" + "suffix": { + "stable": "", + "beta": "-beta", + "noupdate": "-noupdate" }, "min": { "chrome": "31", @@ -38,6 +39,7 @@ "grunt-contrib-concat": "~0.4.0", "grunt-contrib-copy": "~0.5.0", "grunt-contrib-watch": "~0.6.1", + "grunt-crx": "~0.3.3", "grunt-shell": "~0.7.0", "load-grunt-tasks": "~0.4.0" }, diff --git a/src/General/meta/manifest-w.json b/src/General/meta/manifest-w.json deleted file mode 100755 index cb022ecea..000000000 --- a/src/General/meta/manifest-w.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "<%= meta.name %>", - "version": "<%= version %>", - "manifest_version": 2, - "description": "<%= description %>", - "icons": { - "16": "icon16.png", - "48": "icon48.png", - "128": "icon128.png" - }, - "content_scripts": [{ - "js": ["script.js"], - "matches": <%= JSON.stringify(meta.matches) %>, - "all_frames": true, - "run_at": "document_start" - }], - "homepage_url": "<%= meta.page %>", - "minimum_chrome_version": "<%= meta.min.chrome %>", - "permissions": [ - "storage", - "http://*/", - "https://*/" - ] -} diff --git a/src/General/meta/manifest.json b/src/General/meta/manifest.json index 6d3d4caf6..adccabb9e 100755 --- a/src/General/meta/manifest.json +++ b/src/General/meta/manifest.json @@ -15,8 +15,8 @@ "run_at": "document_start" }], "homepage_url": "<%= meta.page %>", - "update_url": "<%= meta.downloads %>updates.xml", - "minimum_chrome_version": "<%= meta.min.chrome %>", +<% if (channel !== 'noupdate') { %> "update_url": "<%= meta.downloads %>updates<%= meta.suffix[channel] %>.xml", +<% } %> "minimum_chrome_version": "<%= meta.min.chrome %>", "permissions": [ "storage", "http://*/", diff --git a/src/General/meta/metadata.js b/src/General/meta/metadata.js index c68cbf0fb..70b9786a4 100755 --- a/src/General/meta/metadata.js +++ b/src/General/meta/metadata.js @@ -18,7 +18,7 @@ // @grant GM_openInTab // @grant GM_xmlhttpRequest // @run-at document-start -// @updateURL <%= meta.downloads %><%= meta.files.metajs %> -// @downloadURL <%= meta.downloads %><%= meta.files.userjs %> +<% if (channel !== 'noupdate') { %>// @updateURL <%= meta.downloads %><%= name %><%= meta.suffix[channel] %>.meta.js +<% } %>// @downloadURL <%= meta.downloads %><%= name %><%= meta.suffix[channel] %>.user.js // @icon data:image/png;base64,<%= grunt.file.read('src/General/img/icon48.png', {encoding: 'base64'}) %> // ==/UserScript== diff --git a/src/General/meta/updates.xml b/src/General/meta/updates.xml index 0f5d3104b..72cc96973 100644 --- a/src/General/meta/updates.xml +++ b/src/General/meta/updates.xml @@ -1,7 +1,7 @@ - +