From f57a9625b7ce5adf716a16a52f4f234976e097e1 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 1 Aug 2024 13:44:23 +0200 Subject: [PATCH] Add binaries to binary branch instead of master (#441) --- .github/workflows/beta.yml | 33 ++++++++++++++--- .github/workflows/nightly.yml | 39 +++++++++++++++----- .github/workflows/release.yml | 41 +++++++++++++++------ index.html | 2 +- pio_package_pre.py | 12 ++++++ platformio.ini | 8 +++- resources/config_version.py | 40 ++++++++++++++++++++ resources/ota_manifest.py | 8 ++++ src/Config.h | 63 ++++++++++++++++---------------- src/WebCfgServer.cpp | 4 +- updater/pio_package_pre.py | 13 ++++++- updater/pio_package_pre_solo1.py | 16 ++++++-- 12 files changed, 213 insertions(+), 66 deletions(-) create mode 100644 pio_package_pre.py create mode 100644 resources/config_version.py diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 8200247..871a703 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -49,6 +49,7 @@ jobs: Version: ${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt }} run: | sed -i "s/unknownbuildnr/$Version/g" src/Config.h + python3 resources/config_version.py beta - name: Build ${{ matrix.build }} PlatformIO Project ${{ matrix.board }} run: | if [ "$BUILD" = "debug" ]; then @@ -97,7 +98,21 @@ jobs: - name: Git Checkout uses: actions/checkout@v4 with: - ref: ${{ github.head_ref }} + ref: binary + - name: Git Checkout master + uses: actions/checkout@v4 + with: + ref: master + path: master + sparse-checkout: | + resources/ota_manifest.py + src/Config.h + - name: Git Commands + run: | + git checkout --orphan newBinary + git branch -D binary + git branch -M binary + git rm --cached --ignore-unmatch -r * - name: Download release assets uses: actions/download-artifact@v4 with: @@ -108,17 +123,23 @@ jobs: Version: ${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt }} run: | mkdir -p ota/beta/ + mkdir -p resources/ + mkdir -p src/ cp -vf release/*/nuki_hub_*.bin ota/beta/ - rm -rf release + cp -vf master/resources/ota_manifest.py resources/ota_manifest.py + cp -vf master/src/Config.h src/Config.h python3 resources/ota_manifest.py beta $Version - - name: Commit binaries to master + find * -not -path "ota*" -not -path "webflash*" -delete + rm -rf .github .gitignore .gitmodules + - name: Commit binaries to binary uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: "Update beta binaries" - file_pattern: 'ota/beta/*.bin ota/manifest.json' - branch: master + commit_message: "Update binaries" + file_pattern: 'ota/* ota/master/* ota/beta/* webflash/*' + branch: binary skip_dirty_check: true skip_fetch: true skip_checkout: true disable_globbing: true add_options: '-f' + push_options: '-f' diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index e55a3c2..5518b6b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -19,12 +19,11 @@ jobs: submodules: recursive - name: Get new commits run: echo "NEW_COMMIT_COUNT=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_ENV - - name: Check if commits larger than 1 - if: ${{ env.NEW_COMMIT_COUNT < 2 }} + - name: Check if commits larger than 0 + if: ${{ env.NEW_COMMIT_COUNT < 1 }} run: exit 1 build: name: Build ${{ matrix.board }} (${{ matrix.build }}) - if: github.repository == 'technyon/nuki_hub' needs: check-commits runs-on: ubuntu-latest strategy: @@ -67,6 +66,7 @@ jobs: Version: ${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt }} run: | sed -i "s/unknownbuildnr/$Version/g" src/Config.h + python3 resources/config_version.py master - name: Build ${{ matrix.build }} PlatformIO Project ${{ matrix.board }} run: | if [ "$BUILD" = "debug" ]; then @@ -109,14 +109,27 @@ jobs: path: ${{ matrix.build }}/${{ env.VARIANT }} ota-nightly: name: Create nightly from latest master - if: github.repository == 'technyon/nuki_hub' needs: build runs-on: ubuntu-latest steps: - name: Git Checkout uses: actions/checkout@v4 with: - ref: ${{ github.head_ref }} + ref: binary + - name: Git Checkout master + uses: actions/checkout@v4 + with: + ref: master + path: master + sparse-checkout: | + resources/ota_manifest.py + src/Config.h + - name: Git Commands + run: | + git checkout --orphan newBinary + git branch -D binary + git branch -M binary + git rm --cached --ignore-unmatch -r * - name: Download release assets uses: actions/download-artifact@v4 with: @@ -127,17 +140,23 @@ jobs: Version: ${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt }} run: | mkdir -p ota/master/ + mkdir -p resources/ + mkdir -p src/ cp -vf release/*/nuki_hub_*.bin ota/master/ - rm -rf release + cp -vf master/resources/ota_manifest.py resources/ota_manifest.py + cp -vf master/src/Config.h src/Config.h python3 resources/ota_manifest.py master $Version - - name: Commit binaries to master + find * -not -path "ota*" -not -path "webflash*" -delete + rm -rf .github .gitignore .gitmodules + - name: Commit binaries to binary uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: "Update master binaries" - file_pattern: 'ota/master/*.bin ota/manifest.json' - branch: master + commit_message: "Update binaries" + file_pattern: 'ota/* ota/master/* ota/beta/* webflash/*' + branch: binary skip_dirty_check: true skip_fetch: true skip_checkout: true disable_globbing: true add_options: '-f' + push_options: '-f' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9b98f8..8c2c01c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -97,10 +97,24 @@ jobs: - name: Git Checkout uses: actions/checkout@v4 with: - ref: ${{ github.head_ref }} + ref: binary + - name: Git Checkout master + uses: actions/checkout@v4 + with: + ref: master + path: master + sparse-checkout: | + resources/ota_manifest.py + src/Config.h + - name: Git Commands + run: | + git checkout --orphan newBinary + git branch -D binary + git branch -M binary + git rm --cached --ignore-unmatch -r * - name: Get the version id: get_version - run: echo "VERSION=$(cat src/Config.h | grep -oP '(?<=#define NUKI_HUB_VERSION \")(.*)(?=\")')" >> $GITHUB_OUTPUT + run: echo "VERSION=$(cat master/src/Config.h | grep -oP '(?<=#define NUKI_HUB_VERSION \")(.*)(?=\")')" >> $GITHUB_OUTPUT - name: Download release assets uses: actions/download-artifact@v4 with: @@ -167,22 +181,27 @@ jobs: env: Version: ${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt }} run: | + mkdir -p ota/ + mkdir -p resources/ + mkdir -p src/ cp -vf release/*/nuki_hub_*.bin ota/ cp -vf release/*/webflash_nuki_hub_*.bin webflash/ - rm -rf release - rm -rf debug - rm -rf NukiHub-*.zip - git rm -r --cached ota/beta/*.bin + cp -vf master/resources/ota_manifest.py resources/ota_manifest.py + cp -vf master/src/Config.h src/Config.h python3 resources/ota_manifest.py release $Version python3 resources/ota_manifest.py beta none - - name: Commit binaries to master + find * -not -path "ota*" -not -path "webflash*" -delete + rm -rf ota/beta/*.bin + rm -rf .github .gitignore .gitmodules + - name: Commit binaries to binary uses: stefanzweifel/git-auto-commit-action@v5 with: - commit_message: "Update binaries for version ${{ steps.get_version.outputs.VERSION }}" - file_pattern: 'ota/*.bin ota/manifest.json ota/beta/*.bin webflash/*.bin' - branch: master + commit_message: "Update binaries" + file_pattern: 'ota/* ota/master/* webflash/*' + branch: binary skip_dirty_check: true skip_fetch: true skip_checkout: true disable_globbing: true - add_options: '-f' \ No newline at end of file + add_options: '-f' + push_options: '-f' diff --git a/index.html b/index.html index b8a4fad..866f757 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,7 @@ type="module" src="https://unpkg.com/esp-web-tools@8.0.1/dist/web/install-button.js?module"> - +



Note: If flashing doesn't work, press and hold the "BOOT" switch, then click "Install". diff --git a/pio_package_pre.py b/pio_package_pre.py new file mode 100644 index 0000000..7659975 --- /dev/null +++ b/pio_package_pre.py @@ -0,0 +1,12 @@ +import re, shutil, os +from datetime import datetime, timezone + +regex = r"\#define NUKI_HUB_DATE \"(.*)\"" +content_new = "" + +with open ('src/Config.h', 'r' ) as readfile: + file_content = readfile.read() + content_new = re.sub(regex, "#define NUKI_HUB_DATE \"" + datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + "\"", file_content, flags = re.M) + +with open('src/Config.h', 'w') as writefile: + writefile.write(content_new) \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index e2a0a68..86581a8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -59,7 +59,9 @@ monitor_filters = [env:esp32dev] board = esp32dev -extra_scripts = post:pio_package.py +extra_scripts = + pre:pio_package_pre.py + post:pio_package.py build_flags = ${env.build_flags} -DBLESCANNER_USE_LATEST_NIMBLE @@ -87,7 +89,9 @@ board = esp32-c6-devkitm-1 platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32-2023.10.03.zip framework = arduino board = esp32-solo1 -extra_scripts = post:pio_package.py +extra_scripts = + pre:pio_package_pre.py + post:pio_package.py build_flags = ${env.build_flags} -DFRAMEWORK_ARDUINO_SOLO1 diff --git a/resources/config_version.py b/resources/config_version.py new file mode 100644 index 0000000..744f50a --- /dev/null +++ b/resources/config_version.py @@ -0,0 +1,40 @@ +import re, json, argparse +from urllib.request import urlopen + +parser = argparse.ArgumentParser() + +parser.add_argument('ota_type', type=str) +args = parser.parse_args() + +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) + +data = "" +number = 1 + +response = urlopen("https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json") +data = json.loads(response.read().decode("utf-8")) +if ("number" not in data[args.ota_type]): + number = 1 +elif (data[args.ota_type]['version'] == version): + number = data[args.ota_type]['number'] + 1 +else: + number = 1 + +content_new = "" + +with open ('src/Config.h', 'r' ) as readfile: + file_content = readfile.read() + content_new = re.sub(regex, "#define NUKI_HUB_VERSION \"" + str(version) + "-" + args.ota_type + str(number) + "\"", file_content, flags = re.M) + +with open('src/Config.h', 'w') as writefile: + writefile.write(content_new) \ No newline at end of file diff --git a/resources/ota_manifest.py b/resources/ota_manifest.py index 5f0691b..1ceb99b 100644 --- a/resources/ota_manifest.py +++ b/resources/ota_manifest.py @@ -25,7 +25,15 @@ with open('ota/manifest.json', 'r+') as json_file: data[args.ota_type]['time'] = "0000-00-00 00:00:00" data[args.ota_type]['version'] = "No beta available" data[args.ota_type]['build'] = "" + del(data[args.ota_type]['number']) else: + if ("number" not in data[args.ota_type]): + data[args.ota_type]['number'] = 1 + elif (data[args.ota_type]['version'] == version): + data[args.ota_type]['number'] = data[args.ota_type]['number'] + 1 + else: + data[args.ota_type]['number'] = 1 + 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 diff --git a/src/Config.h b/src/Config.h index 7939022..c29a36b 100644 --- a/src/Config.h +++ b/src/Config.h @@ -4,47 +4,48 @@ #define NUKI_HUB_VERSION "9.00" #define NUKI_HUB_BUILD "unknownbuildnr" +#define NUKI_HUB_DATE "unknownbuilddate" #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" +#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/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" -#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32c3.bin" -#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32c3.bin" -#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32c3.bin" -#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_esp32c3.bin" -#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_updater_esp32c3.bin" +#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32c3.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32c3.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32c3.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_updater_esp32c3.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_esp32c3.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_updater_esp32c3.bin" #elif defined(CONFIG_IDF_TARGET_ESP32S3) -#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32s3.bin" -#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32s3.bin" -#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32s3.bin" -#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32s3.bin" -#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_esp32s3.bin" -#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_updater_esp32s3.bin" +#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32s3.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32s3.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32s3.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_updater_esp32s3.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_esp32s3.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_updater_esp32s3.bin" #elif defined(CONFIG_IDF_TARGET_ESP32C6) -#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32c6.bin" -#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32c6.bin" -#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32c6.bin" -#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32c6.bin" -#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_esp32c6.bin" -#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_updater_esp32c6.bin" +#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32c6.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32c6.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32c6.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_updater_esp32c6.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_esp32c6.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_updater_esp32c6.bin" #else #if defined(FRAMEWORK_ARDUINO_SOLO1) -#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32solo1.bin" -#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32solo1.bin" -#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32solo1.bin" -#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32solo1.bin" -#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_esp32solo1.bin" -#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_updater_esp32solo1.bin" +#define GITHUB_LATEST_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32solo1.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32solo1.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32solo1.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_updater_esp32solo1.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_esp32solo1.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_updater_esp32solo1.bin" #else -#define GITHUB_LATEST_RELEASE_BINARY_URL "https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_esp32.bin" -#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/nuki_hub_updater_esp32.bin" -#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_esp32.bin" -#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/beta/nuki_hub_updater_esp32.bin" -#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_esp32.bin" -#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://github.com/technyon/nuki_hub/raw/master/ota/master/nuki_hub_updater_esp32.bin" +#define GITHUB_LATEST_RELEASE_BINARY_URL "https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_esp32.bin" +#define GITHUB_LATEST_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/nuki_hub_updater_esp32.bin" +#define GITHUB_BETA_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_esp32.bin" +#define GITHUB_BETA_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/beta/nuki_hub_updater_esp32.bin" +#define GITHUB_MASTER_RELEASE_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_esp32.bin" +#define GITHUB_MASTER_UPDATER_BINARY_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/master/nuki_hub_updater_esp32.bin" #endif #endif diff --git a/src/WebCfgServer.cpp b/src/WebCfgServer.cpp index 382e198..a627f9e 100644 --- a/src/WebCfgServer.cpp +++ b/src/WebCfgServer.cpp @@ -426,7 +426,9 @@ void WebCfgServer::buildOtaHtml(String &response, bool errored) response.concat(NUKI_HUB_VERSION); response.concat(" ("); response.concat(NUKI_HUB_BUILD); - response.concat(")
"); + response.concat("), "); + response.concat(NUKI_HUB_DATE); + response.concat("
"); #ifndef NUKI_HUB_UPDATER HTTPClient https; diff --git a/updater/pio_package_pre.py b/updater/pio_package_pre.py index 0417fb0..375aa1f 100644 --- a/updater/pio_package_pre.py +++ b/updater/pio_package_pre.py @@ -1,3 +1,14 @@ -import shutil +import re, shutil, os +from datetime import datetime, timezone + +regex = r"\#define NUKI_HUB_DATE \"(.*)\"" +content_new = "" + +with open ('../src/Config.h', 'r' ) as readfile: + file_content = readfile.read() + content_new = re.sub(regex, "#define NUKI_HUB_DATE \"" + datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + "\"", file_content, flags = re.M) + +with open('../src/Config.h', 'w') as writefile: + writefile.write(content_new) shutil.copy("../src/main.cpp", "src/main.cpp") \ No newline at end of file diff --git a/updater/pio_package_pre_solo1.py b/updater/pio_package_pre_solo1.py index 36ab242..ad5b255 100644 --- a/updater/pio_package_pre_solo1.py +++ b/updater/pio_package_pre_solo1.py @@ -1,5 +1,5 @@ -import shutil -import os +import re, shutil, os +from datetime import datetime, timezone if not os.path.exists('src/networkDevices/'): os.mkdir('src/networkDevices') @@ -29,4 +29,14 @@ shutil.copy("../src/networkDevices/EthLan8720Device.cpp", "src/networkDevices/Et shutil.copy("../src/networkDevices/IPConfiguration.cpp", "src/networkDevices/IPConfiguration.cpp") shutil.copy("../src/networkDevices/NetworkDevice.cpp", "src/networkDevices/NetworkDevice.cpp") shutil.copy("../src/networkDevices/W5500Device.cpp", "src/networkDevices/W5500Device.cpp") -shutil.copy("../src/networkDevices/WifiDevice.cpp", "src/networkDevices/WifiDevice.cpp") \ No newline at end of file +shutil.copy("../src/networkDevices/WifiDevice.cpp", "src/networkDevices/WifiDevice.cpp") + +regex = r"\#define NUKI_HUB_DATE \"(.*)\"" +content_new = "" + +with open ('src/Config.h', 'r' ) as readfile: + file_content = readfile.read() + content_new = re.sub(regex, "#define NUKI_HUB_DATE \"" + datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + "\"", file_content, flags = re.M) + +with open('src/Config.h', 'w') as writefile: + writefile.write(content_new) \ No newline at end of file