Skip to content

Commit

Permalink
Updates after modifying the output of create_java_tools_release.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
keertk committed Oct 2, 2023
1 parent d9d12b7 commit 5ceed83
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,20 @@
import wget
import json

def generate_release_info(platform, version, path, sha):
mirror_url = "https://mirror.bazel.build/bazel_java_tools/" + path
github_url = "https://github.com/bazelbuild/java_tools/releases/download/java_" + version + "/" + platform + "-" + version + ".zip"
relnote = ("\n" +
def generate_release_info(platform, artifacts):
return ("\n" +
"http_archive(\n"
" name = \"remote_" + platform + "\",\n" +
" sha = \"" + sha + "\",\n" +
" sha = \"" + artifacts["sha"] + "\",\n" +
" urls = [\n" +
" \"" + mirror_url + "\",\n" +
" \"" + github_url + "\",\n" +
" \"" + artifacts["mirror_url"] + "\",\n" +
" \"" + artifacts["github_url"] + "\",\n" +
" ],\n" +
")")
return relnote, mirror_url

def download_file(mirror_url):
wget.download(mirror_url , '.')

def get_version(artifacts):
path = artifacts["java_tools"]["path"]
version = path[path.find("/v"):path.find("/java_")][1:]
return version

def main():
parser = argparse.ArgumentParser()
parser.add_argument(
Expand All @@ -49,16 +41,12 @@ def main():
help='Output from create_java_tools_release.sh')
opts = parser.parse_args()

artifacts = json.loads(opts.artifacts)
version = get_version(artifacts)
artifacts = json.loads(opts.artifacts)["artifacts"]

relnotes = "To use this java_tools release, add to your WORKSPACE file the definitions: \n```py"
for platform in artifacts:
path = artifacts[platform]["path"]
sha = artifacts[platform]["sha"]
relnote, mirror_url = generate_release_info(platform, version, path, sha)
relnotes += relnote
download_file(mirror_url)
relnotes += generate_release_info(platform, artifacts[platform])
download_file(artifacts[platform]["mirror_url"])

relnotes += "```"
with open('relnotes.txt', 'w') as f:
Expand Down

0 comments on commit 5ceed83

Please sign in to comment.