diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 63c3496..2b53552 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -108,11 +108,12 @@ jobs: mkdir -p ota/beta/ cp -vf release/*/nuki_hub_*.bin ota/beta/ rm -rf release + python3 resources/ota_manifest.py beta $Version - name: Commit binaries to master uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "Update beta binaries" - file_pattern: 'ota/beta/*.bin' + file_pattern: 'ota/beta/*.bin ota/manifest.json' branch: master skip_dirty_check: true skip_fetch: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bbb0080..1da75e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -166,6 +166,9 @@ jobs: name: "Nuki Hub ${{ steps.get_version.outputs.VERSION }}" artifacts: ${{ steps.zip.outputs.artifacts }} artifactContentType: application/zip + - name: Add version info + env: + Version: ${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt }} - name: Copy binaries to ota and webflash and remove beta run: | cp -vf release/*/nuki_hub_*.bin ota/ @@ -174,11 +177,13 @@ jobs: rm -rf debug rm -rf NukiHub-*.zip git rm -r --cached ota/beta/*.bin + python3 resources/ota_manifest.py release $Version + python3 resources/ota_manifest.py beta none - name: Commit binaries to master uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "Update binaries for version ${{ steps.get_version.outputs.VERSION }}" - file_pattern: 'ota/*.bin ota/beta/*.bin ota/beta/debug/*.bin webflash/*.bin' + file_pattern: 'ota/*.bin ota/manifest.json ota/beta/*.bin webflash/*.bin' branch: master skip_dirty_check: true skip_fetch: true diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 69bdb4f..41183e5 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -115,11 +115,12 @@ jobs: mkdir -p ota/master/ cp -vf release/*/nuki_hub_*.bin ota/master/ rm -rf release + python3 resources/ota_manifest.py master $Version - name: Commit binaries to master uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "Update master binaries" - file_pattern: 'ota/master/*.bin' + file_pattern: 'ota/master/*.bin ota/manifest.json' branch: master skip_dirty_check: true skip_fetch: true diff --git a/.gitignore b/.gitignore index 9d2bd1a..0f732aa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ cmake-build-debug cmake-build-release cmake-build-release-s3 bin/* -ota/* +ota/*.bin webflash/*.bin .pio .vscode diff --git a/ota/manifest.json b/ota/manifest.json new file mode 100644 index 0000000..30142af --- /dev/null +++ b/ota/manifest.json @@ -0,0 +1,17 @@ +{ + "release": { + "time": "2024-07-18 00:00:00", + "version": "8.35", + "build": "" + }, + "beta": { + "time": "2024-07-18 00:00:00", + "version": "9.00", + "build": "" + }, + "master": { + "time": "2024-07-18 00:00:00", + "version": "9.00", + "build": "" + } +} \ No newline at end of file diff --git a/resources/ota_manifest.py b/resources/ota_manifest.py new file mode 100644 index 0000000..5f0691b --- /dev/null +++ b/resources/ota_manifest.py @@ -0,0 +1,34 @@ +import re, json, argparse +from datetime import datetime, timezone + +regex = r"\#define NUKI_HUB_VERSION \"(.*)\"" +version = "unknown" + +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) + +parser = argparse.ArgumentParser() + +parser.add_argument('ota_type', type=str) +parser.add_argument('build', type=str) +args = parser.parse_args() + +with open('ota/manifest.json', 'r+') as json_file: + data = json.load(json_file) + if (args.build == 'none'): + data[args.ota_type]['time'] = "0000-00-00 00:00:00" + data[args.ota_type]['version'] = "No beta available" + data[args.ota_type]['build'] = "" + else: + data[args.ota_type]['time'] = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + data[args.ota_type]['version'] = version + data[args.ota_type]['build'] = args.build + json_file.seek(0) + json.dump(data, json_file, indent=4) + json_file.truncate() \ No newline at end of file diff --git a/src/Config.h b/src/Config.h index b24b409..7008901 100644 --- a/src/Config.h +++ b/src/Config.h @@ -7,6 +7,7 @@ #define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest" #define GITHUB_LATEST_RELEASE_API_URL (char*)"https://api.github.com/repos/technyon/nuki_hub/releases/latest" +#define GITHUB_OTA_MANIFEST_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/manifest.json" #if defined(CONFIG_IDF_TARGET_ESP32C3) #define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32c3.bin"