Skip to content

Commit 8e76cb7

Browse files
committed
Update build script.
1 parent 2af1538 commit 8e76cb7

File tree

2 files changed

+37
-27
lines changed

2 files changed

+37
-27
lines changed

build/release-notes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ var fs = require("fs"),
99
extract = /<a href="\/ticket\/(\d+)" title="View ticket">(.*?)<[^"]+"component">\s*(\S+)/g;
1010

1111
var opts = {
12-
version: "1.8.2",
13-
short_version: "1.8.2",
14-
final_version: "1.8.2",
12+
version: "1.8.3",
13+
short_version: "1.8.3",
14+
final_version: "1.8.3",
1515
categories: []
1616
};
1717

build/release.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ var debug = false,
1010
var fs = require("fs"),
1111
child = require("child_process"),
1212
path = require("path"),
13-
which = require('which').sync;
13+
which = require("which").sync;
1414

1515
var releaseVersion,
1616
nextVersion,
1717
finalFiles,
1818
isBeta,
1919
pkg,
20+
branch,
2021

2122
scpURL = "[email protected]:/var/www/html/code.jquery.com/",
2223
cdnURL = "http://code.origin.jquery.com/",
23-
repoURL = "git://github.com/jquery/jquery.git",
24-
branch = "master",
24+
repoURL = "git@github.com:dmethvin/jquery.git",
25+
//repoURL = "[email protected]:jquery/jquery.git",
2526

2627
// Windows needs the .cmd version but will find the non-.cmd
2728
// On Windows, ensure the HOME environment variable is set
@@ -62,18 +63,18 @@ function initialize( next ) {
6263
// First arg should be the version number being released
6364
var newver, oldver,
6465
rversion = /^(\d)\.(\d+)\.(\d)((?:a|b|rc)\d|pre)?$/,
65-
version = ( process.argv[2] || "" ).toLowerCase().match( rversion ) || {},
66+
version = ( process.argv[3] || "" ).toLowerCase().match( rversion ) || {},
6667
major = version[1],
6768
minor = version[2],
6869
patch = version[3],
6970
xbeta = version[4];
7071

71-
72-
releaseVersion = process.argv[2];
72+
branch = process.argv[2];
73+
releaseVersion = process.argv[3];
7374
isBeta = !!xbeta;
7475

75-
if ( !major || !minor || !patch ) {
76-
die( "Usage: " + process.argv[1] + " releaseVersion" );
76+
if ( !branch || !major || !minor || !patch ) {
77+
die( "Usage: " + process.argv[1] + " branch releaseVersion" );
7778
}
7879
if ( xbeta === "pre" ) {
7980
die( "Cannot release a 'pre' version!" );
@@ -95,7 +96,11 @@ function initialize( next ) {
9596
next();
9697
}
9798
function checkGitStatus( next ) {
98-
exec( "git status", function( error, stdout, stderr ) {
99+
child.execFile( "git", [ "status" ], {}, function( error, stdout, stderr ) {
100+
var onBranch = (stdout.match( /On branch (\S+)/ ) || [])[1];
101+
if ( onBranch !== branch ) {
102+
die( "Branches don't match: Wanted " + branch + ", got " + onBranch );
103+
}
99104
if ( /Changes to be committed/i.test( stdout ) ) {
100105
die( "Please commit changed files before attemping to push a release." );
101106
}
@@ -107,12 +112,12 @@ function checkGitStatus( next ) {
107112
}
108113
function tagReleaseVersion( next ) {
109114
updatePackageVersion( releaseVersion );
110-
exec( 'git commit -a -m "Tagging the ' + releaseVersion + ' release."', function(){
111-
exec( "git tag " + releaseVersion, next);
115+
git( [ "commit", "-a", "-m", "Tagging the " + releaseVersion + " release." ], function(){
116+
git( [ "tag", releaseVersion ], next);
112117
});
113118
}
114119
function gruntBuild( next ) {
115-
exec( gruntCmd, next );
120+
exec( gruntCmd, [], next );
116121
}
117122
function makeReleaseCopies( next ) {
118123
finalFiles = {};
@@ -130,25 +135,25 @@ function makeReleaseCopies( next ) {
130135
}
131136
function setNextVersion( next ) {
132137
updatePackageVersion( nextVersion );
133-
exec( 'git commit -a -m "Updating the source version to ' + nextVersion + '"', next );
138+
git( [ "commit", "-a", "-m", "Updating the source version to " + nextVersion ], next );
134139
}
135140
function uploadToCDN( next ) {
136141
var cmds = [];
137142

138143
Object.keys( finalFiles ).forEach(function( name ) {
139144
cmds.push(function( x ){
140-
exec( "scp " + name + " " + scpURL, x, skipRemote );
145+
exec( "scp", [ name, scpURL ], x, skipRemote );
141146
});
142147
cmds.push(function( x ){
143-
exec( "curl '" + cdnURL + name + "?reload'", x, skipRemote );
148+
exec( "curl", [ cdnURL + name + "?reload" ], x, skipRemote );
144149
});
145150
});
146151
cmds.push( next );
147152

148153
steps.apply( this, cmds );
149154
}
150155
function pushToGithub( next ) {
151-
exec("git push --tags "+ repoURL + " " + branch, next, skipRemote );
156+
git( [ "push", "--tags", repoURL, branch ], next, skipRemote );
152157
}
153158

154159
//==============================
@@ -174,18 +179,23 @@ function copy( oldFile, newFile ) {
174179
fs.writeFileSync( newFile, fs.readFileSync( oldFile, "utf8" ) );
175180
}
176181
}
177-
function exec( cmd, fn, skip ) {
182+
function git( args, fn, skip ) {
183+
exec( "git", args, fn, skip );
184+
}
185+
function exec( cmd, args, fn, skip ) {
178186
if ( debug || skip ) {
179-
console.log( "# " + cmd );
187+
console.log( "# " + cmd + " " + args.join(" ") );
180188
fn();
181189
} else {
182-
console.log( cmd );
183-
child.exec( cmd, { env: process.env }, function( err, stdout, stderr ) {
184-
if ( err ) {
185-
die( stderr || stdout || err );
190+
console.log( cmd + " " + args.join(" ") );
191+
child.execFile( cmd, args, { env: process.env },
192+
function( err, stdout, stderr ) {
193+
if ( err ) {
194+
die( stderr || stdout || err );
195+
}
196+
fn();
186197
}
187-
fn();
188-
});
198+
);
189199
}
190200
}
191201
function die( msg ) {

0 commit comments

Comments
 (0)