Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
d3085313
Commit
d3085313
authored
Aug 09, 2012
by
Dave Methvin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update release script; use package.json as the One True Version.
parent
060eabc9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
127 deletions
+160
-127
release.js
build/release.js
+160
-126
version.txt
version.txt
+0
-1
No files found.
build/release.js
View file @
d3085313
#!/usr/bin/env node
#!/usr/bin/env node
/*
/*
* jQuery Release Management
* jQuery
Core
Release Management
*/
*/
// Debugging variables
var
debug
=
false
,
skipRemote
=
true
;
var
fs
=
require
(
"fs"
),
var
fs
=
require
(
"fs"
),
child
=
require
(
"child_process"
),
child
=
require
(
"child_process"
),
debug
=
false
;
path
=
require
(
"path"
),
which
=
require
(
'which'
).
sync
;
var
releaseVersion
,
nextVersion
,
finalFiles
,
isBeta
,
pkg
,
var
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"
,
branch
=
"master"
,
version
=
/^
[\d
.
]
+
(?:(?:
a|b|rc
)\d
+|pre
)?
$/
,
// Windows needs the .cmd version but will find the non-.cmd
versionFile
=
"version.txt"
,
// On Windows, run from the Windows prompt, not a Cygwin shell
gruntCmd
=
process
.
platform
===
"win32"
?
"grunt.cmd"
:
"grunt"
,
file
=
"dist/jquery.js"
,
devFile
=
"dist/jquery.js"
,
minFile
=
"dist/jquery.min.js"
,
minFile
=
"dist/jquery.min.js"
,
files
=
{
releaseFiles
=
{
"jquery-VER.js"
:
file
,
"jquery-VER.js"
:
devFile
,
"jquery-VER.min.js"
:
minFile
"jquery-VER.min.js"
:
minFile
,
},
"jquery.js"
:
devFile
,
"jquery-latest.js"
:
devFile
,
finalFiles
=
{
"jquery.js"
:
file
,
"jquery-latest.js"
:
file
,
"jquery.min.js"
:
minFile
,
"jquery.min.js"
:
minFile
,
"jquery-latest.min.js"
:
minFile
"jquery-latest.min.js"
:
minFile
};
};
exec
(
"git pull && git status"
,
function
(
error
,
stdout
,
stderr
)
{
steps
(
if
(
/Changes to be committed/i
.
test
(
stdout
)
)
{
initialize
,
exit
(
"Please commit changed files before attemping to push a release."
);
checkGitStatus
,
tagReleaseVersion
,
}
else
if
(
/Changes not staged for commit/i
.
test
(
stdout
)
)
{
gruntBuild
,
exit
(
"Please stash files before attempting to push a release."
);
makeReleaseCopies
,
setNextVersion
,
uploadToCDN
,
pushToGithub
,
exit
);
function
initialize
(
next
)
{
// First arg should be the version number being released
var
newver
,
oldver
,
rversion
=
/^
(\d)\.(\d
+
)\.(\d)((?:
a|b|rc
)\d
|pre
)?
$/
,
version
=
(
process
.
argv
[
2
]
||
""
).
toLowerCase
().
match
(
rversion
)
||
{},
major
=
version
[
1
],
minor
=
version
[
2
],
patch
=
version
[
3
],
xbeta
=
version
[
4
];
}
else
{
if
(
debug
)
{
setVersion
(
);
console
.
warn
(
"=== DEBUG MODE ==="
);
}
}
});
function
setVersion
()
{
releaseVersion
=
process
.
argv
[
2
];
var
oldVersion
=
fs
.
readFileSync
(
versionFile
,
"utf8"
);
isBeta
=
!!
xbeta
;
prompt
(
"New Version (was "
+
oldVersion
+
"): "
,
function
(
data
)
{
if
(
data
&&
version
.
test
(
data
)
)
{
fs
.
writeFileSync
(
versionFile
,
data
);
exec
(
"git commit -a -m 'Tagging the "
+
data
+
" release.' && git push && "
+
"git tag "
+
data
+
" && git push origin "
+
data
,
function
()
{
make
(
data
);
});
}
else
{
console
.
error
(
"Malformed version number, please try again."
);
setVersion
();
}
});
}
function
make
(
newVersion
)
{
if
(
!
major
||
!
minor
||
!
patch
)
{
exec
(
"make clean && make"
,
function
(
error
,
stdout
,
stderr
)
{
die
(
"Usage: "
+
process
.
argv
[
1
]
+
" releaseVersion"
);
// TODO: Verify JSLint
}
if
(
xbeta
===
"pre"
)
{
Object
.
keys
(
files
).
forEach
(
function
(
oldName
)
{
die
(
"Cannot release a 'pre' version"
);
var
value
=
files
[
oldName
],
name
=
oldName
.
replace
(
/VER/g
,
newVersion
);
}
if
(
!
(
fs
.
existsSync
||
path
.
existsSync
)(
"package.json"
)
)
{
die
(
"No package.json in this directory"
);
}
copy
(
value
,
name
);
pkg
=
JSON
.
parse
(
fs
.
readFileSync
(
"package.json"
)
);
delete
files
[
oldName
];
console
.
log
(
"Current version is "
+
pkg
.
version
+
"; generating release "
+
releaseVersion
);
files
[
name
]
=
value
;
version
=
pkg
.
version
.
match
(
rversion
);
});
oldver
=
(
+
version
[
1
])
*
10000
+
(
+
version
[
2
]
*
100
)
+
(
+
version
[
3
])
newver
=
(
+
major
)
*
10000
+
(
+
minor
*
100
)
+
(
+
patch
);
if
(
newver
<
oldver
)
{
die
(
"Next version is older than current version!"
);
}
exec
(
"scp "
+
Object
.
keys
(
files
).
join
(
" "
)
+
" "
+
scpURL
,
function
()
{
nextVersion
=
major
+
"."
+
minor
+
"."
+
(
isBeta
?
patch
:
+
patch
+
1
)
+
"pre"
;
setNextVersion
(
newVersion
);
next
();
});
});
}
}
function
checkGitStatus
(
next
)
{
function
setNextVersion
(
newVersion
)
{
exec
(
"git status"
,
function
(
error
,
stdout
,
stderr
)
{
var
isFinal
=
false
;
if
(
/Changes to be committed/i
.
test
(
stdout
)
)
{
die
(
"Please commit changed files before attemping to push a release."
);
if
(
/
(?:
a|b|rc
)\d
+$/
.
test
(
newVersion
)
)
{
newVersion
=
newVersion
.
replace
(
/
(?:
a|b|rc
)\d
+$/
,
"pre"
);
}
else
if
(
/^
\d
+
\.\d
+
\.?(\d
*
)
$/
.
test
(
newVersion
)
)
{
newVersion
=
newVersion
.
replace
(
/^
(\d
+
\.\d
+
\.?)(\d
*
)
$/
,
function
(
all
,
pre
,
num
)
{
return
pre
+
(
pre
.
charAt
(
pre
.
length
-
1
)
!==
"."
?
"."
:
""
)
+
(
num
?
parseFloat
(
num
)
+
1
:
1
)
+
"pre"
;
});
isFinal
=
true
;
}
prompt
(
"Next Version ["
+
newVersion
+
"]: "
,
function
(
data
)
{
if
(
!
data
)
{
data
=
newVersion
;
}
}
if
(
/Changes not staged for commit/i
.
test
(
stdout
)
)
{
if
(
version
.
test
(
data
)
)
{
die
(
"Please stash files before attempting to push a release."
);
fs
.
writeFileSync
(
versionFile
,
data
);
exec
(
"git commit -a -m 'Updating the source version to "
+
data
+
"' && git push"
,
function
()
{
if
(
isFinal
)
{
makeFinal
(
newVersion
);
}
});
}
else
{
console
.
error
(
"Malformed version number, please try again."
);
setNextVersion
(
newVersion
);
}
}
next
();
});
});
}
}
function
tagReleaseVersion
(
next
)
{
function
makeFinal
(
newVersion
)
{
updatePackageVersion
(
releaseVersion
);
var
all
=
Object
.
keys
(
finalFiles
);
exec
(
'git commit -a -m "Tagging the '
+
releaseVersion
+
' release."'
,
function
(){
exec
(
"git tag "
+
releaseVersion
,
next
);
// Copy all the files
all
.
forEach
(
function
(
name
)
{
copy
(
finalFiles
[
name
],
name
);
});
});
}
// Upload files to CDN
function
gruntBuild
(
next
)
{
exec
(
"scp "
+
all
.
join
(
" "
)
+
" "
+
scpURL
,
function
()
{
exec
(
gruntCmd
,
next
);
exec
(
"curl '"
+
cdnURL
+
"{"
+
all
.
join
(
","
)
+
"}?reload'"
,
function
()
{
}
console
.
log
(
"Done."
);
function
makeReleaseCopies
(
next
)
{
});
finalFiles
=
{};
Object
.
keys
(
releaseFiles
).
forEach
(
function
(
key
)
{
var
builtFile
=
releaseFiles
[
key
],
releaseFile
=
key
.
replace
(
/VER/g
,
releaseVersion
);
// Beta releases don't update the jquery-latest etc. copies
if
(
!
isBeta
||
key
!==
releaseFile
)
{
copy
(
builtFile
,
releaseFile
);
finalFiles
[
releaseFile
]
=
builtFile
;
}
});
});
next
();
}
}
function
setNextVersion
(
next
)
{
updatePackageVersion
(
nextVersion
);
exec
(
"git commit -a -m 'Updating the source version to "
+
nextVersion
+
"'"
,
next
);
}
function
uploadToCDN
(
next
)
{
var
cmds
=
[];
function
copy
(
oldFile
,
newFile
)
{
Object
.
keys
(
finalFiles
).
forEach
(
function
(
name
)
{
if
(
debug
)
{
cmds
.
push
(
function
(
x
){
console
.
log
(
"Copying "
+
oldFile
+
" to "
+
newFile
);
exec
(
"scp "
+
name
+
" "
+
scpURL
,
x
);
});
cmds
.
push
(
function
(
x
){
exec
(
"curl '"
+
cdnURL
+
name
+
"?reload'"
,
x
);
});
});
cmds
.
push
(
next
);
if
(
skipRemote
)
{
console
.
warn
(
"Skipping remote file copies"
);
next
();
}
else
{
}
else
{
fs
.
writeFileSync
(
newFile
,
fs
.
readFileSync
(
oldFile
,
"utf8"
)
);
steps
.
apply
(
this
,
cmds
);
}
}
}
}
function
pushToGithub
(
next
)
{
function
prompt
(
msg
,
callback
)
{
if
(
skipRemote
)
{
process
.
stdout
.
write
(
msg
);
console
.
warn
(
"Skipping git push --tags"
);
next
();
process
.
stdin
.
resume
();
}
else
{
process
.
stdin
.
setEncoding
(
"utf8"
);
exec
(
"git push --tags "
+
repoURL
+
" "
+
branch
,
next
);
}
process
.
stdin
.
once
(
"data"
,
function
(
chunk
)
{
process
.
stdin
.
pause
();
callback
(
chunk
.
replace
(
/
\n
*$/g
,
""
)
);
});
}
}
//==============================
function
steps
()
{
var
cur
=
0
,
steps
=
arguments
;
(
function
next
(){
var
step
=
steps
[
cur
++
];
step
(
next
);
})();
}
function
updatePackageVersion
(
ver
)
{
console
.
log
(
"Updating package.json version to "
+
ver
);
pkg
.
version
=
ver
;
if
(
!
debug
)
{
fs
.
writeFileSync
(
"package.json"
,
JSON
.
stringify
(
pkg
,
null
,
"
\
t"
)
+
"
\n
"
);
}
}
function
copy
(
oldFile
,
newFile
)
{
console
.
log
(
"Copying "
+
oldFile
+
" to "
+
newFile
);
if
(
!
debug
)
{
fs
.
writeFileSync
(
newFile
,
fs
.
readFileSync
(
oldFile
,
"utf8"
)
);
}
}
function
exec
(
cmd
,
fn
)
{
function
exec
(
cmd
,
fn
)
{
console
.
log
(
cmd
);
if
(
debug
)
{
if
(
debug
)
{
console
.
log
(
cmd
);
fn
();
fn
();
}
else
{
}
else
{
child
.
exec
(
cmd
,
fn
);
child
.
exec
(
cmd
,
{
env
:
process
.
env
},
function
(
err
,
stdout
,
stderr
)
{
if
(
err
)
{
die
(
stderr
||
stdout
||
err
);
}
fn
();
});
}
}
}
}
function
die
(
msg
)
{
function
exit
(
msg
)
{
console
.
error
(
"Error: "
+
msg
);
if
(
msg
)
{
console
.
error
(
"
\n
Error: "
+
msg
);
}
process
.
exit
(
1
);
process
.
exit
(
1
);
}
}
function
exit
()
{
process
.
exit
(
0
);
}
version.txt
deleted
100644 → 0
View file @
060eabc9
1.8pre
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment