Note: This document describes how to release java_tools for a JDK version that is already tested by Bazel. This document is addressed to trusted members of the Bazel team who have access to the Buildkite Bazel trusted pipelines and GCP. If you want to release the Java tools but don’t have these permissions please contact someone from the Bazel EngProd team ([email protected]).
The steps below are only meant to be followed as presented in order to release a new java_tools version. To understand the mechanism behind these steps and for more details about how the process works, see Behind the java_tools release process.
- Create a new tracking issue for the release in this repository and add the
release
label. See #59 as an example. - Trigger a new build of the
java_tools binaries pipeline
. Set the message field to "java_tools release [version] [rc]", and leave the commit field as "HEAD" and branch as "master". See example. - Identify and set the following environment variables:
-
COMMIT_HASH
the commit hash where the pipeline was run (see below) -
NEW_VERSION
the new version number you’re trying to release (e.g.11.09
) -
RC
the number of the current release candidateFor example:
export COMMIT_HASH=7bd0ab63a8441c3f3d7f495d09ed2bed38762874 export NEW_VERSION=11.09 export RC=1
-
Create a new release candidate by running the command below from the bazel repo:
src/create_java_tools_release.sh \ --commit_hash $COMMIT_HASH \ --java_tools_version $NEW_VERSION \ --rc $RC --release false
The script will output the sha256sum of the rc artifacts for linux, darwin and windows.
Sample output:
$ src/create_java_tools_release.sh --commit_hash 7bd0ab63a8441c3f3d7f495d09ed2bed38762874 --java_tools_version 11.9 --rc 1 --release false release_candidates/java/v11.9/java_tools_linux-v11.9-rc1.zip 512582cac5b7ea7974a77b0da4581b21f546c9478f206eedf54687eeac035989 release_candidates/java/v11.9/java_tools_windows-v11.9-rc1.zip 677ab910046205020fd715489147c2bcfad8a35d9f5d94fdc998d217545bd87a release_candidates/java/v11.9/java_tools_darwin_x86_64-v11.9-rc1.zip b9e962c6a836ba1d7573f2473fab3a897c6370d4c2724bde4017b40932ff4fe4 release_candidates/java/v11.9/java_tools_darwin_arm64-v11.9-rc1.zip 3a897c6370d4c2724bde4017b40932ff4fe4b9e962c6a836ba1d7573f2473fab release_candidates/java/v11.9/java_tools-v11.9-rc1.zip 5cd59ea6bf938a1efc1e11ea562d37b39c82f76781211b7cd941a2346ea8484d
-
Create a new branch in the rules_java repository
-
Name the branch
java_v[version number]
, e.g.java_v11.09
-
Edit java_tools_repos() by updating the
sha256
andurls
fields forremote_java_tools
with the correct version, rc, sha256sum, and url (see output from step 4)Example:
maybe( http_archive, name = "remote_java_tools", sha256 = "5cd59ea6bf938a1efc1e11ea562d37b39c82f76781211b7cd941a2346ea8484d", urls = [ "https://mirror.bazel.build/bazel_java_tools/release_candidates/java/v11.9/java_tools-v11.9-rc1.zip", ], )
-
Repeat for
remote_java_tools_linux
,remote_java_tools_windows
,remote_java_tools_darwin_x86_64
andremote_java_tools_darwin_arm64
-
Refer to this example
- Edit workspace_deps.bzl in the Bazel repository and create a new pull request. This PR will trigger the CI presubmit.
- Get the commit hash for the changes made in step 5 (e.g.
d1196d250c17dfffed52db13c75d4f9b9cd20617
for this commit)-
Download the tar.gz file at
https://github.com/bazelbuild/rules_java/archive/<commit hash>.tar.gz
-
Run
shasum -a 256 <file>
-
Update the following fields (note: add
strip_prefix
)Example:
"archive": "d1196d250c17dfffed52db13c75d4f9b9cd20617.tar.gz", "sha256": "0f65c471b99c79e97dd18a3571d3707b4dbfc31ff8e9bf7083a09aae0adb7b5e", "strip_prefix": "rules_java-d1196d250c17dfffed52db13c75d4f9b9cd20617", "urls": ["https://github.com/bazelbuild/rules_java/archive/d1196d250c17dfffed52db13c75d4f9b9cd20617.tar.gz"],
-
Refer to this PR (specifically this commit)
-
- Add archive_override to MODULE.bazel
-
To calculate the
integrity
value of the source archive, do:$ git clone https://github.com/bazelbuild/bazel-central-registry.git $ cd bazel-central-registry $ python3 ./tools/calc_integrity.py https://github.com/bazelbuild/rules_java/archive/d1196d250c17dfffed52db13c75d4f9b9cd20617.tar.gz
-
Add archive_override with the
integrity
and commit hash from aboveExample:
archive_override( module_name = "rules_java", urls = ["https://github.com/bazelbuild/rules_java/archive/d1196d250c17dfffed52db13c75d4f9b9cd20617.tar.gz"], integrity = "sha256-4YvfBdBJhBvZNJh8nz0RRpdMI+CFuM4O8xRb3d1GinA=", strip_prefix = "rules_java-d1196d250c17dfffed52db13c75d4f9b9cd20617", )
-
Refer to this PR (specifically this commit)
-
-
Trigger a new build on Downstream https://buildkite.com/bazel/bazel-at-head-plus-downstream. Set the message field to "java_tools release [version] [rc]", leave the commit field as "HEAD", and use
pull/[PRNUMBER]/head
for the branch. See example.-
Check the results of the build to confirm that there are no new failures (i.e. all failures also appear at HEAD). To do this, compare the results to the latest run here.
-
If the CI finishes successfully:
-
Create the release artifacts from the release candidate:
src/create_java_tools_release.sh \ --java_tools_version $NEW_VERSION \ --rc $RC --release true
The script will output the sha256sum of the rc artifacts for linux, darwin and windows.
Sample output:
$ src/create_java_tools_release.sh --commit_hash 7bd0ab63a8441c3f3d7f495d09ed2bed38762874 --java_tools_version 11.9 --rc 1 --release true releases/java/v11.9/java_tools_linux-v11.9.zip 512582cac5b7ea7974a77b0da4581b21f546c9478f206eedf54687eeac035989 releases/java/v11.9/java_tools_windows-v11.9.zip 677ab910046205020fd715489147c2bcfad8a35d9f5d94fdc998d217545bd87a releases/java/v11.9/java_tools_darwin_x86_64-v11.9.zip b9e962c6a836ba1d7573f2473fab3a897c6370d4c2724bde4017b40932ff4fe4 releases/java/v11.9/java_tools_darwin_arm64-v11.9.zip 3a897c6370d4c2724bde4017b40932ff4fe4b9e962c6a836ba1d7573f2473fab releases/java/v11.9/java_tools-v11.9.zip 5cd59ea6bf938a1efc1e11ea562d37b39c82f76781211b7cd941a2346ea8484d
-
Update the release in the java_tools releases page
-
Click on "Draft a new release"
- Set tag to java_v[version number], e.g. java_v11.09
- Set target to master
- Add the name, sha256, and urls to the description
Example:
To use this java_tools release, add to your WORKSPACE file the definitions: http_archive( name = "remote_java_tools", sha256 = "5cd59ea6bf938a1efc1e11ea562d37b39c82f76781211b7cd941a2346ea8484d", urls = [ "https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools-v11.9.zip", "https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools-v11.9.zip", ], ) http_archive( name = "remote_java_tools_linux", sha256 = "512582cac5b7ea7974a77b0da4581b21f546c9478f206eedf54687eeac035989", urls = [ "https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools_linux-v11.9.zip", "https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools_linux-v11.9.zip", ], ) http_archive( name = "remote_java_tools_windows", sha256 = "677ab910046205020fd715489147c2bcfad8a35d9f5d94fdc998d217545bd87a", urls = [ "https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools_windows-v11.9.zip", "https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools_windows-v11.9.zip", ], ) http_archive( name = "remote_java_tools_darwin_x86_64", sha256 = "b9e962c6a836ba1d7573f2473fab3a897c6370d4c2724bde4017b40932ff4fe4", urls = [ "https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools_darwin_x86_64-v11.9.zip", "https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools_darwin_x86_64-v11.9.zip", ], ) http_archive( name = "remote_java_tools_darwin_arm64", sha256 = "3a897c6370d4c2724bde4017b40932ff4fe4b9e962c6a836ba1d7573f2473fab", urls = [ "https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools_darwin_arm64-v11.9.zip", "https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools_darwin_arm64-v11.9.zip", ], )
- Download the 5 .zip files from the updated https://mirror.bazel.build URLs above and attach them to the release
- Set as the latest release
- Refer to this example
-
-
Return to the rules_java repository and create a PR to update java_tools_repos() with the latest java_tools versions. After making sure presubmits pass, send the PR for review and assign
@hvadehra
. Refer to this example (it also includes the 2 updates needed for the next step). -
Follow the steps here to release a new version of rules_java. Reach out to
@hvadhera
to decide/confirm the version number bump.- In order for checks to pass in the next step, the release must be mirrored to the Bazel Central Registry. Make sure that a PR is opened and approved in the BCR repository (example)
- One time step: Add the
publish-to-bcr
app to your personal fork ofbazelbuild/bazel-central-registry
. Refer to the instructions here.
- One time step: Add the
- In order for checks to pass in the next step, the release must be mirrored to the Bazel Central Registry. Make sure that a PR is opened and approved in the BCR repository (example)
-
Update Bazel with the final rules_java version by editing the following files. After making sure presubmits pass, send the PR for review and assign
@hvadehra
. Refer to this PR.- https://github.com/bazelbuild/bazel/blob/master/workspace_deps.bzl (example)
- https://github.com/bazelbuild/bazel/blob/master/src/MODULE.tools (example)
- https://github.com/bazelbuild/bazel/blob/master/MODULE.bazel# (example). Remove the archive_override() method as well.
-
-
If the CI finishes unsuccessfully find the reasons why the CI is failing and file bugs. After the bugs are fixed start all over again from step 2 and create the next release candidate. This case is highly unlikely because Bazel already tests the
java_tools
built at head.
-