-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflutterbuild.py
More file actions
executable file
·34 lines (27 loc) · 921 Bytes
/
flutterbuild.py
File metadata and controls
executable file
·34 lines (27 loc) · 921 Bytes
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
#!/usr/bin/env python3
from sys import argv
from subprocess import run
FILENAME = 'pubspec.yaml'
BACKUP_FILENAME = '.pubspec.old.yaml'
try:
with open(FILENAME) as f:
lines = f.readlines()
except FileNotFoundError:
print('No pubspec.yaml file in current directory')
exit(1)
with open(BACKUP_FILENAME, 'w') as f:
f.writelines(lines)
for i in range(len(lines)):
if lines[i].startswith('version'):
split = lines[i].split('+')
build_number = run('git rev-list --all --count'.split(), capture_output=True).stdout.decode('utf8').strip()
print('BUILD NUMBER', build_number)
lines[i] = split[0] + '+' + build_number + '\n'
break
with open(FILENAME, 'w') as f:
f.writelines(lines)
if len(argv) > 1 and argv[1] in ['--debug', '--release', '--profile']:
args = ' ' + argv[1]
else:
args = ''
run(('flutter build ios' + args).split(), check=False)