This script automates releases for all jQuery projects. It is designed to create consistency between projects and reduce the burden of maintaining individual release scripts.
Creating a release is as simple as cloning this repository and telling the script which project to use. In order to ensure a clean and proper release is created, you should always start from a new clone of this repository.
git clone [email protected]:jquery/jquery-release.git
cd jquery-release
npm install
node release.js --remote=jquery/<project-name>
You can do a test run of the release script by using a different remote repository. It is recommended to perform tests from a fresh clone of the project being released. The script is smart enough to detect if you're using an official repository and adjust which actions are taken so that undesired actions, such as publishing to npm, don't occur for test runs.
You can also explicitly specify --dry-run
to skip actions that affect external state.
When working on features of this script, adapt the following to simplify testing a bit, replacing the paths for project
and cdn
:
#!/bin/sh -e
# uncomment next line to debug this script
# set -x
project=/path/to/fake-project
cdn=/path/to/fake-cdn
cd $project
git checkout main
set +e
git tag -d 0.0.1
set -e
git reset --hard safe
git checkout asdf
cd -
cd $cdn
git push -f
cd -
npm run clean
env TEST_REMOTE=$cdn node release.js --dry-run --remote=$project
Save as test-release.sh
in the checkout of this repo, make it executable with chmod +x test-release.sh
, then run with ./test-release.sh
.
If you have access to the private repositories fake-project and fake-cdn, you can use them by dropping the --dry-run
argument and updating the TEST_REMOTE
environment variable to "[email protected]:jquery/fake-cdn.git".
See the usage documentation for the full set of options. You can also run the script with no parameters to see the usage.
This script only performs the set of common functionality across all projects. Each project may have additional functionality. Any project-specific configuration and functionality must be defined in the build/release.js
file inside the project's repository.
Here's a minimal example:
module.exports = function( Release ) {
Release.define({
issueTracker: "trac",
contributorReportId: 37,
changelogShell: function() {
return "# Amazing Changelog for v" + Release.newVersion + "\n";
}
});
};
Performs any project-specific checks to ensure the repository is in a good state to be released. For example, there is a built-in check to ensure that AUTHORS.txt
is up-to-date.
This method has no return value. If a project-specific check fails, the script should use Release.abort()
to prevent the release from continuing.
This method may be synchronous or asynchronous depending on the presence of callback
. If present, the callback must be invoked.
Generates any release artifacts that should be included in the release. The callback must be invoked with an array of files that should be committed before creating the tag.
Defines the shell for the changelog. The changelog is created by concatenating the shell, the commit log, and the issue list.
If using Trac, return a different milestone to be used in the queries to generate a changelog and list of contributors. Defaults to newVersion
.
A function that returns an array of tags to apply to the npm release. Every release must contain at least one tag.
Which type of issue tracker is being used for the project. Must be either "trac"
or "github"
.
If using Trac, this defines which report will produce a list of contributors for a specific release.
See docs/trac-contributors.sql for the SQL necessary to create the Trac report.
Note: This is a property on the exports
object in build/release.js
.
An array of release-specific dependencies. Dependencies can be listed here instead of in devDependencies
in package.json
so that contributors don't need to install dependencies which are only necessary for the release.
Defines new properties and methods to add to the Release
object.
Aborts the release and prints the message. If an error object is provided, it is used for the stack trace, otherwise the current call stack is used.
Executes the given command
. You can pass { silent: true }
to suppress output on the command line.
Returns the output.
Executes the given git command
. If the command fails, the release will be aborted and errorMessage
will be displayed.
Gets a git log using the specified format. If the log fails, the release will be aborted.
Returns an array of commits.
Prompts the user for input.
Passes the input to callback
.
Prompts the user to confirm they want to continue with the release script. If the user decides not to continue, the release will be aborted and callback
won't be invoked.
Prompts the user to review the output and confirm they want to continue with the release script. If the user decides not to continue, the release will be aborted and callback
won't be invoked.
Gets the results of a Trac query, with tab-delimited results.
Returns the tab-delimited string.
Gets the contents of package.json
as an object.
Saves package
to package.json
, preserving indentation style.
Executes the array of methods
(minimum one element) step by step. For any given method, if that method accepts arguments (method.length > 0
), it will pass a callback that the method needs to execute when done, making the method call async. Otherwise the method is assumed to be sync and the next method runs immediately.
Once all methods are executed, the done
callback is executed.
This function is available in case the project requires more distribution than what is provided. It is called after building, but before publishing to npm.
Whether this is a test release. Test releases don't publish to npm and use the fake-cdn project instead of publishing to the real CDN.
The name of the project being released.
The location of the remote repository.
The version number for a pre-release version, or false
for stable releases.
The main directory used for the release script.
The directory for the local repository.
The version being released.
The previous release version (used for determining what changed).
The version that will be set in package.json
after the release.
Which directory contains files to publish to the jQuery CDN. Set to false
to prevent publishing to the jQuery CDN. Defaults to "dist/cdn"
.
Set to true
to publish a release via npm. Defaults to false
.
Timestamp for the release tag.
Which branch the release is being generated from (defaults to main
).