Skip to content

Commit

Permalink
Auto merge of #13616 - ehuss:beta-fix-cdn-publish, r=weihanglo
Browse files Browse the repository at this point in the history
[beta 1.78] Fix publish script due to crates.io CDN change

This is a beta backport of #13614 to fix publishing in the next release.
  • Loading branch information
bors committed Mar 21, 2024
2 parents 2fe739f + 54a60d0 commit fd4fd37
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@


def already_published(name, version):
url = f'https://static.crates.io/crates/{name}/{version}/download'
try:
urllib.request.urlopen('https://crates.io/api/v1/crates/%s/%s/download' % (name, version))
urllib.request.urlopen(url)
except HTTPError as e:
if e.code == 404:
# 403 and 404 are common responses to assume it is not published
if 400 <= e.code < 500:
return False
print(f'error: failed to check if {name} {version} is already published')
print(f' HTTP response error code {e.code} checking {url}')
raise
return True

Expand Down

0 comments on commit fd4fd37

Please sign in to comment.