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
from collections import namedtuple
from datetime import datetime
import subprocess
from distutils.version import StrictVersion
from esptool import LoadFirmwareImage # required to get hash and checksum right
import packaging.version
from esptool.bin_image import LoadFirmwareImage # required to get hash and checksum right
import os
# 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
def tag_from_version(v):
return tag_prefix + v
return tag_prefix + str(v)
def increment_version(v):
parsed_version = [int(i) for i in v.split('.')]
def increment_version(v: packaging.version.Version):
parsed_version = [int(i) for i in str(v).split('.')]
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()
version_strings.sort(key=StrictVersion)
latest_release = version_strings[-1]
versions = [packaging.version.parse(s) for s in get_released_versions()]
versions.sort()
latest_release = versions[-1]
commits_since_tag = subprocess.getoutput(
'git rev-list {}..HEAD --count'.format(tag_from_version(latest_release)))
sha = subprocess.getoutput('git rev-parse HEAD')[:sha_length]