Automate Test 1

This commit is contained in:
VerstreuteSeele
2022-12-18 20:21:38 +01:00
parent 3b2a037283
commit e76b3dfa83
3 changed files with 42 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 667 B

After

Width:  |  Height:  |  Size: 677 B

41
automate.py Normal file
View File

@@ -0,0 +1,41 @@
import os
import re
import shutil
folder = r'E:\Storage\Coding\Flipper Zero\Firmware\build-src'
settings = folder + r"\fbt_options.py"
commit = input("Whats your commit message?\nCommit Message: ")
def find_number():
regex = re.compile(r'(DIST_SUFFIX = \"CC_CL-)+[0]*([0-9]*)+(\")')
with open(settings) as f:
for line in f:
try:
obj = regex.search(line)
if not obj == None:
result = obj.group(0)
except:
pass
return result
def push_number(line):
with open(os.path.join(settings), "r+") as src:
file = src.read()
src.seek(0)
newnum = int(line.split("-")[1].replace('"', "").replace("0", "", 3)) + 1
newline = 'DIST_SUFFIX = "CC_CL-' + "0" * (4 -len(str(newnum))) + str(newnum) + '"'
print(f"New Version: {newline}")
src.write(file.replace(line, newline))
src.truncate()
src.close()
return newline.split('"')[1].split('"')[0]
def main():
ren = push_number(find_number())
os.system(f' cd "{folder}" && powershell -command "./fbt updater_package"')
newfolder = rf"E:\\Storage\\Coding\\Flipper-Zero\\Firmware\\{ren}"
shutil.move(os.path.join(folder + f"\\dist\\f7-C\\f7-update-{ren}"), newfolder)
os.system(f'git add * && git commit -m "{commit}"')
shutil.make_archive(ren, 'zip', newfolder)
os.system(f'''gh release create {ren.split('"')[1].split('"')[0]} -R "ClaraCrazy/flipper-firmware" --generate-notes {ren}.zip''')
main()

View File

@@ -14,7 +14,7 @@ DEBUG = 0
# Suffix to add to files when building distribution
# If OS environment has DIST_SUFFIX set, it will be used instead
DIST_SUFFIX = "CC_CL-0003"
DIST_SUFFIX = "CC_CL-0004"
# Coprocessor firmware
COPRO_OB_DATA = "scripts/ob.data"