Skip to content

Commit

Permalink
Improve the build workflow (#356)
Browse files Browse the repository at this point in the history
* Debug artifact files

* Test again

* Refactor build workflow and display file structure

* Refactor build folder structure and manifest generation

* Update build-firmware.yaml to include multiple firmware options

* Test again

* Copy firmware files to build assets

* Update firmware file location

* Fix file removal in build workflow

* Last round up to finish the build
  • Loading branch information
klaasnicolaas committed Jan 12, 2024
1 parent 848b78a commit 490478e
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions .github/workflows/build-firmware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ concurrency:
cancel-in-progress: true

env:
FIRMWARES: home-assistant-glow
FIRMWARES: |
home-assistant-glow
jobs:
prepare:
Expand Down Expand Up @@ -97,10 +98,10 @@ jobs:
- name: 🔨 Alter path in manifest.json
run: |
sed -i 's/${{ steps.esphome-build.outputs.name }}\//\/${{ matrix.firmware }}\/${{ matrix.device }}\//g' output/${{ matrix.device }}/manifest.json
- name: ⬆️ Upload firmware artifact
- name: ⬆️ Upload firmware / device artifact
uses: actions/upload-artifact@v4.0.0
with:
name: ${{ matrix.firmware}}
name: ${{ matrix.firmware}}-${{ matrix.device }}
path: output

combined-manifests:
Expand All @@ -115,20 +116,23 @@ jobs:
- project: home-assistant-glow
name: Home Assistant Glow
steps:
- name: ⤵️ Download artifacts
uses: actions/download-artifact@v3.0.2
- name: ⤵️ Download specific artifacts
uses: actions/download-artifact@v4.1.1
with:
name: ${{ matrix.project }}
path: files
pattern: ${{ matrix.project }}-*
merge-multiple: true
path: project-build
- name: 🔨 Generate device manifest.json
run: |
version=$(cat files/*/version | sort -V | tail -n 1)
jq -s --arg version "$version" '{"name": "${{ matrix.name }}", "version": $version, "home_assistant_domain": "esphome", "builds":.}' files/*/manifest.json > manifest.json
- name: ⬆️ Upload manifest.json
version=$(cat project-build/*/version | sort -V | tail -n 1)
jq -s --arg version "$version" '{"name": "${{ matrix.name }}", "version": $version, "home_assistant_domain": "esphome", "builds":.}' project-build/*/manifest.json > project-build/manifest.json
- name: 🧪 Display structure of job
run: ls -R
- name: ⬆️ Upload project artifact
uses: actions/upload-artifact@v4.0.0
with:
name: ${{ matrix.project }}
path: manifest.json
path: project-build

build-docs:
name: Build documentation website
Expand All @@ -138,12 +142,18 @@ jobs:
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4.1.1
- name: ⬇️ Download artifacts
uses: actions/download-artifact@v3.0.2
- name: ⬇️ Download all artifacts
uses: actions/download-artifact@v4.1.1
with:
path: output
- name: 🗂️ Copy firmware files to build assets
run: cp -R output/* docs/static
path: repository
- name: 🗂️ Move firmware folders to static
run: |
for firmware in $FIRMWARES; do
mv repository/$firmware docs/static
done
rm -R repository
- name: 🧪 Display structure of job
run: ls -R

- name: 🏗️ Set up Node.js
uses: actions/setup-node@v4.0.1
Expand Down

0 comments on commit 490478e

Please sign in to comment.