-
Notifications
You must be signed in to change notification settings - Fork 9
/
new-release
executable file
·44 lines (37 loc) · 1.84 KB
/
new-release
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
#!/usr/bin/env python3
if __name__ == "__main__":
import argparse
import os
import re
import sys
from datetime import date
parser = argparse.ArgumentParser(description='Publish release.')
parser.add_argument('version', help='Release version')
parser.add_argument('-i', '--ignore-missing', action='store_true', help='Ignore missing files')
args = parser.parse_args()
pats = dict(linux32=re.compile(r"bnfc-{}-linux(-i386|32)\.(tar\.gz|tgz|gz)".format(args.version), re.I),
linux64=re.compile(r"bnfc-{}-linux(-x86_64|64)\.(tar\.gz|tgz|gz|binary)".format(args.version), re.I),
mac=re.compile(r"bnfc-{}-mac\.pkg".format(args.version), re.I),
win=re.compile(r"bnfc-{}-win\.exe".format(args.version), re.I),
source=re.compile(r"bnfc-{}\.(tar\.gz|tgz)".format(args.version), re.I))
found = dict()
for file in os.listdir('download'):
for k in pats:
if pats[k].match(file):
found[k] = file
if args.ignore_missing is not True and len(set(pats) - set(found)) > 0:
print("Missing:", *set(pats) - set(found))
sys.exit(1)
post = "_posts/releases/{}-v{}.md".format(date.today().isoformat(), args.version)
with open(post, 'w') as f:
print("---", file=f)
print("layout: post", file=f)
print("version:", args.version, file=f)
print("categories:", "- releases", sep="\n", file=f)
print("packages:", file=f)
for k in sorted(found):
print(" %s:" % k, found[k], file=f)
print("---", file=f)
print('Now open "{}" and add the changelog bulletpoints'.format(post))
print('Changelog can be found at: https://github.com/BNFC/bnfc/blob/master/source/changelog')
print('Manually change the filename if they don\'t match the release date')