]>
git.proxmox.com Git - cargo.git/blob - publish.py
3 # This script is used to publish Cargo to crates.io.
10 from urllib
.error
import HTTPError
14 'crates/cargo-platform',
21 def already_published(name
, version
):
23 urllib
.request
.urlopen('https://crates.io/api/v1/crates/%s/%s/download' % (name
, version
))
24 except HTTPError
as e
:
31 def maybe_publish(path
):
32 content
= open(os
.path
.join(path
, 'Cargo.toml')).read()
33 name
= re
.search('^name = "([^"]+)"', content
, re
.M
).group(1)
34 version
= re
.search('^version = "([^"]+)"', content
, re
.M
).group(1)
35 if already_published(name
, version
):
36 print('%s %s is already published, skipping' % (name
, version
))
38 subprocess
.check_call(['cargo', 'publish', '--no-verify'], cwd
=path
)
43 print('Starting publish...')
44 for i
, path
in enumerate(TO_PUBLISH
):
45 if maybe_publish(path
):
46 if i
< len(TO_PUBLISH
)-1:
47 # Sleep to allow the index to update. This should probably
48 # check that the index is updated, or use a retry loop
51 print('Publish complete!')
54 if __name__
== '__main__':