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
a8988e3c
Commit
a8988e3c
authored
Apr 26, 2011
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a Node-based release management script for pushing new releases to the CDN.
parent
fd11df1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
169 additions
and
0 deletions
+169
-0
release.js
build/release.js
+169
-0
No files found.
build/release.js
0 → 100644
View file @
a8988e3c
#!/usr/bin/env node
/*
* jQuery Release Management
*/
var
fs
=
require
(
"fs"
),
child
=
require
(
"child_process"
),
debug
=
false
;
var
scpURL
=
"jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/"
,
cdnURL
=
"http://code.origin.jquery.com/"
,
version
=
/^
[\d
.
]
+
(?:(?:
a|b|rc
)\d
+|pre
)?
$/
,
versionFile
=
"version.txt"
,
file
=
"dist/jquery.js"
,
minFile
=
"dist/jquery.min.js"
,
files
=
{
"jquery-VER.js"
:
file
,
"jquery-VER.min.js"
:
minFile
},
finalFiles
=
{
"jquery.js"
:
file
,
"jquery-latest.js"
:
file
,
"jquery.min.js"
:
minFile
,
"jquery-latest.min.js"
:
minFile
};
exec
(
"git pull && git status"
,
function
(
error
,
stdout
,
stderr
)
{
if
(
/Changes to be committed/i
.
test
(
stdout
)
)
{
exit
(
"Please commit changed files before attemping to push a release."
);
}
else
if
(
/Changes not staged for commit/i
.
test
(
stdout
)
)
{
exit
(
"Please stash files before attempting to push a release."
);
}
else
{
setVersion
();
}
});
function
setVersion
()
{
var
oldVersion
=
fs
.
readFileSync
(
versionFile
,
"utf8"
);
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
)
{
exec
(
"make clean && make"
,
function
(
error
,
stdout
,
stderr
)
{
// TODO: Verify JSLint
Object
.
keys
(
files
).
forEach
(
function
(
oldName
)
{
var
value
=
files
[
oldName
],
name
=
oldName
.
replace
(
/VER/g
,
newVersion
);
copy
(
value
,
name
);
delete
files
[
oldName
];
files
[
name
]
=
value
;
});
exec
(
"scp "
+
Object
.
keys
(
files
).
join
(
" "
)
+
" "
+
scpURL
,
function
()
{
setNextVersion
(
newVersion
);
});
});
}
function
setNextVersion
(
newVersion
)
{
var
isFinal
=
false
;
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
+
(
num
?
parseFloat
(
num
)
+
1
:
1
)
+
"pre"
;
});
isFinal
=
true
;
}
prompt
(
"Next Version ["
+
newVersion
+
"]: "
,
function
(
data
)
{
if
(
!
data
)
{
data
=
newVersion
;
}
if
(
version
.
test
(
data
)
)
{
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
);
}
});
}
function
makeFinal
(
newVersion
)
{
var
all
=
Object
.
keys
(
finalFiles
);
// Copy all the files
all
.
forEach
(
function
(
name
)
{
copy
(
finalFiles
[
name
],
name
);
});
// Upload files to CDN
exec
(
"scp "
+
all
.
join
(
" "
)
+
" "
+
scpURL
,
function
()
{
exec
(
"curl '"
+
cdnURL
+
"{"
+
all
.
join
(
","
)
+
"}?reload'"
,
function
()
{
console
.
log
(
"Done."
);
});
});
}
function
copy
(
oldFile
,
newFile
)
{
if
(
debug
)
{
console
.
log
(
"Copying "
+
oldFile
+
" to "
+
newFile
);
}
else
{
fs
.
writeFileSync
(
newFile
,
fs
.
readFileSync
(
oldFile
,
"utf8"
)
);
}
}
function
prompt
(
msg
,
callback
)
{
process
.
stdout
.
write
(
msg
);
process
.
stdin
.
resume
();
process
.
stdin
.
setEncoding
(
"utf8"
);
process
.
stdin
.
once
(
"data"
,
function
(
chunk
)
{
process
.
stdin
.
pause
();
callback
(
chunk
.
replace
(
/
\n
*$/g
,
""
)
);
});
}
function
exec
(
cmd
,
fn
)
{
if
(
debug
)
{
console
.
log
(
cmd
);
fn
();
}
else
{
child
.
exec
(
cmd
,
fn
);
}
}
function
exit
(
msg
)
{
if
(
msg
)
{
console
.
error
(
"
\n
Error: "
+
msg
);
}
process
.
exit
(
1
);
}
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