-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathrelease.py
60 lines (50 loc) · 2.45 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import argparse
import subprocess
parser = argparse.ArgumentParser(description='Release Mixpanel Flutter SDK')
parser.add_argument('--old', help='version for the release', action="store")
parser.add_argument('--new', help='version for the release', action="store")
args = parser.parse_args()
def bump_version():
replace_version('pubspec.yaml', "version: " + args.old, "version: " + args.new)
replace_version('lib/mixpanel_flutter.dart', "\'\\$lib_version\': \'" + args.old + "\'", "\'\\$lib_version\': \'" + args.new + "\'")
replace_version('test/mixpanel_flutter_test.dart', "\'\\$lib_version\': \'" + args.old + "\'", "\'\\$lib_version\': \'" + args.new + "\'")
replace_version('ios/mixpanel_flutter.podspec', "= \'" + args.old + "\'", "= \'" + args.new + "\'")
subprocess.call('git add pubspec.yaml', shell=True)
subprocess.call('git add lib/mixpanel_flutter.dart', shell=True)
subprocess.call('git add test/mixpanel_flutter_test.dart', shell=True)
subprocess.call('git add ios/mixpanel_flutter.podspec', shell=True)
subprocess.call('git commit -m "Version {}"'.format(args.new), shell=True)
subprocess.call('git push', shell=True)
def replace_version(file_name, old_version, new_version):
with open(file_name) as f:
file_str = f.read()
assert(old_version in file_str)
file_str = file_str.replace(old_version, new_version)
with open(file_name, "w") as f:
f.write(file_str)
def generate_docs():
subprocess.call('flutter analyze --no-pub --no-current-package lib', shell=True)
subprocess.call('dartdoc --output docs', shell=True)
subprocess.call('git add docs', shell=True)
subprocess.call('git commit -m "Update docs"', shell=True)
subprocess.call('git push', shell=True)
def add_tag():
subprocess.call('git tag -a v{} -m "version {}"'.format(args.new, args.new), shell=True)
subprocess.call('git push origin --tags', shell=True)
def publish_dry_run():
subprocess.call('mv docs doc', shell=True)
subprocess.call('dart pub publish --dry-run', shell=True)
subprocess.call('mv doc docs', shell=True)
def clean_up():
subprocess.call('flutter clean', shell=True)
subprocess.call('cd example', shell=True)
subprocess.call('flutter clean', shell=True)
def main():
bump_version()
generate_docs()
add_tag()
publish_dry_run()
clean_up()
print("Congratulations! " + args.new + " is now ready to be released!")
if __name__ == '__main__':
main()