1616from tools import utils
1717
1818
19- def main (argv ):
20- if subprocess .check_output (['git' , 'status' , '-uno' , '--porcelain' ], cwd = root_dir ).strip ():
21- print ('tree is not clean' )
22- return 1
23-
24- is_github_runner = len (argv ) > 1 and argv [1 ] == '--action'
25-
26- utils .set_version_globals ()
27-
28- release_version = [utils .EMSCRIPTEN_VERSION_MAJOR , utils .EMSCRIPTEN_VERSION_MINOR ,
29- utils .EMSCRIPTEN_VERSION_TINY ]
30- new_dev_version = list (release_version )
31- new_dev_version [2 ] += 1
32-
33- release_version = '.' .join (str (v ) for v in release_version )
34- new_dev_version = '.' .join (str (v ) for v in new_dev_version )
35-
36- print ('Creating new release: %s' % release_version )
37-
19+ def update_version_txt (release_version , new_version ):
3820 version_file = os .path .join (root_dir , 'emscripten-version.txt' )
39- changelog_file = os .path .join (root_dir , 'ChangeLog.md' )
40-
4121 old_content = utils .read_file (version_file )
42- utils .write_file (version_file , old_content .replace (release_version , new_dev_version ))
22+ utils .write_file (version_file , old_content .replace (release_version , new_version ))
4323
24+
25+ def update_changelog (release_version , new_version ):
26+ changelog_file = os .path .join (root_dir , 'ChangeLog.md' )
4427 changelog = utils .read_file (changelog_file )
4528 marker = f'{ release_version } (in development)'
4629 pos = changelog .find (marker )
@@ -54,28 +37,56 @@ def main(argv):
5437 changelog = changelog [:pos ] + new_entry + changelog [pos :]
5538
5639 # Update the "in development" entry
57- changelog = changelog .replace (f'{ release_version } (in development)' , f'{ new_dev_version } (in development)' )
40+ changelog = changelog .replace (f'{ release_version } (in development)' , f'{ new_version } (in development)' )
5841
5942 utils .write_file (changelog_file , changelog )
6043
44+
45+ def create_git_branch (release_version ):
6146 branch_name = 'version_' + release_version
6247
63- if is_github_runner : # For GitHub Actions workflows
64- with open (os .environ ['GITHUB_ENV' ], 'a' ) as f :
65- f .write (f'RELEASE_VERSION={ release_version } ' )
66- else : # Local use
67- # Create a new git branch
68- subprocess .check_call (['git' , 'checkout' , '-b' , branch_name , 'upstream/main' ], cwd = root_dir )
48+ # Create a new git branch
49+ subprocess .check_call (['git' , 'checkout' , '-b' , branch_name , 'upstream/main' ], cwd = root_dir )
6950
70- # Create auto-generated changes to the new git branch
71- subprocess .check_call (['git' , 'add' , '-u' , '.' ], cwd = root_dir )
72- subprocess .check_call (['git' , 'commit' , '-m' , f'Mark { release_version } as released' ], cwd = root_dir )
73- print ('New release created in branch: `%s`' % branch_name )
51+ # Create auto-generated changes to the new git branch
52+ subprocess .check_call (['git' , 'add' , '-u' , '.' ], cwd = root_dir )
53+ subprocess .check_call (['git' , 'commit' , '-m' , f'Mark { release_version } as released' ], cwd = root_dir )
54+ print ('New release created in branch: `%s`' % branch_name )
7455
56+ if '-n' not in sys .argv :
7557 # Push new branch to upstream
7658 subprocess .check_call (['git' , 'push' , 'upstream' , branch_name ], cwd = root_dir )
7759
78- # TODO(sbc): Maybe create the tag too
60+
61+ def main (argv ):
62+ if subprocess .check_output (['git' , 'status' , '-uno' , '--porcelain' ], cwd = root_dir ).strip ():
63+ print ('tree is not clean' )
64+ return 1
65+
66+ is_github_runner = len (argv ) > 1 and argv [1 ] == '--action'
67+
68+ utils .set_version_globals ()
69+
70+ release_version = [utils .EMSCRIPTEN_VERSION_MAJOR , utils .EMSCRIPTEN_VERSION_MINOR ,
71+ utils .EMSCRIPTEN_VERSION_TINY ]
72+ new_dev_version = list (release_version )
73+ new_dev_version [2 ] += 1
74+
75+ release_version = '.' .join (str (v ) for v in release_version )
76+ new_dev_version = '.' .join (str (v ) for v in new_dev_version )
77+
78+ update_version_txt (release_version , new_dev_version )
79+ update_changelog (release_version , new_dev_version )
80+
81+ print ('Creating new release: %s' % release_version )
82+
83+ if is_github_runner : # For GitHub Actions workflows
84+ with open (os .environ ['GITHUB_ENV' ], 'a' ) as f :
85+ f .write (f'RELEASE_VERSION={ release_version } ' )
86+ else : # Local use
87+ create_git_branch (release_version )
88+ # TODO(sbc): Maybe create the tag too
89+
7990 return 0
8091
8192
0 commit comments