Skip to content

Commit

Permalink
Merge pull request #230 from huizebruin/jesserockz-2024-448
Browse files Browse the repository at this point in the history
Use esphome build workflow
  • Loading branch information
huizebruin authored Sep 15, 2024
2 parents ca0847c + 52342af commit c210038
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 89 deletions.
114 changes: 37 additions & 77 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,85 +9,29 @@ on:
release:
types: [published]

env:
RELEASE_URL: ${{ github.server_url }}/${{ github.repository }}/releases/latest
FIRMWARES: |
s0tool
jobs:
build:
name: Build ${{ matrix.firmware.name }}
runs-on: ubuntu-latest
strategy:
matrix:
firmware:
- file: esphome/watermeter.yaml
name: s0tool-watermeter
manifest_filename: s0tool-watermeter-manifest.json
- file: esphome/pulscounter.yaml
name: s0tool-standard
manifest_filename: s0tool-standard-manifest.json
- file: esphome/S0-puls-kwhpuls.yaml
name: s0tool-kwh-puls
manifest_filename: s0tool-kwh-puls-manifest.json
- file: esphome/S0-puls-DSZ12D.yaml
name: s0tool-dsz12d
manifest_filename: s0tool-dsz12d-manifest.json
- file: esphome/S0-puls-LEM022SJ.yaml
name: s0tool-lem022sj
manifest_filename: s0tool-lem022sj-manifest.json
- file: esphome/s0-watermeter.yaml
name: s0tool-s0-watermeter
manifest_filename: s0tool-s0-watermeter-manifest.json
- file: esphome/wsz15d32a.yaml
name: s0tool-wsz15d32a
manifest_filename: s0tool-wsz15d32a-manifest.json
- file: esphome/sdm72d.yaml
name: s0tool-sdm72d
manifest_filename: s0tool-sdm72d-manifest.json
- file: esphome/puls-water-internal.yaml
name: s0tool-standard-internal
manifest_filename: s0tool-standard-internal-manifest.json
- file: esphome/kwh-water-test.yaml
name: s0tool-kwh-water-test
manifest_filename: s0tool-kwh-water-test-manifest.json
- file: esphome/pulscounter_flux.yaml
name: s0tool-standard-flux
manifest_filename: s0tool-standard-flux-manifest.json

fail-fast: false
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Read version from YAML file
id: read_version
run: |
project_version=$(grep 'project_version:' esphome/components/basis.yaml | awk '{print $2}' | tr -d '"')
echo "project_version=$project_version" >> $GITHUB_ENV
- name: Build firmware
uses: esphome/build-action@v3.2.0
id: esphome-build
with:
yaml_file: ${{ matrix.firmware.file }}
version: 2024.7.3
release_url: ${{ github.event.release.html_url || env.RELEASE_URL }}

- name: Copy firmware and manifest 🔨
run: |
mkdir output
mv ${{ steps.esphome-build.outputs.name }} output/
jq -s "{\"name\": \"${{ matrix.firmware.name }}\", \"version\": \"${{ env.project_version }}\", \"home_assistant_domain\": \"esphome\", \"new_install_prompt_erase\": false, \"builds\":.}" output/${{ steps.esphome-build.outputs.name }}/manifest.json > output/${{ matrix.firmware.manifest_filename }}
- name: Upload artifact
uses: actions/upload-artifact@v4.4.0
with:
name: ${{ matrix.firmware.name }}
path: output
name: Build firmware 🛠️
uses: esphome/workflows/.github/workflows/build.yml@main
with:
files: |
esphome/watermeter.yaml
esphome/pulscounter.yaml
esphome/S0-puls-kwhpuls.yaml
esphome/S0-puls-DSZ12D.yaml
esphome/S0-puls-LEM022SJ.yaml
esphome/s0-watermeter.yaml
esphome/wsz15d32a.yaml
esphome/sdm72d.yaml
esphome/puls-water-internal.yaml
esphome/kwh-water-test.yaml
esphome/pulscounter_flux.yaml
esphome-version: 2024.7.3
release-summary: ${{ github.event_name == 'release' && github.event.release.body || '' }}
release-url: ${{ github.event_name == 'release' && github.event.release.html_url || '' }}
release-version: ${{ github.event_name == 'release' && github.event.release.tag_name || '' }}

consolidate:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
name: Consolidate firmwares 🚀
runs-on: ubuntu-latest
needs: build
Expand All @@ -98,18 +42,34 @@ jobs:
uses: actions/download-artifact@v4
with:
path: firmwares
- name: Remove intermediate version folder
run: |-
for d in firmwares/*/*; do
if [ -d "$d" ]; then
mv $d/* $d/../
rm -rf $d
fi
done
- name: Copy files
run: |-
mkdir output
cp -R static/* output/
cp -R firmwares/*/* output/
cp -R firmwares/* output/
- name: Copy manifest files to root and modify paths # This is required so that older firmwares can update to newer firmwares with new manifest paths
run: |-
for device in firmwares/*; do
device=$(basename $device)
jq --arg device "$device" \
'.builds[].ota.path |= $device + "/" + . | (.builds[].parts // [])[].path |= $device + "/" + .' \
firmwares/$device/manifest.json > output/$device-manifest.json
done
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3.0.1
with:
path: output

deploy:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
if: github.event_name == 'release'
name: Deploy to GitHub Pages 🚀
runs-on: ubuntu-latest
needs: consolidate
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/s0tool-dsz12d-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-dsz12d-manifest.json
source: https://s0tool.nl/s0tool-dsz12d/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-kwh-puls-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-kwh-puls-manifest.json
source: https://s0tool.nl/s0tool-kwh-puls/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-kwh-water-test-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-kwh-water-test-manifest.json
source: https://s0tool.nl/s0tool-kwh-water-test/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-lem022sj-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-lem022sj-manifest.json
source: https://s0tool.nl/s0tool-lem022sj/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-s0-watermeter-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-s0-watermeter-manifest.json
source: https://s0tool.nl/s0tool-s0-watermeter/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-sdm72d-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-sdm72d-manifest.json
source: https://s0tool.nl/s0tool-sdm72d/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-standard-flux-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-standard-flux-manifest.json
source: https://s0tool.nl/s0tool-standard-flux/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-standard-internal-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-standard-internal-manifest.json
source: https://s0tool.nl/s0tool-standard-internal/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-standard-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-standard-manifest.json
source: https://s0tool.nl/s0tool-standard/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-watermeter-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-watermeter-manifest.json
source: https://s0tool.nl/s0tool-watermeter/manifest.json
2 changes: 1 addition & 1 deletion esphome/components/s0tool-wsz15d32a-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ update:
- platform: http_request
name: Firmware Update
id: update_http_request
source: https://s0tool.nl/s0tool-wsz15d32a-manifest.json
source: https://s0tool.nl/s0tool-wsz15d32a/manifest.json
2 changes: 1 addition & 1 deletion static/Installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ <h3>s0tool-standard-flux</h3>
document.querySelectorAll('input[name="type"]').forEach((radio) =>
radio.addEventListener("change", () => {
const button = document.querySelector("esp-web-install-button");
button.manifest = `./${radio.value}-manifest.json`;
button.manifest = `./${radio.value}/manifest.json`;

document.querySelectorAll(".info").forEach((info) => {
info.classList.add("hidden");
Expand Down

0 comments on commit c210038

Please sign in to comment.