Merge pull request #662 from iranl/auto-set-next-version

Auto set next release version
This commit is contained in:
iranl
2025-04-16 21:29:35 +02:00
committed by GitHub
2 changed files with 46 additions and 0 deletions

View File

@@ -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

24
resources/next_version.py Normal file
View File

@@ -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)