Skip to content

Instantly share code, notes, and snippets.

@mdpauley
Created August 2, 2015 15:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mdpauley/4375a40a328a4f502ef9 to your computer and use it in GitHub Desktop.
Save mdpauley/4375a40a328a4f502ef9 to your computer and use it in GitHub Desktop.
alloy.jmk to bump version on build
var fs = require('fs');
var path = require('path');
task("pre:compile", function(event, logger) {
var tiappxml = path.join(event.dir.project, 'tiapp.xml');
var tiapp = fs.readFileSync(tiappxml, {
encoding : 'utf-8'
});
tiapp = tiapp.replace(/(android:versionCode=")([^"]+)(")/, function(match, before, versionCode, after) {
versionCode = parseInt(versionCode, 10) + 1;
logger.info('Bumped android:versionCode to: ' + versionCode);
return before + versionCode + after;
});
tiapp = tiapp.replace(/(<key>CFBundleVersion<\/key>\s*<string>)([^<]+)(<\/string>)/mg, function(match, before, CFBundleVersion, after) {
CFBundleVersion = parseInt(CFBundleVersion, 10) + 1;
logger.info('Bumped CFBundleVersion to: ' + CFBundleVersion);
return before + CFBundleVersion + after;
});
fs.writeFileSync(tiappxml, tiapp);
logger.info('building project at ' + event.dir.project);
});
task("post:compile", function(event, logger) {
logger.info('compile finished!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment