Skip to content

Update build.yml

Update build.yml #273

Workflow file for this run

name: Build
# Build the ESPHome firmwares for the S0tool project.
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
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/[email protected]
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/[email protected]
with:
name: ${{ matrix.firmware.name }}
path: output
consolidate:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
name: Consolidate firmwares 🚀
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Download built firmwares
uses: actions/download-artifact@v4
with:
path: firmwares
- name: Copy files
run: |-
mkdir output
cp -R static/* output/
cp -R firmwares/*/* output/
- name: Upload GitHub Pages artifact
uses: actions/[email protected]
with:
path: output
deploy:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
name: Deploy to GitHub Pages 🚀
runs-on: ubuntu-latest
needs: consolidate
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
- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected]