Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 296db90

Browse files
committed
Add github-release.py script
Summary: This script can be used for uploading relases sources and binaries to github. Reviewers: hans Reviewed By: hans Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64841 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@366977 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5fb8cf0 commit 296db90

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env python3
2+
# ===-- github-release.py -------------------------------------------------===#
3+
#
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
7+
#
8+
#===------------------------------------------------------------------------===#
9+
#
10+
# Create and manage releases in the llvm github project.
11+
#
12+
# This script requires python3 and the PyGithub module.
13+
#
14+
# Example Usage:
15+
#
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
19+
#
20+
# Create a new release from an existing tag:
21+
# ./github-release.py --token $github_token --release 8.0.1-rc4 create
22+
#
23+
# Upload files for a release
24+
# ./github-release.py --token $github_token --release 8.0.1-rc4 upload --files llvm-8.0.1rc4.src.tar.xz
25+
#
26+
# You can upload as many files as you want at a time and use wildcards e.g.
27+
# ./github-release.py --token $github_token --release 8.0.1-rc4 upload --files *.src.*
28+
#===------------------------------------------------------------------------===#
29+
30+
31+
import argparse
32+
import github
33+
34+
def create_release(repo, release, tag = None, name = None, message = None):
35+
if not tag:
36+
tag = 'llvmorg-{}'.format(release)
37+
38+
if not name:
39+
name = 'LLVM {}'.format(release)
40+
41+
if not message:
42+
message = 'LLVM {} Release'.format(release)
43+
44+
prerelease = True if "rc" in release else False
45+
46+
repo.create_git_release(tag = tag, name = name, message = message,
47+
prerelease = prerelease)
48+
49+
def upload_files(repo, release, files):
50+
release = repo.get_release('llvmorg-{}'.format(release))
51+
for f in files:
52+
print('Uploading {}'.format(f))
53+
release.upload_asset(f)
54+
print("Done")
55+
56+
57+
58+
parser = argparse.ArgumentParser()
59+
parser.add_argument('command', type=str, choices=['create', 'upload'])
60+
61+
# All args
62+
parser.add_argument('--token', type=str)
63+
parser.add_argument('--release', type=str)
64+
65+
# Upload args
66+
parser.add_argument('--files', nargs='+', type=str)
67+
68+
69+
args = parser.parse_args()
70+
71+
github = github.Github(args.token)
72+
llvm_repo = github.get_organization('llvm').get_repo('llvm-project')
73+
74+
if args.command == 'create':
75+
create_release(llvm_repo, args.release)
76+
if args.command == 'upload':
77+
upload_files(llvm_repo, args.release, args.files)

0 commit comments

Comments
 (0)