Skip to content

Commit a0df0f3

Browse files
committed
Add stub of release Python rewrite (WIP)
1 parent 1c9a20c commit a0df0f3

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

release.py

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env python
2+
#
3+
# This is an INCOMPLETE, work-in-progress rewrite of the "release" shell script in Python.
4+
# The motivation for this rewrite is that it is actually much easier to write portable
5+
# Python code than it is to write portable shell scripts. Moreover, in Python a lot of
6+
# other things become easier, e.g. parsing the JSON output returned by GitHub requests.
7+
#
8+
# On the downside, invoking external tools is a bit more annoying...#
9+
#
10+
# This script should only use Python libraries that are shipped with Python.
11+
# It should also stay compatible with all Python versions >= 2.7, including Python 3.
12+
#
13+
14+
import sys
15+
16+
def notice(msg):
17+
print("\033[32m" + msg + "\033[0m")
18+
19+
def warning(msg):
20+
print("\033[33m" + msg + "\033[0m")
21+
22+
def error(msg):
23+
print("\033[31m" + msg + "\033[0m")
24+
exit(1)
25+
26+
if sys.version_info < (2,7):
27+
error("Python 2.7 or newer is required")
28+
29+
# load modules after version check
30+
import json
31+
import argparse
32+
33+
34+
35+
36+
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
37+
description="""A tool for making releases of GAP packages on GitHub.
38+
39+
Run this from within a git clone of your package repository, checked out
40+
at the revision you want to release. This tool extracts relevant data
41+
from the PackageInfo.g file, and performs the releases process.""",
42+
epilog="""Notes:
43+
* The package name and version, the list of archive formats, and the GitHub repository
44+
are extracted from PackageInfo.g.
45+
* To learn how to create a GitHub access token, please consult
46+
https://help.github.com/articles/creating-an-access-token-for-command-line-use/
47+
* Without the --push option, all steps are performed, except for the final push
48+
of the gh-pages changes. These changes are what make the release visible
49+
to the GAP package distribution system.
50+
* Please consult the README for more information.
51+
""")
52+
53+
parser.add_argument('-p', '--push', action='store_true',
54+
help='also peform the final push, completing the release')
55+
parser.add_argument('-f', '--force', action='store_true',
56+
help='if a release with the same name already exists: overwrite it')
57+
58+
group = parser.add_argument_group('Paths')
59+
60+
group.add_argument('--srcdir', type=str,
61+
help='directory containing PackageInfo.g (default: current directory)')
62+
group.add_argument('--tmpdir', type=str,
63+
help='path to the source directory (default: tmp subdirectory of src)')
64+
group.add_argument('--webdir', type=str,
65+
help='path to the web directory (default: gh-pages subdirectory of src)')
66+
67+
group = parser.add_argument_group('Repository access')
68+
69+
group.add_argument('--token', type=str,
70+
help='GitHub access token')
71+
# group.add_argument('-t', '--tag', type=str,
72+
# help='git tag for the release (default: vVERSION, e.g. v1.2.3)')
73+
# group.add_argument('-r', '--repository', type=str,
74+
# help='set GitHub repository (as `USERNAME/PKGNAME`)')
75+
group.add_argument('--remote', type=str, default="origin",
76+
help='git remote to which tags are pushed (default: origin)')
77+
78+
79+
80+
#parser.add_argument('--version', action='version', version='%(prog)s 2.0')
81+
82+
83+
args = parser.parse_args()
84+
print args
85+
86+
87+
88+
89+
90+
#obj=json.load(sys.stdin);
91+

0 commit comments

Comments
 (0)