Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / utils / release / github-upload-release.py
blobf1ad78120a0aa6463c2f540d4efaae4988797718
1 #!/usr/bin/env python3
2 # ===-- github-upload-release.py ------------------------------------------===#
4 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # See https://llvm.org/LICENSE.txt for license information.
6 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 # ===------------------------------------------------------------------------===#
10 # Create and manage releases in the llvm github project.
12 # This script requires python3 and the PyGithub module.
14 # Example Usage:
16 # You will need to obtain a personal access token for your github account in
17 # order to use this script. Instructions for doing this can be found here:
18 # https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
20 # Create a new release from an existing tag:
21 # ./github-upload-release.py --token $github_token --release 8.0.1-rc4 create
23 # Upload files for a release
24 # ./github-upload-release.py --token $github_token --release 8.0.1-rc4 upload --files llvm-8.0.1rc4.src.tar.xz
26 # You can upload as many files as you want at a time and use wildcards e.g.
27 # ./github-upload-release.py --token $github_token --release 8.0.1-rc4 upload --files *.src.*
28 # ===------------------------------------------------------------------------===#
31 import argparse
32 import github
33 from textwrap import dedent
35 def create_release(repo, release, tag=None, name=None, message=None):
36 if not tag:
37 tag = "llvmorg-{}".format(release)
39 if not name:
40 name = "LLVM {}".format(release)
42 if not message:
43 message = dedent(
44 """\
45 LLVM {} Release
47 # A note on binaries
49 Volunteers make binaries for the LLVM project, which will be uploaded
50 when they have had time to test and build these binaries. They might
51 not be available directly or not at all for each release. We suggest
52 you use the binaries from your distribution or build your own if you
53 rely on a specific platform or configuration."""
54 ).format(release)
56 prerelease = True if "rc" in release else False
58 repo.create_git_release(tag=tag, name=name, message=message, prerelease=prerelease)
61 def upload_files(repo, release, files):
62 release = repo.get_release("llvmorg-{}".format(release))
63 for f in files:
64 print("Uploading {}".format(f))
65 release.upload_asset(f)
66 print("Done")
69 parser = argparse.ArgumentParser()
70 parser.add_argument("command", type=str, choices=["create", "upload"])
72 # All args
73 parser.add_argument("--token", type=str)
74 parser.add_argument("--release", type=str)
76 # Upload args
77 parser.add_argument("--files", nargs="+", type=str)
80 args = parser.parse_args()
82 github = github.Github(args.token)
83 llvm_repo = github.get_organization("llvm").get_repo("llvm-project")
85 if args.command == "create":
86 create_release(llvm_repo, args.release)
87 if args.command == "upload":
88 upload_files(llvm_repo, args.release, args.files)