fix(webui): replace listeners with two-way bindings #249
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a basic workflow to help you get started with Actions | |
| name: CI | |
| # Controls when the action will run. Triggers the workflow on push or pull request | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| tags: | |
| - 'v0.*' | |
| paths-ignore: | |
| - '.vscode/**' | |
| - '.gitignore' | |
| - 'LICENSE' | |
| - '*.md' | |
| - 'docs/**' | |
| concurrency: | |
| group: "build" | |
| cancel-in-progress: true | |
| jobs: | |
| cleanup-dev-release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| steps: | |
| - name: Update dev tag | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| try { | |
| await github.rest.git.updateRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: 'tags/dev', | |
| sha: context.sha, | |
| force: true | |
| }); | |
| } catch (e) { | |
| if (e.status === 404 || (e.response && e.response.status === 404)) { | |
| await github.rest.git.createRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: 'refs/tags/dev', | |
| sha: context.sha | |
| }); | |
| } else { | |
| throw e; | |
| } | |
| } | |
| - name: Cleanup dev release | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const serverUrl = process.env.GITHUB_SERVER_URL || 'https://github.com'; | |
| const runUrl = `${serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| const body = `Latest commits are being processed, come back later.\nBuild status can be checked [here](${runUrl})`; | |
| try { | |
| const { data: release } = await github.rest.repos.getReleaseByTag({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag: 'dev' | |
| }); | |
| for (const asset of release.assets) { | |
| await github.rest.repos.deleteReleaseAsset({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| asset_id: asset.id | |
| }); | |
| } | |
| await github.rest.repos.updateRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: release.id, | |
| body: body | |
| }); | |
| } catch (e) { | |
| if (e.status === 404 || (e.response && e.response.status === 404)) { | |
| console.log('No dev release found, skipping cleanup'); | |
| } else { | |
| throw e; | |
| } | |
| } | |
| littlefs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: 'data' | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install LittleFS Tool | |
| run: pip install littlefs-python | |
| - name: Install dependencies | |
| run: bun install | |
| working-directory: data | |
| - name: Build | |
| run: bun run build | |
| working-directory: data | |
| - name: Remove extra, only keep compressed | |
| run: find dist -regex ".*\.\(html\|css\|br\|js\|json.gz\)" -delete | |
| working-directory: data | |
| - name: Create LittleFS Image | |
| run: littlefs-python create $(pwd)/dist littlefs.bin -v --fs-size=0x20000 --name-max=64 --block-size=4096 | |
| working-directory: data | |
| - name: Archive build directory | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ui-build-directory | |
| path: data/dist | |
| retention-days: 1 | |
| - name: Archive LittleFS image | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: littlefs-binary | |
| path: data/littlefs.bin | |
| esp32: | |
| runs-on: ubuntu-latest | |
| needs: littlefs | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| submodules: 'recursive' | |
| - name: Get UI Build Directory | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: ui-build-directory | |
| path: data/dist | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| $HOME/.ccache | |
| managed_components | |
| key: ${{ runner.os }}-esp32-build | |
| - name: ESP32 Build | |
| uses: espressif/esp-idf-ci-action@v1 | |
| with: | |
| esp_idf_version: v5.5.4 | |
| target: esp32 | |
| path: '.' | |
| extra_docker_args: -v $HOME/.ccache:/root/.ccache -e CCACHE_DIR=/root/.ccache | |
| command: CI=true idf.py --ccache build && idf.py merge-bin | |
| - name: Rename firmware | |
| run: sudo chown -R $USER:$USER build/ && mv build/HomeKey-ESP32.bin build/esp32.firmware.bin && mv build/merged-binary.bin build/esp32.firmware.factory.bin | |
| - name: Archive firmware | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: esp32-firmware | |
| path: build/esp32.firmware.bin | |
| - name: Archive merged binary | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: esp32-firmware-factory | |
| path: build/esp32.firmware.factory.bin | |
| esp32c3: | |
| runs-on: ubuntu-latest | |
| needs: littlefs | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| submodules: 'recursive' | |
| - name: Get UI Build Directory | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: ui-build-directory | |
| path: data/dist | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| $HOME/.ccache | |
| managed_components | |
| key: ${{ runner.os }}-esp32c3-build | |
| - name: ESP32C3 Build | |
| uses: espressif/esp-idf-ci-action@v1 | |
| with: | |
| esp_idf_version: v5.5.4 | |
| target: esp32c3 | |
| path: '.' | |
| extra_docker_args: -v $HOME/.ccache:/root/.ccache -e CCACHE_DIR=/root/.ccache | |
| command: CI=true idf.py --ccache build && idf.py merge-bin | |
| - name: Rename firmware | |
| run: sudo chown -R $USER:$USER build/ && mv build/HomeKey-ESP32.bin build/esp32c3.firmware.bin && mv build/merged-binary.bin build/esp32c3.firmware.factory.bin | |
| - name: Archive firmware | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: esp32c3-firmware | |
| path: build/esp32c3.firmware.bin | |
| - name: Archive merged binary | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: esp32c3-firmware-factory | |
| path: build/esp32c3.firmware.factory.bin | |
| esp32c6: | |
| runs-on: ubuntu-latest | |
| needs: littlefs | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| submodules: 'recursive' | |
| - name: Get UI Build Directory | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: ui-build-directory | |
| path: data/dist | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| $HOME/.ccache | |
| managed_components | |
| key: ${{ runner.os }}-esp32c6-build | |
| - name: ESP32C6 Build | |
| uses: espressif/esp-idf-ci-action@v1 | |
| with: | |
| esp_idf_version: v5.5.4 | |
| target: esp32c6 | |
| path: '.' | |
| command: CI=true idf.py --ccache build && idf.py merge-bin | |
| - name: Rename firmware | |
| run: sudo chown -R $USER:$USER build/ && mv build/HomeKey-ESP32.bin build/esp32c6.firmware.bin && mv build/merged-binary.bin build/esp32c6.firmware.factory.bin | |
| - name: Archive firmware | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: esp32c6-firmware | |
| path: build/esp32c6.firmware.bin | |
| - name: Archive merged binary | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: esp32c6-firmware-factory | |
| path: build/esp32c6.firmware.factory.bin | |
| esp32s3: | |
| runs-on: ubuntu-latest | |
| needs: littlefs | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| submodules: 'recursive' | |
| - name: Get UI Build Directory | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: ui-build-directory | |
| path: data/dist | |
| - uses: actions/cache@v5 | |
| with: | |
| path: | | |
| $HOME/.ccache | |
| managed_components | |
| key: ${{ runner.os }}-esp32s3-build | |
| - name: ESP32S3 Build | |
| uses: espressif/esp-idf-ci-action@v1 | |
| with: | |
| esp_idf_version: v5.5.4 | |
| target: esp32s3 | |
| path: '.' | |
| extra_docker_args: -v $HOME/.ccache:/root/.ccache -e CCACHE_DIR=/root/.ccache | |
| command: CI=true idf.py --ccache build && idf.py merge-bin | |
| - name: Rename firmware | |
| run: sudo chown -R $USER:$USER build/ && mv build/HomeKey-ESP32.bin build/esp32s3.firmware.bin && mv build/merged-binary.bin build/esp32s3.firmware.factory.bin | |
| - name: Archive firmware | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: esp32s3-firmware | |
| path: build/esp32s3.firmware.bin | |
| - name: Archive merged binary | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: esp32s3-firmware-factory | |
| path: build/esp32s3.firmware.factory.bin | |
| pre-release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| needs: [littlefs, esp32, esp32c3, esp32c6, esp32s3] | |
| steps: | |
| - name: Get Artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Update dev release | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const artifactsDir = 'artifacts'; | |
| const files = [ | |
| 'esp32.firmware.bin', | |
| 'esp32.firmware.factory.bin', | |
| 'esp32c3.firmware.bin', | |
| 'esp32c3.firmware.factory.bin', | |
| 'esp32c6.firmware.bin', | |
| 'esp32c6.firmware.factory.bin', | |
| 'esp32s3.firmware.bin', | |
| 'esp32s3.firmware.factory.bin', | |
| 'littlefs.bin' | |
| ]; | |
| let release; | |
| try { | |
| const { data: existing } = await github.rest.repos.getReleaseByTag({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag: 'dev' | |
| }); | |
| release = existing; | |
| } catch (e) { | |
| if (e.status === 404 || (e.response && e.response.status === 404)) { | |
| const { data: notes } = await github.rest.repos.generateReleaseNotes({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: 'dev', | |
| target_commitish: context.sha | |
| }); | |
| const { data: newRelease } = await github.rest.repos.createRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: 'dev', | |
| name: 'development', | |
| prerelease: true, | |
| body: notes.body | |
| }); | |
| release = newRelease; | |
| } else { | |
| throw e; | |
| } | |
| } | |
| for (const file of files) { | |
| const filePath = path.join(artifactsDir, file); | |
| if (!fs.existsSync(filePath)) { | |
| console.log(`Skipping missing file: ${file}`); | |
| continue; | |
| } | |
| await github.rest.repos.uploadReleaseAsset({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: release.id, | |
| name: file, | |
| data: fs.readFileSync(filePath) | |
| }); | |
| } | |
| const { data: notes } = await github.rest.repos.generateReleaseNotes({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag_name: 'dev', | |
| target_commitish: context.sha | |
| }); | |
| await github.rest.repos.updateRelease({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: release.id, | |
| body: notes.body | |
| }); |