⬆️ Update dependency react to v19 #1016
Workflow file for this run
This file contains 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
--- | |
# Test building ESPHome firmwares for the Home Assistant Glow project. | |
name: Build firmware | |
on: | |
push: | |
branches: | |
- develop | |
- release/** | |
workflow_dispatch: | |
workflow_call: | |
inputs: | |
release-url: | |
required: true | |
type: string | |
pull_request: | |
branches-ignore: | |
- renovate/docusaurus** | |
# Every Monday at 4:00 UTC | |
schedule: | |
- cron: "0 4 * * 1" | |
concurrency: | |
# yamllint disable-line rule:line-length | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
RELEASE_URL: ${{ github.server_url }}/${{ github.repository }}/releases/latest | |
FIRMWARES: | | |
home-assistant-glow | |
jobs: | |
prepare: | |
name: Prepare matrix | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.prepare-matrix.outputs.matrix }} | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/[email protected] | |
- name: ⤵️ Get changed files | |
if: github.event_name == 'pull_request' | |
id: changes | |
uses: masesgroup/retrieve-changed-files@v3 | |
- name: 🚧 Prepare matrix | |
id: prepare-matrix | |
run: |- | |
# Set variables | |
matrix="" | |
fullRun=$(! [[ "${{ github.event_name }}" != "pull_request" || "${{ steps.changes.outputs.modified }}" == *".github/workflows/build-firmware.yaml"* ]]; echo $?) | |
# Iterate through firmwares and devices | |
for firmware in $FIRMWARES; do | |
for device in $firmware/*.yaml; do | |
# If pull_request event type and changed files do not contain the device, skip it | |
if [[ $fullRun -eq 0 && "${{ steps.changes.outputs.added_modified }}" != *"${device}"* ]]; then | |
continue | |
fi | |
# Extract device name from file path | |
device=${device##*/} | |
device=${device%.yaml} | |
# Set default version | |
version="latest" | |
# Build matrix entry | |
matrix="$matrix{\"firmware\":\"$firmware\",\"device\":\"$device\", \"version\":\"$version\"}," | |
done | |
done | |
# Remove trailing comma and format matrix | |
matrix=${matrix%?} | |
matrix="{\"include\":[$matrix]}" | |
# Output matrix to a file | |
echo matrix=$matrix >> $GITHUB_OUTPUT | |
- name: 🧪 Display generated matrix | |
run: | | |
echo "${{ steps.prepare-matrix.outputs.matrix }}" | |
build: | |
name: ${{ matrix.firmware }} / ${{ matrix.device }} | |
if: ${{ needs.prepare.outputs.matrix != '{"include":[]}' }} | |
runs-on: ubuntu-latest | |
needs: prepare | |
strategy: | |
max-parallel: 5 | |
fail-fast: false | |
matrix: ${{fromJson(needs.prepare.outputs.matrix)}} | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/[email protected] | |
- name: 🔍 Determine ref - ESPHome packages | |
if: ${{ !contains(fromJSON('["release", "workflow_call"]'), github.event_name) }} | |
run: | | |
echo "ref: ${{ github.head_ref || github.ref_name }}" | |
sed -i "s|ref: .*|ref: \"${{ github.head_ref || github.ref_name }}\"|g" ${{ matrix.firmware }}/${{ matrix.device }}.yaml | |
- name: 🧪 Display changed YAML file | |
run: cat ${{ matrix.firmware }}/${{ matrix.device }}.yaml | |
- name: 🔨 Build firmware | |
uses: esphome/[email protected] | |
id: esphome-build | |
with: | |
yaml-file: ${{ matrix.firmware }}/${{ matrix.device }}.yaml | |
version: ${{ matrix.version || 'latest' }} | |
release-summary: "Check the release notes for more information." | |
release-url: ${{ inputs.release-url || env.RELEASE_URL }} | |
cache: true | |
- name: 🚚 Move generated files to output | |
run: | | |
mkdir -p output/${{ matrix.device }} | |
mv ${{ steps.esphome-build.outputs.name }}/* output/${{ matrix.device }}/ | |
echo ${{ steps.esphome-build.outputs.version }} > output/${{ matrix.device }}/version | |
echo ${{ steps.esphome-build.outputs.project-version }} > output/${{ matrix.device }}/project_version | |
- name: 🔨 Alter path in manifest.json | |
run: | | |
sed -i 's/${{ steps.esphome-build.outputs.name }}\(\.[a-z]*\)\.bin/\/${{ matrix.firmware }}\/${{ matrix.device }}\/${{ steps.esphome-build.outputs.name }}\1.bin/' output/${{ matrix.device }}/manifest.json | |
cat output/${{ matrix.device }}/manifest.json | |
- name: ⬆️ Upload firmware / device artifact | |
uses: actions/[email protected] | |
with: | |
name: build-${{ matrix.firmware}}-${{ matrix.device }} | |
path: output | |
retention-days: 1 |