From f6aea3bbf601e29c2625a50a78da714ba7c16190 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:24:48 +1200 Subject: [PATCH 1/4] Build firmware with gh actions --- .github/workflows/build.yml | 70 +++++++++++++++++++++++++++++++++++++ static/index.html | 12 +++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 static/index.html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..8ec9c639 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,70 @@ +name: Build ESPHome firmware + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + build-firmware: + name: Build Firmware + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - name: Build Firmware + uses: esphome/build-action@v3.2.0 + id: esphome-build + with: + yaml_file: voice-kit.yaml + version: latest + cache: true + - name: Move generated files to output + run: | + mkdir -p output + mv ${{ steps.esphome-build.outputs.name }}/*.bin output/ + jq --arg version "${{ steps.esphome-build.outputs.project-version }}" \ + '{"name": "ESPHome Voice Kit", "version": $version, "home_assistant_domain": "esphome", "new_install_skip_erase": false, "builds":[.]}' \ + ${{ steps.esphome-build.outputs.name }}/manifest.json > output/manifest.json + + - name: Upload firmware + uses: actions/upload-artifact@v4.3.4 + with: + path: output + name: voice-kit + + build-pages: + name: Build pages + runs-on: ubuntu-latest + needs: + - build-firmware + steps: + - uses: actions/checkout@v4.1.7 + - uses: actions/download-artifact@v4.1.8 + with: + name: voice-kit + path: output + - run: cp -R static/* output/ + - uses: actions/upload-pages-artifact@v3.0.1 + with: + path: output + retention-days: 1 + + deploy: + if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' + name: Deploy to GitHub Pages + runs-on: ubuntu-latest + needs: build-pages + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Setup Pages + uses: actions/configure-pages@v5.0.0 + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4.0.5 diff --git a/static/index.html b/static/index.html new file mode 100644 index 00000000..8c98f273 --- /dev/null +++ b/static/index.html @@ -0,0 +1,12 @@ + + + + ESPHome Voice Kit + + + + + + + + From 124a8701a865738aaa1bbe130be5ec5ae9f9060e Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:34:52 +1200 Subject: [PATCH 2/4] Fix deploy step to only run on push to dev --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ec9c639..00b3dea0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build ESPHome firmware on: push: branches: - - main + - dev pull_request: workflow_dispatch: @@ -52,7 +52,8 @@ jobs: retention-days: 1 deploy: - if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' + # TODO: Change this to `release` later. + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/dev') name: Deploy to GitHub Pages runs-on: ubuntu-latest needs: build-pages From 556c3e73b51d9b67added7d12c2876db89945c1e Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:40:50 +1200 Subject: [PATCH 3/4] Fix paths --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00b3dea0..25450591 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,10 +23,10 @@ jobs: - name: Move generated files to output run: | mkdir -p output - mv ${{ steps.esphome-build.outputs.name }}/*.bin output/ + mv ${{ steps.esphome-build.outputs.name }} output/ jq --arg version "${{ steps.esphome-build.outputs.project-version }}" \ '{"name": "ESPHome Voice Kit", "version": $version, "home_assistant_domain": "esphome", "new_install_skip_erase": false, "builds":[.]}' \ - ${{ steps.esphome-build.outputs.name }}/manifest.json > output/manifest.json + output/${{ steps.esphome-build.outputs.name }}/manifest.json > output/manifest.json - name: Upload firmware uses: actions/upload-artifact@v4.3.4 From 24815d7624dcee0ccd855d9232b742d059353d07 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:46:56 +1200 Subject: [PATCH 4/4] Fix deprecated manifest key --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25450591..c17470f0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: mkdir -p output mv ${{ steps.esphome-build.outputs.name }} output/ jq --arg version "${{ steps.esphome-build.outputs.project-version }}" \ - '{"name": "ESPHome Voice Kit", "version": $version, "home_assistant_domain": "esphome", "new_install_skip_erase": false, "builds":[.]}' \ + '{"name": "ESPHome Voice Kit", "version": $version, "home_assistant_domain": "esphome", "new_install_prompt_erase": false, "builds":[.]}' \ output/${{ steps.esphome-build.outputs.name }}/manifest.json > output/manifest.json - name: Upload firmware