From 860ae74ac43cb9361d2cfdc07752faa8a0723fe8 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 16 Apr 2025 20:52:31 +0200 Subject: [PATCH] Auto set next release version --- .github/workflows/release.yml | 22 ++++++++++++++++++++++ resources/next_version.py | 24 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 resources/next_version.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f8546b6..81146b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -178,3 +178,25 @@ jobs: disable_globbing: true add_options: '-f' push_options: '-f' + next_version: + name: Set next release version + needs: release + runs-on: ubuntu-latest + steps: + - name: Git Checkout master + uses: actions/checkout@v4 + with: + ref: master + - name: Set new version + run: | + python3 resources/next_version.py + - name: Commit config to master + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Set next release version" + file_pattern: 'src/Config.h' + branch: master + skip_dirty_check: true + skip_fetch: true + skip_checkout: true + disable_globbing: true \ No newline at end of file diff --git a/resources/next_version.py b/resources/next_version.py new file mode 100644 index 0000000..a01ec03 --- /dev/null +++ b/resources/next_version.py @@ -0,0 +1,24 @@ +import re + +regex = r"\#define NUKI_HUB_VERSION \"(.*)\"" +regex2 = r"\#define NUKI_HUB_VERSION_INT \(uint32_t\)(.*)" +version = "unknown" +version_int = "unknown" +content_new = "" + +with open('src/Config.h', 'r') as file: + file_content = file.read() + matches = re.finditer(regex, file_content, re.MULTILINE) + + for matchNum, match in enumerate(matches, start=1): + for groupNum in range(0, len(match.groups())): + groupNum = groupNum + 1 + version = match.group(groupNum) + version_int = int((float(version)*100)+0.1) + 1 + version = float(version_int / 100) + + content_new = re.sub(regex, "#define NUKI_HUB_VERSION \"" + str('{:.2f}'.format(version)) + "\"", file_content, flags = re.M) + content_new = re.sub(regex2, "#define NUKI_HUB_VERSION_INT (uint32_t)" + str(version_int), content_new, flags = re.M) + +with open('src/Config.h', 'w') as writefile: + writefile.write(content_new)