-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish
executable file
·65 lines (52 loc) · 2.58 KB
/
publish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
import subprocess
import fileinput
import sys
import urllib.request
from pathlib import Path
from helpers import run_cmd, run_cmd_capture, mill_sc_version, \
get_new_version, replace_version_rc, replace_version_libs
if __name__ == "__main__":
cwd = Path.cwd()
rc_repo = cwd / "rocket-chip"
assert rc_repo.exists()
assert rc_repo.is_dir()
# if a specific rocket-chip hash is requested, check it out
if len(sys.argv) == 2 and sys.argv[1]:
rc_hash = sys.argv[1]
run_cmd(f"git checkout {rc_hash}", cwd=rc_repo)
else:
# Master is the branch used for publishing, dev might break frequently
run_cmd(f"git checkout master", cwd=rc_repo)
# Patch the rocket-chip build.sc with the versioning hacks and change org to edu.berkeley.cs
run_cmd("git apply rocket-chip.patch --directory rocket-chip", cwd=cwd)
# clone rocket submodules
run_cmd("git submodule update --init dependencies/cde dependencies/hardfloat dependencies/diplomacy dependencies/chisel", cwd=rc_repo)
rc_510_version = run_cmd_capture("mill show rocketchip[5.1.0].publishVersion", cwd=rc_repo)[1:-1]
print(rc_510_version)
# check that this rocket version isn't already published to sonatype snapshots
def check_if_published(version: str, chiselVersion: str) -> bool:
try:
url = f"https://oss.sonatype.org/content/repositories/snapshots/edu/berkeley/cs/rocketchip-{chiselVersion}_2.13/{version}/"
print(f"Checking {url}")
page = urllib.request.urlopen(url).read()
return True
except urllib.error.HTTPError as e:
# Return code error (e.g. 404, 501, ...)
assert e.code == 404, f"Sonatype URL GET returned something other than 200/404 {e.url} -> {e.code}"
return False
except urllib.error.URLError as e:
# Not an HTTP-specific error (e.g. connection refused)
print('URLError: {}'.format(e.reason))
sys.exit(1)
else:
sys.exit(2)
if check_if_published(rc_510_version, "5.1.0"):
print(f"Version {rc_510_version} is already published - exiting")
sys.exit(0)
run_cmd("echo $MILL_GPG_SECRET_BASE64 | base64 --decode > gpg_key", cwd=cwd)
run_cmd("gpg --import --no-tty --batch --yes gpg_key", cwd=cwd)
run_cmd("rm gpg_key", cwd=cwd)
for project in ["rocketchip[5.1.0]", "hardfloat[5.1.0]", "diplomacy[5.1.0]", "cde", "macros"]:
run_cmd(f"mill mill.scalalib.PublishModule/publishAll --publishArtifacts {project}.publishArtifacts", cwd=rc_repo)
sys.exit(0)