diff --git a/firmware/deploy-firmware.py b/firmware/deploy-firmware.py old mode 100644 new mode 100755 index 33601e2..5bfc883 --- a/firmware/deploy-firmware.py +++ b/firmware/deploy-firmware.py @@ -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]