forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_release.py
More file actions
executable file
·75 lines (53 loc) · 2.47 KB
/
create_release.py
File metadata and controls
executable file
·75 lines (53 loc) · 2.47 KB
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
#!/usr/bin/env python3
# Copyright 2022 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.
from datetime import datetime
import os
import subprocess
import sys
script_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(os.path.dirname(script_dir))
sys.path.append(root_dir)
from tools import shared, utils
def main():
if subprocess.check_output(['git', 'status', '-uno', '--porcelain'], cwd=root_dir).strip():
print('tree is not clean')
return 1
shared.set_version_globals()
release_version = [shared.EMSCRIPTEN_VERSION_MAJOR, shared.EMSCRIPTEN_VERSION_MINOR,
shared.EMSCRIPTEN_VERSION_TINY]
new_dev_version = list(release_version)
new_dev_version[2] += 1
release_version = '.'.join(str(v) for v in release_version)
new_dev_version = '.'.join(str(v) for v in new_dev_version)
print('Creating new release: %s' % release_version)
version_file = os.path.join(root_dir, 'emscripten-version.txt')
changelog_file = os.path.join(root_dir, 'ChangeLog.md')
old_content = utils.read_file(version_file)
utils.write_file(version_file, old_content.replace(release_version, new_dev_version))
changelog = utils.read_file(changelog_file)
marker = f'{release_version} (in development)'
pos = changelog.find(marker)
assert pos != -1
pos += 2 * len(marker) + 1
# Add new entry
today = datetime.now().strftime('%m/%d/%y')
new_entry = f'{release_version} - {today}'
new_entry = '\n\n' + new_entry + '\n' + ('-' * len(new_entry))
changelog = changelog[:pos] + new_entry + changelog[pos:]
# Update the "in development" entry
changelog = changelog.replace(f'{release_version} (in development)', f'{new_dev_version} (in development)')
utils.write_file(changelog_file, changelog)
branch_name = 'version_' + release_version
# Create a new git branch
subprocess.check_call(['git', 'checkout', '-b', branch_name], cwd=root_dir)
# Create auto-generated changes to the new git branch
subprocess.check_call(['git', 'add', '-u', '.'], cwd=root_dir)
subprocess.check_call(['git', 'commit', '-m', f'Mark {release_version} as released'], cwd=root_dir)
print('New relase created in branch: `%s`' % branch_name)
# TODO(sbc): Maybe create the tag too, and even push both to `origin`?
return 0
if __name__ == '__main__':
sys.exit(main())