Skip to content

Commit 9872d04

Browse files
committed
[GitHub] Make release aduit more strict for LLVM 19 and beyond
Since 19, only release managers and the bot account can upload assets. Third party builds are posted on the Discourse thread instead.
1 parent e596387 commit 9872d04

File tree

1 file changed

+58
-25
lines changed

1 file changed

+58
-25
lines changed

.github/workflows/release-asset-audit.py

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import github
2+
import re
23
import sys
34

45
_SPECIAL_CASE_BINARIES = {
@@ -16,38 +17,70 @@ def _is_valid(uploader_name, valid_uploaders, asset_name):
1617
return False
1718

1819

19-
def main():
20-
token = sys.argv[1]
21-
22-
gh = github.Github(login_or_token=token)
23-
repo = gh.get_repo("llvm/llvm-project")
20+
def _get_uploaders(release_version):
21+
# Until llvm 18, assets were uploaded by community members, the release managers
22+
# and the GitHub Actions bot.
23+
if release_version <= 18:
24+
return set(
25+
[
26+
"DimitryAndric",
27+
"stefanp-ibm",
28+
"lei137",
29+
"omjavaid",
30+
"nicolerabjohn",
31+
"amy-kwan",
32+
"mandlebug",
33+
"zmodem",
34+
"androm3da",
35+
"tru",
36+
"rorth",
37+
"quinnlp",
38+
"kamaub",
39+
"abrisco",
40+
"jakeegan",
41+
"maryammo",
42+
"tstellar",
43+
"github-actions[bot]",
44+
]
45+
)
2446

25-
uploaders = set(
47+
# llvm 19 and beyond, only the release managers and the GitHub Actions bot
48+
# should be uploading assets.
49+
return set(
2650
[
27-
"DimitryAndric",
28-
"stefanp-ibm",
29-
"lei137",
30-
"omjavaid",
31-
"nicolerabjohn",
32-
"amy-kwan",
33-
"mandlebug",
34-
"zmodem",
35-
"androm3da",
3651
"tru",
37-
"rovka",
38-
"rorth",
39-
"quinnlp",
40-
"kamaub",
41-
"abrisco",
42-
"jakeegan",
43-
"maryammo",
4452
"tstellar",
4553
"github-actions[bot]",
4654
]
4755
)
4856

57+
58+
def _get_major_release_version(release_title):
59+
# All release titles are of the form "LLVM X.Y.Z(-rcN)".
60+
match = re.match("LLVM ([0-9]+)\.")
61+
if match is None:
62+
_write_comment_and_exit_with_error(
63+
f'Could not parse release version from release title "{release_title}".'
64+
)
65+
else:
66+
return int(match.groups(0))
67+
68+
69+
def _write_comment_and_exit_with_error(comment):
70+
with open("comment", "w") as file:
71+
file.write(comment)
72+
sys.exit(1)
73+
74+
75+
def main():
76+
token = sys.argv[1]
77+
78+
gh = github.Github(login_or_token=token)
79+
repo = gh.get_repo("llvm/llvm-project")
80+
4981
for release in repo.get_releases():
5082
print("Release:", release.title)
83+
uploaders = _get_uploaders(release.title)
5184
for asset in release.get_assets():
5285
created_at = asset.created_at
5386
updated_at = (
@@ -57,9 +90,9 @@ def main():
5790
f"{asset.name} : {asset.uploader.login} [{created_at} {updated_at}] ( {asset.download_count} )"
5891
)
5992
if not _is_valid(asset.uploader.login, uploaders, asset.name):
60-
with open('comment', 'w') as file:
61-
file.write(f'@{asset.uploader.login} is not a valid uploader.')
62-
sys.exit(1)
93+
_write_comment_and_exit_with_error(
94+
f"@{asset.uploader.login} is not a valid uploader."
95+
)
6396

6497

6598
if __name__ == "__main__":

0 commit comments

Comments
 (0)