forked from talmolab/sleap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.py
76 lines (56 loc) · 2.18 KB
/
release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""
Script to create tagged release of HEAD on develop for "nightly" builds.
The tag will be the version number in
https://github.com/murthylab/sleap/blob/develop/sleap/version.py
so you should bump the version number and push that to develop
before running this script. The version number should be
X.Y.ZaN
so that pypi knows this is a pre-release and shouldn't be installed
unless explicitly requested.
The script will prompt you for a GitHub access token.
When a tagged release is pushed to GitHub, this triggers AppVeyor
to build and upload the conda and pypi packages. For tags on develop,
the package is uploaded to anaconda with the "dev" label, so it won't
be installed by default unless the user explicitly requests
sleap/label/dev
as the channel (instead of "sleap").
"""
import datetime
import re
from os import path
import github
from getpass import getpass
def main(publish, draft):
token = ""
while not token:
token = getpass("Access token for GitHub:")
try:
g = github.Github(token)
repo = g.get_repo("murthylab/sleap")
except github.BadCredentialsException as e:
print("Unable to connect to the repo with those credentials.")
return
dev_branch = repo.get_branch("develop")
# Get version from sleap/version.py in develop branch on github
version_file = repo.get_contents(
"sleap/version.py", ref=dev_branch.commit.sha
).decoded_content.decode()
sleap_version = re.search("\d.+(?=['\"])", version_file).group(0)
print(f"Releasing {dev_branch.commit.sha} (develop HEAD) as {sleap_version}...")
if publish:
x = repo.create_git_tag_and_release(
tag=f"v{sleap_version}",
tag_message="",
release_name=f"SLEAP v{sleap_version}",
release_message=f"Automated release of {sleap_version} on {datetime.date.today().isoformat()}",
object=dev_branch.commit.sha,
type="tree",
draft=draft,
prerelease=True,
)
print("Tag/release created on GitHub.")
print(x)
else:
print("Just testing connection, no tag/release pushed.")
if __name__ == "__main__":
main(publish=True, draft=False)