diff --git a/.github/ISSUE_TEMPLATE/release.md b/.github/ISSUE_TEMPLATE/release.md new file mode 100644 index 0000000..55a3aa8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/release.md @@ -0,0 +1,17 @@ +--- +name: 'Release tracker' +about: Use this template to request for a new java_tools release +title: 'Release: java_tools vX.Y.Z' +labels: ['release','P1'] +assignees: + - iancha1992 + - sgowroji +--- + +**Link to relevant issue and/or commit:** + +**Other details:** + + + +cc @bazelbuild/triage diff --git a/README.md b/README.md index 8e5fa82..a2cc933 100644 --- a/README.md +++ b/README.md @@ -9,60 +9,20 @@ incrementally to this repository. # Upgrade a Bazel project to use custom java_tools version To use a specific java_tools release in your Bazel project please add the `http_archive` -definitions in your WORKSPACE file and set the options `--java_toolchain` and/or -`--host_java_toolchain` accordingly. All java_tools releases can be found under -https://github.com/bazelbuild/java_tools/releases. +definitions in your WORKSPACE file. -For example to use java_tools_javac11-v6.0 you can add the following to the WORKSPACE -file: +For Bazel versions above 4.0.0, use java_tools releases >= v11. No additional options are needed. -``` -http_archive( - name = "remote_java_tools_linux", - sha256 = "37acb8380b1dd6c31fd27a19bf3da821c9b02ee93c6163fce36f070a806516b5", - urls = [ - "https://mirror.bazel.build/bazel_java_tools/releases/javac11/v6.0/java_tools_javac11_linux-v6.0.zip", - "https://github.com/bazelbuild/java_tools/releases/download/javac11-v6.0/java_tools_javac11_linux-v6.0.zip", - ], -) -http_archive( - name = "remote_java_tools_windows", - sha256 = "384e138ca58842ea563fb7efbe0cb9c5c381bd4de1f6a31f0256823325f81ccc", - urls = [ - "https://mirror.bazel.build/bazel_java_tools/releases/javac11/v6.0/java_tools_javac11_windows-v6.0.zip", - "https://github.com/bazelbuild/java_tools/releases/download/javac11-v6.0/java_tools_javac11_windows-v6.0.zip", - ], -) -http_archive( - name = "remote_java_tools_darwin", - sha256 = "5a9f320c33424262e505151dd5c6903e36678a0f0bbdaae67bcf07f41d8c7cf3", - urls = [ - "https://mirror.bazel.build/bazel_java_tools/releases/javac11/v6.0/java_tools_javac11_darwin-v6.0.zip", - "https://github.com/bazelbuild/java_tools/releases/download/javac11-v6.0/java_tools_javac11_darwin-v6.0.zip", - ], -) -``` +For Bazel versions <= 4.0.0 use java_tools releases <= v10 and set the options `--java_toolchain` and/or +`--host_java_toolchain` accordingly. -and set the command line options according to the OS: +All java_tools releases can be found under https://github.com/bazelbuild/java_tools/releases. -``` - --java_toolchain=@remote_java_tools_linux//:toolchain \ - --host_java_toolchain=@remote_java_tools_linux//:toolchain -``` # Releases -The releases can be found under [java_tools/releases](https://github.com/bazelbuild/java_tools/releases) -starting with java_tools javac11 v4.0. +The releases can be found under [java_tools/releases](https://github.com/bazelbuild/java_tools/releases). For previous releases see the issues marked with -[the release label](https://github.com/bazelbuild/java_tools/issues/15). +[the release label](https://github.com/bazelbuild/java_tools/issues?q=label%3Arelease/15). If you're interested in the release process please see [docs/release.md](docs/release.md) - -# Release Schedule - -A new `java_tools` for the javac version used by bazel is released monthly. -The first RC should be cut at least 7 days before the bazel release, around the -25th day of the month. - -See [upcoming scheduled releases](https://github.com/bazelbuild/java_tools/issues?q=is%3Aopen+is%3Aissue+label%3Arelease). diff --git a/docs/release-automated.md b/docs/release-automated.md new file mode 100644 index 0000000..724fdc1 --- /dev/null +++ b/docs/release-automated.md @@ -0,0 +1,109 @@ +**This playbook describes the updated java_tools release process. If you see any errors or issues with automation, please follow the manual release process documented [here](https://github.com/bazelbuild/java_tools/blob/master/docs/release.md).** + +# Release Process + +1. Create a new tracking issue for the release in this repository using the ["release tracker" template](https://github.com/bazelbuild/java_tools/issues/new/choose). + +2. Trigger a new build of the [java_tools binaries pipeline](https://buildkite.com/bazel-trusted/java-tools-binaries-java). Set the message field to "java_tools release [version] [rc]", and leave the commit field as "HEAD" and branch as "master". See [example](https://buildkite.com/bazel-trusted/java-tools-binaries-java/builds/233). + +3. Get the commit hash where the pipeline was run (e.g. `c7d8d1e3f16ac6db37b134358b6cfdb5e3c8f6b0` for v13.1) + +4. Create a new release candidate by triggering a new build of the [java-tools-rc pipeline](https://buildkite.com/bazel-trusted/java-tools-rc). Set the message field to "java_tools release [version] [rc]", and leave the commit field as "HEAD" and branch as "master". Click on "release information" and enter the required details. See [example](https://buildkite.com/bazel-trusted/java-tools-rc/builds/1). + + ``` + Version: 13.1 + RC: 1 + Commit hash: c7d8d1e3f16ac6db37b134358b6cfdb5e3c8f6b0 + Final release: false + ``` + +5. Create a new branch in the [rules_java](https://github.com/bazelbuild/rules_java) repository and name it `java_v[version number]`, e.g. `java_v13.1`. Edit [java/repositories.bzl](https://github.com/bazelbuild/rules_java/blob/master/java/repositories.bzl) by copying the output from step 4 to `_JAVA_TOOLS_CONFIG`. Refer to [this example](https://github.com/bazelbuild/rules_java/commit/8b3d6fd2728610c71be2f6937783a396de139576). + + ```starlark + _JAVA_TOOLS_CONFIG = { + "version": "v13.1", + "release": "false", + "artifacts": { + "java_tools_linux": { + "mirror_url": "https://mirror.bazel.build/bazel_java_tools/release_candidates/java/v13.1/java_tools_linux-v13.1-rc1.zip", + "sha": "d134da9b04c9023fb6e56a5d4bffccee73f7bc9572ddc4e747778dacccd7a5a7" + }, + "java_tools_windows": { + "mirror_url": "https://mirror.bazel.build/bazel_java_tools/release_candidates/java/v13.1/java_tools_windows-v13.1-rc1.zip", + "sha": "c5c70c214a350f12cbf52da8270fa43ba629b795f3dd328028a38f8f0d39c2a1" + }, + "java_tools_darwin_x86_64": { + "mirror_url": "https://mirror.bazel.build/bazel_java_tools/release_candidates/java/v13.1/java_tools_darwin_x86_64-v13.1-rc1.zip", + "sha": "0db40d8505a2b65ef0ed46e4256757807db8162f7acff16225be57c1d5726dbc" + }, + "java_tools_darwin_arm64": { + "mirror_url": "https://mirror.bazel.build/bazel_java_tools/release_candidates/java/v13.1/java_tools_darwin_arm64-v13.1-rc1.zip", + "sha": "dab5bb87ec43e980faea6e1cec14bafb217b8e2f5346f53aa784fd715929a930" + }, + "java_tools": { + "mirror_url": "https://mirror.bazel.build/bazel_java_tools/release_candidates/java/v13.1/java_tools-v13.1-rc1.zip", + "sha": "286bdbbd66e616fc4ed3f90101418729a73baa7e8c23a98ffbef558f74c0ad14" + } + } + } + ``` + +6. Update [workspace_deps.bzl](https://github.com/bazelbuild/bazel/blob/master/workspace_deps.bzl) in the Bazel repository and create a new draft pull request to trigger the CI presubmit. Refer to [this PR](https://github.com/bazelbuild/bazel/pull/20045) (specifically [this commit](https://github.com/bazelbuild/bazel/pull/20045/commits/b0ec360581ee665faf2298641ef4bb6feee12f9d)) + + * Get the commit hash for the changes made in step 5 (e.g. `8b3d6fd2728610c71be2f6937783a396de139576` for [this commit](https://github.com/bazelbuild/rules_java/commit/8b3d6fd2728610c71be2f6937783a396de139576)) + * Download the tar.gz file at `https://github.com/bazelbuild/rules_java/archive/.tar.gz` + * Run `shasum -a 256 ` + * Update the following fields: `archive`, `sha256`, `urls`, `strip_prefix` (to be added) + + Example: + ```starlark + "archive": "8b3d6fd2728610c71be2f6937783a396de139576.tar.gz", + "sha256": "e8a6427d7882215b009c048f996499e89c9e43c13c56234da16a49b154c46546", + "strip_prefix": "rules_java-8b3d6fd2728610c71be2f6937783a396de139576", + "urls": ["https://github.com/bazelbuild/rules_java/archive/8b3d6fd2728610c71be2f6937783a396de139576.tar.gz"],` + ``` + +7. Add archive_override to [MODULE.bazel](https://github.com/bazelbuild/bazel/blob/master/MODULE.bazel) + + * To calculate the `integrity` value of the source archive, trigger the [BCR integrity pipeline](https://buildkite.com/bazel-trusted/bcr-integrity). Set the message field to "java_tools release [version] [rc]", and leave the commit field as "HEAD" and branch as "main". Click on "get archive" and enter the `.tar.gz` (e.g. `8b3d6fd2728610c71be2f6937783a396de139576.tar.gz`). The integrity value will be printed at the end of the "calculate integrity value" step. See [example](https://buildkite.com/bazel-trusted/bcr-integrity/builds/13). + * Alternately, run `cat .tar.gz | openssl dgst -sha256 -binary | base64`. + + * Add archive_override with the `integrity` and commit hash from above. + + Example: + ```starlark + archive_override( + module_name = "rules_java", + urls = ["https://github.com/bazelbuild/rules_java/archive/8b3d6fd2728610c71be2f6937783a396de139576.tar.gz"], + integrity = "sha256-6KZCfXiCIVsAnASPmWSZ6JyeQ8E8ViNNoWpJsVTEZUY=", + strip_prefix = "rules_java-8b3d6fd2728610c71be2f6937783a396de139576", + ) + ``` + +8. 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](https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2818). + +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](https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds?branch=master). 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. + +If the CI finishes successfully: + +9. Create the release artifacts from the release candidate by triggering a new build of the [java-tools-rc pipeline](https://buildkite.com/bazel-trusted/java-tools-rc). Set the message field to "java_tools release [version] [rc]", and leave the commit field as "HEAD" and branch as "master". Click on "release information" and enter the required details. + + ``` + Version: 13.1 + RC: 1 + Commit hash: c7d8d1e3f16ac6db37b134358b6cfdb5e3c8f6b0 + Final release: true + ``` + +10. Create a [java_tools release](https://github.com/bazelbuild/java_tools/releases) on GitHub by triggering the [java-tools-release pipeline](https://buildkite.com/bazel-trusted/java-tools-release). Set the message field to "java_tools release [version] [rc]", and leave the commit field as "HEAD" and branch as "master". Click on "artifacts information" and paste the output from the step above. See [example](https://buildkite.com/bazel-trusted/java-tools-release/builds/2). + +11. Return to the rules_java repository and create a PR to update [java/repositories.bzl](https://github.com/bazelbuild/rules_java/blob/master/java/repositories.bzl) with the latest java_tools versions. After making sure presubmits pass, send the PR for review and assign `@hvadehra`. Refer to [this example](https://github.com/bazelbuild/rules_java/pull/119) (it also includes the 2 updates needed for the next step). + +12. Follow the steps [here](https://github.com/bazelbuild/rules_java/tree/master/distro) to release a new version of rules_java. + +13. 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/pull/18902). + + - https://github.com/bazelbuild/bazel/blob/master/workspace_deps.bzl ([example](https://github.com/bazelbuild/bazel/commit/ef5648ef4e0a48291c8bd5ff02a96ef03d69cf04)) + - https://github.com/bazelbuild/bazel/blob/master/src/MODULE.tools ([example](https://github.com/bazelbuild/bazel/pull/18902/commits/73c8858d5195f072bbb316a3bf1289de1646d91a)) + - https://github.com/bazelbuild/bazel/blob/master/MODULE.bazel ([example](https://github.com/bazelbuild/bazel/pull/18902/commits/5b30bc4f23037f5651063e24c1881328720d6bcb)). Remove the archive_override() method as well. + diff --git a/docs/release.md b/docs/release.md index 3d61851..1662a74 100644 --- a/docs/release.md +++ b/docs/release.md @@ -11,19 +11,24 @@ 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](behind-the-release.md). -1. Create a new tracking issue for the release in this repository and add the -`release` label. See [#7](https://github.com/bazelbuild/java_tools/issues/7) as -an example. -2. Trigger a new build of the [`java_tools binaries pipeline`](https://buildkite.com/bazel-trusted/java-tools-binaries-java). +1. Create a new tracking issue for the release in this repository and add the `release` label. See [#59](https://github.com/bazelbuild/java_tools/issues/59) as an example. +2. Trigger a new build of the [`java_tools binaries pipeline`](https://buildkite.com/bazel-trusted/java-tools-binaries-java). Set the message field to "java_tools release [version] [rc]", and leave the commit field as "HEAD" and branch as "master". See [example](https://buildkite.com/bazel-trusted/java-tools-binaries-java/builds/189). 3. 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. `3.1`) + * `NEW_VERSION` the new version number you’re trying to release (e.g. `11.09`) * `RC` the number of the current release candidate -4. Create a new release candidate by running the command below from the bazel repo: + For example: + ```bash + export COMMIT_HASH=7bd0ab63a8441c3f3d7f495d09ed2bed38762874 + export NEW_VERSION=11.09 + export RC=1 + ``` - ``` +4. Create a new release candidate by running the command below from the [bazel](https://github.com/bazelbuild/bazel) repo: + + ```bash src/create_java_tools_release.sh \ --commit_hash $COMMIT_HASH \ --java_tools_version $NEW_VERSION \ @@ -32,27 +37,170 @@ an example. The script will output the sha256sum of the rc artifacts for linux, darwin and windows. + + Sample output: + ```bash + $ 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 + ``` + +5. Create a new branch in the [rules_java](https://github.com/bazelbuild/rules_java) repository -5. Create a new bazel Pull Request that updates the `java_tools` archives (file -[distdir_deps.bzl](https://github.com/bazelbuild/bazel/blob/master/distdir_deps.bzl)) -with the new release candidates. -The PR triggers the CI presubmit. + * Name the branch `java_v[version number]`, e.g. `java_v11.09` + * Edit [java_tools_repos()](https://github.com/bazelbuild/rules_java/blob/master/java/repositories.bzl#L22-L73) by updating the `sha256` and `urls` fields for `remote_java_tools` with the correct version, rc, sha256sum, and url (see output from step 4) + Example: + ```starlark + 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` and `remote_java_tools_darwin_arm64` + * Refer to [this example](https://github.com/bazelbuild/rules_java/commit/d1196d250c17dfffed52db13c75d4f9b9cd20617) -6. Trigger a new build on Downstream https://buildkite.com/bazel/bazel-at-head-plus-downstream. - Using `pull/PRNUMBER/head` for the branch. +6. Edit [workspace_deps.bzl](https://github.com/bazelbuild/bazel/blob/master/workspace_deps.bzl) in the Bazel repository and create a new pull request. This PR will trigger the CI presubmit. - 1. If the CI finishes successfully: - - create the release artifacts from the - release candidate: + * Get the commit hash for the changes made in step 5 (e.g. `d1196d250c17dfffed52db13c75d4f9b9cd20617` for [this commit](https://github.com/bazelbuild/rules_java/commit/d1196d250c17dfffed52db13c75d4f9b9cd20617)) + * Download the tar.gz file at `https://github.com/bazelbuild/rules_java/archive/.tar.gz` + * Run `shasum -a 256 ` + * Update the following fields (note: add `strip_prefix`) + + Example: + ```starlark + "archive": "d1196d250c17dfffed52db13c75d4f9b9cd20617.tar.gz", + "sha256": "0f65c471b99c79e97dd18a3571d3707b4dbfc31ff8e9bf7083a09aae0adb7b5e", + "strip_prefix": "rules_java-d1196d250c17dfffed52db13c75d4f9b9cd20617", + "urls": ["https://github.com/bazelbuild/rules_java/archive/d1196d250c17dfffed52db13c75d4f9b9cd20617.tar.gz"], ``` - src/create_java_tools_release.sh \ - --java_tools_version $NEW_VERSION \ - --rc $RC --release true + + * Refer to [this PR](https://github.com/bazelbuild/bazel/pull/18902) (specifically [this commit](https://github.com/bazelbuild/bazel/pull/18902/commits/26ea92bfa57c2706c10c82714ff9a3094c6a39ad)) + * Add archive_override to MODULE.bazel + * To calculate the `integrity` value of the source archive, do: + + ```bash + $ 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 above + + Example: + ```starlark + 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", + ) ``` - - update the urls of the `http_archive`s in the upgrade PR and send it for - review. - 2. 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 creating the - next release candidate. This case is highly unlikely because bazel already - tests the `java_tools` built at head. + + * Refer to [this PR](https://github.com/bazelbuild/bazel/pull/18902) (specifically [this commit](https://github.com/bazelbuild/bazel/pull/18902/commits/642c32aa6e07d76654ac4210e7119e84e7bf2f82)) + +7. 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](https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2818). + + 1. 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](https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds?branch=master). + 2. If the CI finishes successfully: + - Create the release artifacts from the release candidate: + ```bash + 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: + ```bash + $ 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](https://github.com/bazelbuild/java_tools/releases) + - 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](https://github.com/bazelbuild/java_tools/releases/tag/java_v11.9) + + - Return to the rules_java repository and create a PR to update [java_tools_repos()](https://github.com/bazelbuild/rules_java/blob/master/java/repositories.bzl#L22-L73) with the latest java_tools versions. After making sure presubmits pass, send the PR for review and assign `@hvadehra`. Refer to [this example](https://github.com/bazelbuild/rules_java/pull/119) (it also includes the 2 updates needed for the next step). + + - Follow the steps [here](https://github.com/bazelbuild/rules_java/tree/master/distro) 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](https://github.com/bazelbuild/bazel-central-registry/pull/774)) + - One time step: Add the `publish-to-bcr` app to your personal fork of `bazelbuild/bazel-central-registry`. Refer to the instructions [here](https://github.com/bazel-contrib/publish-to-bcr/blob/main/README.md). + + - 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/pull/18902). + - https://github.com/bazelbuild/bazel/blob/master/workspace_deps.bzl ([example](https://github.com/bazelbuild/bazel/commit/ef5648ef4e0a48291c8bd5ff02a96ef03d69cf04)) + - https://github.com/bazelbuild/bazel/blob/master/src/MODULE.tools ([example](https://github.com/bazelbuild/bazel/pull/18902/commits/73c8858d5195f072bbb316a3bf1289de1646d91a)) + - https://github.com/bazelbuild/bazel/blob/master/MODULE.bazel# ([example](https://github.com/bazelbuild/bazel/pull/18902/commits/5b30bc4f23037f5651063e24c1881328720d6bcb)). Remove the archive_override() method as well. + + 3. 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. + diff --git a/scripts/release.py b/scripts/release.py new file mode 100644 index 0000000..0ed464c --- /dev/null +++ b/scripts/release.py @@ -0,0 +1,63 @@ +# Copyright 2022 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Script to get release notes + zip files to release java_tools.""" + +import argparse +import wget +import json + +def generate_release_info(platform, artifacts): + return ''' + http_archive( + name = "remote_{platform}", + sha256 = "{sha}", + urls = [ + "{mirror_url}", + "{github_url}" + ] + )'''.format( + platform = platform, + sha = artifacts["sha"], + mirror_url = artifacts["mirror_url"], + github_url = artifacts["github_url"] + ) + +def download_file(mirror_url): + wget.download(mirror_url , '.') + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + '--artifacts', + required=True, + dest='artifacts', + help='Output from create_java_tools_release.sh') + opts = parser.parse_args() + + release_info = json.loads(opts.artifacts) + artifacts = release_info["artifacts"] + + relnotes = "To use this java_tools release, add to your WORKSPACE file the definitions: \n```py" + for platform in artifacts: + relnotes += generate_release_info(platform, artifacts[platform]) + download_file(artifacts[platform]["mirror_url"]) + + relnotes += "\n```\nThis Java tools version was built from http://github.com/bazelbuild/bazel/commit/" + release_info["source_revision"] + with open('relnotes.txt', 'w') as f: + f.write(relnotes) + + +if __name__ == '__main__': + main()