From 791ee31ebe998f0ce2311576a96800a9e29fd972 Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Thu, 27 Jun 2024 12:08:29 +0200 Subject: [PATCH 1/3] Build and deploy Web Installer for releases --- .github/workflows/CI.yml | 51 ++++---------------------- .github/workflows/release.yml | 12 +++++++ .github/workflows/web_installer.yml | 55 +++++++++++++++++++++++++++++ config/installer_index.html | 5 +++ tools/bake_installer.py | 5 +++ 5 files changed, 83 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/web_installer.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 537bc5481..c4054cea1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -56,51 +56,12 @@ jobs: - name: "Build environment: ${{ matrix.envname }}" run: pio run -e ${{ matrix.envname }} - build-and-publish-installer: - if: ( github.repository_owner == 'PlummersSoftwareLLC' && github.ref == 'refs/heads/main' ) || ( github.repository_owner == 'rbergen' && github.ref == 'refs/heads/staging' ) - - runs-on: ubuntu-latest + call-web-installer: + if: ( github.repository_owner == 'rbergen' && github.ref == 'refs/heads/staging' ) needs: [build-environment] - env: - PLATFORMIO_CORE_DIR: ${{ github.workspace }}/.platformio - - steps: - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - - name: Maximize build space - uses: easimon/maximize-build-space@master - with: - remove-android: 'true' - remove-codeql: 'true' - remove-docker-images: 'true' - remove-dotnet: 'true' - remove-haskell: 'true' - - - uses: actions/checkout@v4 - - - name: Install PlatformIO - run: | - curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -o get-platformio.py - python get-platformio.py - echo "${PLATFORMIO_CORE_DIR}/penv/bin" >> $GITHUB_PATH - - - name: Copy secrets and clear SSID - run: | - grep -v "^#define cszSSID" include/secrets.example.h > include/secrets.h - echo '#define cszSSID ""' >> include/secrets.h - - - name: Build web installer environments and installer - run: | - python tools/bake_installer.py - touch WebInstaller/.nojekyll - - - name: Push to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4 - with: - branch: pages - folder: WebInstaller + uses: ./.github/workflows/web_installer.yml + with: + release-name: ${{ github.ref_name }} commit ${{ github.sha }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..d9f9f03b5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,12 @@ +name: Release actions + +on: + release: + types: [published] + +jobs: + call-web-installer: + uses: ./.github/workflows/web_installer.yml + with: + release-name: ${{ github.event.release.name }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/web_installer.yml b/.github/workflows/web_installer.yml new file mode 100644 index 000000000..0da8e768b --- /dev/null +++ b/.github/workflows/web_installer.yml @@ -0,0 +1,55 @@ +name: Web Installer build and deploy + +on: + workflow_call: + inputs: + release-name: + description: 'Name of the Web Installer release' + required: true + type: string + +jobs: + build-and-publish-installer: + runs-on: ubuntu-latest + + env: + PLATFORMIO_CORE_DIR: ${{ github.workspace }}/.platformio + + steps: + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Maximize build space + uses: easimon/maximize-build-space@master + with: + remove-android: 'true' + remove-codeql: 'true' + remove-docker-images: 'true' + remove-dotnet: 'true' + remove-haskell: 'true' + + - uses: actions/checkout@v4 + + - name: Install PlatformIO + run: | + curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -o get-platformio.py + python get-platformio.py + echo "${PLATFORMIO_CORE_DIR}/penv/bin" >> $GITHUB_PATH + + - name: Copy secrets and clear SSID + run: | + grep -v "^#define cszSSID" include/secrets.example.h > include/secrets.h + echo '#define cszSSID ""' >> include/secrets.h + + - name: Build web installer environments and installer + run: | + python tools/bake_installer.py ${{ inputs.release-name }} + touch WebInstaller/.nojekyll + + - name: Push to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: pages + folder: WebInstaller diff --git a/config/installer_index.html b/config/installer_index.html index 33f1b9028..7aa6c3631 100644 --- a/config/installer_index.html +++ b/config/installer_index.html @@ -55,6 +55,11 @@

NightDriverLED ESP32 Installation Wizard

+ + Release: $$RELEASE_NAME$$ + +

+ diff --git a/tools/bake_installer.py b/tools/bake_installer.py index 9367a0ee2..51cd9f307 100755 --- a/tools/bake_installer.py +++ b/tools/bake_installer.py @@ -35,6 +35,7 @@ import json import shutil import subprocess +import sys import show_features class Dirs: @@ -57,6 +58,7 @@ class Manifest: globals_h = 'globals.h' index_template_file = 'installer_index.html' index_file = 'index.html' +release_name = sys.argv[1] if len(sys.argv) > 1 else 'unnamed' # Do some ground work to set up the web installer directory, starting with the installer image assets... assets_target_dir = os.path.join(Dirs.webinstaller, Dirs.assets) @@ -205,6 +207,9 @@ class Manifest: with open(os.path.join(Dirs.config, index_template_file), "r", encoding='utf-8') as f: index_template = f.read() +# ...then inject release name... +index_template = index_template.replace('$$RELEASE_NAME$$', release_name) + # ...and write it with the feature legend injected with open(os.path.join(Dirs.webinstaller, index_file), 'w', encoding='utf-8') as f: f.write(index_template.replace('$$FEATURE_LEGEND$$', ', '.join(legend_entries))) \ No newline at end of file From e9e14a360d0a9a4cca78572961e8d0c8ddb4767b Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Thu, 27 Jun 2024 12:29:11 +0200 Subject: [PATCH 2/3] Put release name between quotes --- .github/workflows/web_installer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/web_installer.yml b/.github/workflows/web_installer.yml index 0da8e768b..09cd4d1b0 100644 --- a/.github/workflows/web_installer.yml +++ b/.github/workflows/web_installer.yml @@ -45,7 +45,7 @@ jobs: - name: Build web installer environments and installer run: | - python tools/bake_installer.py ${{ inputs.release-name }} + python tools/bake_installer.py '${{ inputs.release-name }}' touch WebInstaller/.nojekyll - name: Push to GitHub Pages From 8f612a3ece54a8a5aaf2129494fbc4bc7faad894 Mon Sep 17 00:00:00 2001 From: Rutger van Bergen Date: Thu, 27 Jun 2024 13:40:12 +0200 Subject: [PATCH 3/3] Make release line italic --- config/installer_index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/installer_index.html b/config/installer_index.html index 7aa6c3631..9ef4c55ed 100644 --- a/config/installer_index.html +++ b/config/installer_index.html @@ -56,7 +56,7 @@

NightDriverLED ESP32 Installation Wizard

- Release: $$RELEASE_NAME$$ + Release: $$RELEASE_NAME$$