Fix in deploy firmware

This commit is contained in:
Martin Bauer 2023-09-07 16:10:15 +02:00
parent b128732e56
commit 149fb4fb03
1 changed files with 11 additions and 9 deletions

20
firmware/deploy-firmware.py Normal file → Executable file
View File

@ -1,9 +1,11 @@
#!/usr/bin/env python3
import struct import struct
from collections import namedtuple from collections import namedtuple
from datetime import datetime from datetime import datetime
import subprocess import subprocess
from distutils.version import StrictVersion import packaging.version
from esptool import LoadFirmwareImage # required to get hash and checksum right from esptool.bin_image import LoadFirmwareImage # required to get hash and checksum right
import os import os
# locale.setlocale(locale.LC_ALL, 'en_US') # locale.setlocale(locale.LC_ALL, 'en_US')
@ -32,16 +34,16 @@ def version_number_from_git(tag_prefix='release/', sha_length=10, version_format
return versions return versions
def tag_from_version(v): def tag_from_version(v):
return tag_prefix + v return tag_prefix + str(v)
def increment_version(v): def increment_version(v: packaging.version.Version):
parsed_version = [int(i) for i in v.split('.')] parsed_version = [int(i) for i in str(v).split('.')]
parsed_version[-1] += 1 parsed_version[-1] += 1
return '.'.join(str(i) for i in parsed_version) return packaging.version.parse('.'.join(str(i) for i in parsed_version))
version_strings = get_released_versions() versions = [packaging.version.parse(s) for s in get_released_versions()]
version_strings.sort(key=StrictVersion) versions.sort()
latest_release = version_strings[-1] latest_release = versions[-1]
commits_since_tag = subprocess.getoutput( commits_since_tag = subprocess.getoutput(
'git rev-list {}..HEAD --count'.format(tag_from_version(latest_release))) 'git rev-list {}..HEAD --count'.format(tag_from_version(latest_release)))
sha = subprocess.getoutput('git rev-parse HEAD')[:sha_length] sha = subprocess.getoutput('git rev-parse HEAD')[:sha_length]