-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpost_release.py
36 lines (29 loc) · 1.34 KB
/
post_release.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
# Run this script every time you make a git flow release, AFTER the release
import subprocess
import shutil
import os
if __name__ == '__main__':
# Switch to develop branch
subprocess.call(['git', 'checkout', 'develop'])
# create local brand new branch
BRANCH_NAME = 'minimal_source'
subprocess.call(['git', 'branch', '-D', BRANCH_NAME])
subprocess.call(['git', 'checkout', '-b', BRANCH_NAME])
# clean
subprocess.call(['python', 'clean.py', '-u'])
subprocess.call(['python', 'generate_code.py', '-acu'])
# retrieve last commit sha1
p = subprocess.Popen(['git', 'rev-parse', 'develop'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
last_commit_str, err = p.communicate()
return_code = p.returncode
# commit files
subprocess.call(['git', 'commit', '-m', 'minimal version of commit %s' % last_commit_str])
# delete remote branch
subprocess.call(['git', 'push', 'origin', '--delete', BRANCH_NAME])
# create remote branch: -u = set-upstream and push
subprocess.call(['git', 'push', '-u', 'origin', BRANCH_NAME])
# Switch back to develop
# but first we need to commit all unstage files to make it work properly
subprocess.call(['git', 'add', '--all'])
subprocess.call(['git', 'commit', '-m', '"fake"'])
subprocess.call(['git', 'checkout', 'develop'])