Commit bddd1003 authored by Dave Methvin's avatar Dave Methvin

Update the build script so it runs on Windows.

parent 24db7346
...@@ -9,19 +9,19 @@ var debug = false, ...@@ -9,19 +9,19 @@ var debug = false,
var fs = require("fs"), var fs = require("fs"),
child = require("child_process"), child = require("child_process"),
path = require("path"), path = require("path");
which = require('which').sync;
var releaseVersion, var releaseVersion,
nextVersion, nextVersion,
finalFiles, finalFiles,
isBeta, isBeta,
pkg, pkg,
branch,
scpURL = "jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/", scpURL = "jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/",
cdnURL = "http://code.origin.jquery.com/", cdnURL = "http://code.origin.jquery.com/",
repoURL = "git://github.com/jquery/jquery.git", repoURL = "git://github.com/dmethvin/jquery.git",
branch = "master", //repoURL = "git://github.com/jquery/jquery.git",
// Windows needs the .cmd version but will find the non-.cmd // Windows needs the .cmd version but will find the non-.cmd
// On Windows, ensure the HOME environment variable is set // On Windows, ensure the HOME environment variable is set
...@@ -62,18 +62,18 @@ function initialize( next ) { ...@@ -62,18 +62,18 @@ function initialize( next ) {
// First arg should be the version number being released // First arg should be the version number being released
var newver, oldver, var newver, oldver,
rversion = /^(\d)\.(\d+)\.(\d)((?:a|b|rc)\d|pre)?$/, rversion = /^(\d)\.(\d+)\.(\d)((?:a|b|rc)\d|pre)?$/,
version = ( process.argv[2] || "" ).toLowerCase().match( rversion ) || {}, version = ( process.argv[3] || "" ).toLowerCase().match( rversion ) || {},
major = version[1], major = version[1],
minor = version[2], minor = version[2],
patch = version[3], patch = version[3],
xbeta = version[4]; xbeta = version[4];
branch = process.argv[2];
releaseVersion = process.argv[2]; releaseVersion = process.argv[3];
isBeta = !!xbeta; isBeta = !!xbeta;
if ( !major || !minor || !patch ) { if ( !branch || !major || !minor || !patch ) {
die( "Usage: " + process.argv[1] + " releaseVersion" ); die( "Usage: " + process.argv[1] + " branch releaseVersion" );
} }
if ( xbeta === "pre" ) { if ( xbeta === "pre" ) {
die( "Cannot release a 'pre' version!" ); die( "Cannot release a 'pre' version!" );
...@@ -95,7 +95,11 @@ function initialize( next ) { ...@@ -95,7 +95,11 @@ function initialize( next ) {
next(); next();
} }
function checkGitStatus( next ) { function checkGitStatus( next ) {
exec( "git status", function( error, stdout, stderr ) { git( [ "status" ], function( error, stdout, stderr ) {
var onBranch = ((stdout||"").match( /On branch (\S+)/ ) || [])[1];
if ( onBranch !== branch ) {
die( "Branches don't match: Wanted " + branch + ", got " + onBranch );
}
if ( /Changes to be committed/i.test( stdout ) ) { if ( /Changes to be committed/i.test( stdout ) ) {
die( "Please commit changed files before attemping to push a release." ); die( "Please commit changed files before attemping to push a release." );
} }
...@@ -107,12 +111,18 @@ function checkGitStatus( next ) { ...@@ -107,12 +111,18 @@ function checkGitStatus( next ) {
} }
function tagReleaseVersion( next ) { function tagReleaseVersion( next ) {
updatePackageVersion( releaseVersion ); updatePackageVersion( releaseVersion );
exec( 'git commit -a -m "Tagging the ' + releaseVersion + ' release."', function(){ git( [ "commit", "-a", "-m", "Tagging the " + releaseVersion + " release." ], function(){
exec( "git tag " + releaseVersion, next); git( [ "tag", releaseVersion ], next, debug);
}); }, debug);
} }
function gruntBuild( next ) { function gruntBuild( next ) {
exec( gruntCmd, next ); exec( gruntCmd, [], function( error, stdout ) {
if ( error ) {
die( error + stderr );
}
console.log( stdout );
next();
}, debug);
} }
function makeReleaseCopies( next ) { function makeReleaseCopies( next ) {
finalFiles = {}; finalFiles = {};
...@@ -130,17 +140,17 @@ function makeReleaseCopies( next ) { ...@@ -130,17 +140,17 @@ function makeReleaseCopies( next ) {
} }
function setNextVersion( next ) { function setNextVersion( next ) {
updatePackageVersion( nextVersion ); updatePackageVersion( nextVersion );
exec( 'git commit -a -m "Updating the source version to ' + nextVersion + '"', next ); git( [ "commit", "-a", "-m", "Updating the source version to " + nextVersion ], next, debug );
} }
function uploadToCDN( next ) { function uploadToCDN( next ) {
var cmds = []; var cmds = [];
Object.keys( finalFiles ).forEach(function( name ) { Object.keys( finalFiles ).forEach(function( name ) {
cmds.push(function( x ){ cmds.push(function( nxt ){
exec( "scp " + name + " " + scpURL, x, skipRemote ); exec( "scp", [ name, scpURL ], nxt, debug || skipRemote );
}); });
cmds.push(function( x ){ cmds.push(function( nxt ){
exec( "curl '" + cdnURL + name + "?reload'", x, skipRemote ); exec( "curl", [ cdnURL + name + "?reload" ], nxt, debug || skipRemote );
}); });
}); });
cmds.push( next ); cmds.push( next );
...@@ -148,7 +158,7 @@ function uploadToCDN( next ) { ...@@ -148,7 +158,7 @@ function uploadToCDN( next ) {
steps.apply( this, cmds ); steps.apply( this, cmds );
} }
function pushToGithub( next ) { function pushToGithub( next ) {
exec("git push --tags "+ repoURL + " " + branch, next, skipRemote ); git( [ "push", "--tags", repoURL, branch ], next, debug || skipRemote );
} }
//============================== //==============================
...@@ -174,18 +184,23 @@ function copy( oldFile, newFile ) { ...@@ -174,18 +184,23 @@ function copy( oldFile, newFile ) {
fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) ); fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) );
} }
} }
function exec( cmd, fn, skip ) { function git( args, fn, skip ) {
if ( debug || skip ) { exec( "git", args, fn, skip );
console.log( "# " + cmd ); }
fn(); function exec( cmd, args, fn, skip ) {
if ( skip ) {
console.log( "# " + cmd + " " + args.join(" ") );
fn( "", "", "" );
} else { } else {
console.log( cmd ); console.log( cmd + " " + args.join(" ") );
child.exec( cmd, { env: process.env }, function( err, stdout, stderr ) { child.execFile( cmd, args, { env: process.env },
if ( err ) { function( err, stdout, stderr ) {
die( stderr || stdout || err ); if ( err ) {
die( stderr || stdout || err );
}
fn.apply( this, arguments );
} }
fn(); );
});
} }
} }
function die( msg ) { function die( msg ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment