-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_release.py
More file actions
78 lines (61 loc) · 2.58 KB
/
make_release.py
File metadata and controls
78 lines (61 loc) · 2.58 KB
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
#!/usr/bin/env python3
import argparse, os, json, re, shutil
print('Running release build script...' )
#what boards / build targets to include in the release
boards = [
"esp32dev",
]
if __name__ == '__main__':
#look up our version #
version = False
file = open("include/defs.h", "r")
for line in file:
result = re.search(r'FIRMWARE_VERSION "(.*)"', line)
if result:
version = result.group(1)
break
#only proceed if we found the version
if (version):
config = []
#get our changelog
with open("CHANGELOG") as f:
changelog = f.read()
print (f'Making firmware release for version {version}')
for board in boards:
print (f'Building {board} firmware')
#make our firmware.json entry
bdata = {}
bdata['type'] = board
bdata['version'] = version
bdata['url'] = f'https://raw.githubusercontent.com/TheDutchDev/BambuController/master/releases/{board}-{version}.bin'
bdata['changelog'] = changelog
config.append(bdata)
#build the firmware
cmd = f'pio run -e "{board}" -s'
os.system(cmd)
#sign the firmware
# cmd = f'openssl dgst -sign ~/Dropbox/misc/yarrboard/priv_key.pem -keyform PEM -sha256 -out .pio/build/{board}/firmware.sign -binary .pio/build/{board}/firmware.bin'
# os.system(cmd)
#combine the signatures
# cmd = f'cat .pio/build/{board}/firmware.sign .pio/build/{board}/firmware.bin > .pio/build/{board}/signed.bin'
# os.system(cmd)
#copy our fimrware to releases directory
shutil.copyfile(f'build/{board}/firmware.bin', f'releases/{board}-{version}.bin')
#keep our ELF file for debugging later on....
shutil.copyfile(f'build/{board}/firmware.elf', f'releases/{board}-{version}.elf')
#write our config json file
config_str = json.dumps(config, indent=4)
with open("firmware.json", "w") as text_file:
text_file.write(config_str)
#some info to the user to finish the release
print("Build complete.\n")
print("Next steps:")
print(f'1. Add the new firmware files: git add releases')
print(f'2. Commit the new version: git commit -am "Firmware release v{version}"')
print(f'3. Push changes to github: git push')
print(f'4. Create a new tag: git tag -a v{version} -m "Firmware release v{version}"')
print(f'5. Push your tags: git push origin v{version}')
print(f'\nOr just run this:\n')
print(f'git add releases && git commit -am "Firmware release v{version}" && git push && git tag -a v{version} -m "Firmware release v{version}" && git push origin v{version}')
else:
print("FIRMWARE_VERSION not #defined in include/defs.h")