Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit a35842c

Browse files
authored
Fix the release script not publishing binary wheels. (#13850)
1 parent 2b522cc commit a35842c

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

changelog.d/13850.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix the release script not publishing binary wheels.

scripts-dev/release.py

+34-11
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,12 @@ def _publish(gh_token: str) -> None:
427427

428428

429429
@cli.command()
430-
def upload() -> None:
431-
_upload()
430+
@click.option("--gh-token", envvar=["GH_TOKEN", "GITHUB_TOKEN"], required=False)
431+
def upload(gh_token: Optional[str]) -> None:
432+
_upload(gh_token)
432433

433434

434-
def _upload() -> None:
435+
def _upload(gh_token: Optional[str]) -> None:
435436
"""Upload release to pypi."""
436437

437438
current_version = get_package_version()
@@ -444,18 +445,40 @@ def _upload() -> None:
444445
click.echo("Tag {tag_name} (tag.commit) is not currently checked out!")
445446
click.get_current_context().abort()
446447

447-
pypi_asset_names = [
448-
f"matrix_synapse-{current_version}-py3-none-any.whl",
449-
f"matrix-synapse-{current_version}.tar.gz",
450-
]
448+
# Query all the assets corresponding to this release.
449+
gh = Github(gh_token)
450+
gh_repo = gh.get_repo("matrix-org/synapse")
451+
gh_release = gh_repo.get_release(tag_name)
452+
453+
all_assets = set(gh_release.get_assets())
454+
455+
# Only accept the wheels and sdist.
456+
# Notably: we don't care about debs.tar.xz.
457+
asset_names_and_urls = sorted(
458+
(asset.name, asset.browser_download_url)
459+
for asset in all_assets
460+
if asset.name.endswith((".whl", ".tar.gz"))
461+
)
462+
463+
# Print out what we've determined.
464+
print("Found relevant assets:")
465+
for asset_name, _ in asset_names_and_urls:
466+
print(f" - {asset_name}")
467+
468+
ignored_asset_names = sorted(
469+
{asset.name for asset in all_assets}
470+
- {asset_name for asset_name, _ in asset_names_and_urls}
471+
)
472+
print("\nIgnoring irrelevant assets:")
473+
for asset_name in ignored_asset_names:
474+
print(f" - {asset_name}")
451475

452476
with TemporaryDirectory(prefix=f"synapse_upload_{tag_name}_") as tmpdir:
453-
for name in pypi_asset_names:
477+
for name, asset_download_url in asset_names_and_urls:
454478
filename = path.join(tmpdir, name)
455-
url = f"https://github.com/matrix-org/synapse/releases/download/{tag_name}/{name}"
456479

457480
click.echo(f"Downloading {name} into {filename}")
458-
urllib.request.urlretrieve(url, filename=filename)
481+
urllib.request.urlretrieve(asset_download_url, filename=filename)
459482

460483
if click.confirm("Upload to PyPI?", default=True):
461484
subprocess.run("twine upload *", shell=True, cwd=tmpdir)
@@ -672,7 +695,7 @@ def full(gh_token: str) -> None:
672695
_publish(gh_token)
673696

674697
click.echo("\n*** upload ***")
675-
_upload()
698+
_upload(gh_token)
676699

677700
click.echo("\n*** merge back ***")
678701
_merge_back()

0 commit comments

Comments
 (0)