-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathconfig.py
101 lines (86 loc) · 2.79 KB
/
config.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import os
import re
import json
# ------------------------------------------------------------- Static Content
# project
project = {
'name': 'Django Translations',
'github': 'django-translations',
'dist': 'django-translations',
'desc': 'Django model translation for perfectionists with deadlines.',
'logo': 'translation.svg',
}
# author
author = {
'name': 'Behzad B. Mokhtari',
'email': 'bbmokhtari.global@gmail.com',
'github': 'bbmokhtari',
}
# github
github = {
'user': author['github'],
'repo': project['github'],
}
# urls
urls = {
'source': 'https://github.com/{user}/{repo}'.format(**github),
'tracker': 'https://github.com/{user}/{repo}/issues'.format(**github),
'documentation': 'https://{user}.github.io/{repo}'.format(**github),
'funding': 'https://{user}.github.io/{repo}/donation.html'.format(
**github),
}
# search optimization
keywords = [
'django',
'model',
'translation',
'internationalization',
'localization',
]
# ------------------------------------------------------------ Dynamic Content
github_ref = os.environ.get('GITHUB_REF', '')
tag = github_ref.replace("refs/tags/", "")
release = {
# e.g. `1.0.0rc2`
'name': tag,
'version': '', # e.g. `1.0.0`
'status': '', # e.g. `rc`
'classifier': '', # e.g. `5 - Production/Stable`
}
if release['name']:
# all releases must follow this convention
pattern = re.compile(
r'^' +
r'(?P<version>\d+\.\d+\.\d+)' +
r'(?:(?P<status>a|b|rc|\.dev|\.post)(?P<status_no>\d+))?' +
r'$'
)
components = pattern.match(release['name'])
if components:
components = components.groupdict()
release['version'] = components['version']
release['status'] = components['status']
if release['status'] == '.dev':
release['classifier'] = '2 - Pre-Alpha'
elif release['status'] == 'a':
release['classifier'] = '3 - Alpha'
elif release['status'] == 'b':
release['classifier'] = '4 - Beta'
elif release['status'] == 'rc':
release['classifier'] = '5 - Production/Stable'
elif release['status'] is None or release['status'] == '.post':
release['classifier'] = '6 - Mature'
else:
raise Exception('Release must have a development status.')
# --------------------------------------------------------------------- Output
# Export to config.json
if __name__ == '__main__':
with open('config.json', 'w') as fh:
json.dump({
'project': project,
'author': author,
'github': github,
'urls': urls,
'keywords': keywords,
'release': release,
}, fh)