Skip to content

Commit

Permalink
Merge pull request #635 from rbergen/releases-installer
Browse files Browse the repository at this point in the history
Make Web Installer build and deploy on releases publication
  • Loading branch information
rbergen committed Jun 28, 2024
2 parents b6d5ee7 + 8f612a3 commit de10232
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 45 deletions.
51 changes: 6 additions & 45 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions .github/workflows/web_installer.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions config/installer_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
<div class="content">
<img src="assets/NightDriverLogo-small.png" style="width: 640px; height: 380px" />
<h1>NightDriverLED ESP32 Installation Wizard</h1>

<em><small>Release: $$RELEASE_NAME$$</small></em>

<br/><br/>

<label for="devices-dropdown">Select your device type:</label>
<select id="devices-dropdown"></select>

Expand Down
5 changes: 5 additions & 0 deletions tools/bake_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import json
import shutil
import subprocess
import sys
import show_features

class Dirs:
Expand All @@ -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)
Expand Down Expand Up @@ -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)))

0 comments on commit de10232

Please sign in to comment.