Add --overwrite to the upload script

This commit is contained in:
Cheng Zhao 2017-09-26 10:43:43 +09:00
parent c70508edb1
commit 3545280e1d

View file

@ -51,13 +51,18 @@ def main():
github = GitHub(auth_token()) github = GitHub(auth_token())
releases = github.repos(ELECTRON_REPO).releases.get() releases = github.repos(ELECTRON_REPO).releases.get()
tag_exists = False tag_exists = False
for release in releases: for r in releases:
if not release['draft'] and release['tag_name'] == args.version: if not r['draft'] and r['tag_name'] == args.version:
release = r
tag_exists = True tag_exists = True
break break
release = create_or_get_release_draft(github, releases, args.version, assert tag_exists == args.overwrite, \
tag_exists) 'You have to pass --overwrite to overwrite a published release'
if not args.overwrite:
release = create_or_get_release_draft(github, releases, args.version,
tag_exists)
if args.publish_release: if args.publish_release:
# Upload the Node SHASUMS*.txt. # Upload the Node SHASUMS*.txt.
@ -112,6 +117,9 @@ def parse_args():
parser = argparse.ArgumentParser(description='upload distribution file') parser = argparse.ArgumentParser(description='upload distribution file')
parser.add_argument('-v', '--version', help='Specify the version', parser.add_argument('-v', '--version', help='Specify the version',
default=ELECTRON_VERSION) default=ELECTRON_VERSION)
parser.add_argument('-o', '--overwrite',
help='Overwrite a published release',
action='store_true')
parser.add_argument('-p', '--publish-release', parser.add_argument('-p', '--publish-release',
help='Publish the release', help='Publish the release',
action='store_true') action='store_true')