-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish.py
90 lines (71 loc) · 2.44 KB
/
publish.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
import os
import re
import sys
def write_file(path, str):
f = open(path, "w")
f.write(str)
f.close()
def read_file(path):
f = open(path, "r")
str = f.read()
f.close()
return str
def get_input(promo, default):
inp = input(promo)
if inp == "":
return default
else:
return inp
def get_input_multiline(promo, default):
print(promo)
lines = []
while True:
line = input()
if line:
lines.append(line)
else:
break
if len(lines) == 0:
return default
else:
return '\\n'.join(lines)
args = sys.argv.copy()[1:]
isRelease = args[0] == "release"
versionName = ""
# update version info
versionNumberRegex = "\\d+\\.\\d+\\.\\d+"
buildNumberRegex = "(?<=\\+)\\d+"
if isRelease:
write_file("lib/nightly.dart", "const nightly = false;")
pubspec = read_file("pubspec.yaml")
versionNumber = re.findall(versionNumberRegex, pubspec)[0]
buildNumber = re.findall(buildNumberRegex, pubspec)[0]
versionNumber = get_input("Enter a new version number (current {}):".format(versionNumber),
versionNumber)
buildNumber = str(int(buildNumber) + 1)
versionName = versionNumber
print("New version: " + versionNumber + "+" + buildNumber)
pubspec = re.sub(versionNumberRegex, versionNumber, pubspec, 1)
pubspec = re.sub(buildNumberRegex, buildNumber, pubspec, 1)
write_file("pubspec.yaml", pubspec)
else:
write_file("lib/nightly.dart", "const nightly = true;")
pubspec = read_file("pubspec.yaml")
versionNumber = re.findall(versionNumberRegex, pubspec)[0]
buildNumber = re.findall(buildNumberRegex, pubspec)[0]
buildNumber = str(int(buildNumber) + 1)
versionName = "Nightly build " + buildNumber
print("New version: " + versionNumber + "+" + buildNumber)
pubspec = re.sub(buildNumberRegex, buildNumber, pubspec, 1)
write_file("pubspec.yaml", pubspec)
del args[0]
release_note = get_input_multiline("Release Note:", "").replace("-", "[")
# build
os.system("./build.py")
# upload
if isRelease:
os.system("thunar build/app/outputs/apk/release/")
else:
os.system("./basic_upload_apks.py site.pegasis.yrdsb.ta \"" + versionName + "\" \"" + release_note +
"\" build/app/outputs/apk/release/app-armeabi-v7a-release.apk build/app/outputs/apk/release/app-arm64-v8a-release.apk build/app/outputs/apk/release/app-x86_64-release.apk")