New micro wake word 2 m5stack-atom-echo.yaml
#598
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
name: Build | |
# yamllint disable-line rule:truthy | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
pull_request: | |
concurrency: | |
# yamllint disable-line rule:line-length | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
FIRMWARES: esp-web-tools esphome-web voice-assistant wake-word-voice-assistant bluetooth-proxy media-player | |
# VOICE_ASSISTANT_VERSION: 2024.4.2 | |
# WAKE_WORD_VOICE_ASSISTANT_VERSION: 2024.4.2 | |
jobs: | |
prepare: | |
name: Prepare matrix | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.prepare-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get changed files | |
id: changes | |
uses: masesgroup/retrieve-changed-files@v3 | |
if: github.event_name == 'pull_request' | |
- name: Prepare matrix | |
id: prepare-matrix | |
run: |- | |
matrix="" | |
full_run=$(! [[ "${{ github.event_name }}" != "pull_request" || "${{ steps.changes.outputs.modified }}" == *".github/workflows/build.yml"* ]]; echo $?) | |
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 [[ $full_run -eq 0 && "${{ steps.changes.outputs.added_modified }}" != *"${device}"* ]]; then | |
continue | |
fi | |
device=${device##*/} | |
device=${device%.yaml} | |
version="latest" | |
fw=${firmware//-/_} | |
fw=${fw^^} | |
fw_version=${fw}_VERSION | |
if [[ -n "${!fw_version}" ]]; then | |
version=${!fw_version} | |
fi | |
matrix="$matrix{\"firmware\":\"$firmware\",\"device\":\"$device\", \"version\":\"$version\"}," | |
done | |
done | |
matrix=${matrix%?} | |
matrix="{\"include\":[$matrix]}" | |
echo matrix=$matrix >> $GITHUB_OUTPUT | |
build: | |
name: ${{ matrix.firmware }} / ${{ matrix.device }} | |
runs-on: ubuntu-latest | |
needs: prepare | |
strategy: | |
max-parallel: 5 | |
fail-fast: false | |
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build Firmware | |
uses: esphome/[email protected] | |
id: esphome-build | |
with: | |
yaml_file: ${{ matrix.firmware }}/${{ matrix.device }}.yaml | |
version: ${{ matrix.version || 'latest' }} | |
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 manifest path | |
if: ${{ matrix.device != 'pico-w' }} | |
run: | | |
sed -i 's/${{ steps.esphome-build.outputs.name }}\//\/${{ matrix.firmware }}\/${{ matrix.device }}\//g' output/${{ matrix.device }}/manifest.json | |
- uses: actions/[email protected] | |
with: | |
name: build-${{ matrix.firmware }}-${{ matrix.device }} | |
path: output | |
retention-days: 1 | |
combined-manifests: | |
name: Combine ${{ matrix.project }} manifests | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- project: esp-web-tools | |
name: ESP Web Tools Example | |
- project: esphome-web | |
name: ESPHome Web | |
steps: | |
- uses: actions/[email protected] | |
with: | |
pattern: build-${{ matrix.project }}-* | |
merge-multiple: true | |
path: files | |
- name: Generate 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 > files/manifest.json | |
- uses: actions/[email protected] | |
with: | |
name: ${{ matrix.project }} | |
path: files | |
retention-days: 1 | |
full-manifests: | |
name: Create ${{ matrix.project }} manifest | |
runs-on: ubuntu-latest | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- project: voice-assistant | |
name: Voice Assistant | |
- project: wake-word-voice-assistant | |
name: Voice Assistant | |
- project: bluetooth-proxy | |
name: Bluetooth Proxy | |
- project: media-player | |
name: Media Player | |
steps: | |
- uses: actions/[email protected] | |
with: | |
pattern: build-${{ matrix.project }}-* | |
merge-multiple: true | |
path: files | |
- name: Generate manifest.json files | |
run: | | |
cd files | |
for device in */; do | |
mkdir -p ../output/$device | |
pushd $device | |
version=$(cat project_version) | |
jq --arg version "$version" '{"name": "${{ matrix.name }}", "version": $version, "home_assistant_domain": "esphome", "new_install_skip_erase": false, "builds":[.]}' manifest.json > manifest.tmp.json | |
mv manifest.tmp.json manifest.json | |
popd | |
done | |
- uses: actions/[email protected] | |
with: | |
name: ${{ matrix.project }} | |
path: files | |
retention-days: 1 | |
consolidate: | |
name: Consolidate firmwares | |
runs-on: ubuntu-latest | |
needs: | |
- combined-manifests | |
- full-manifests | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/[email protected] | |
with: | |
pattern: "!build-*" | |
path: output | |
- run: cp -R static/* output/ | |
- uses: actions/[email protected] | |
with: | |
path: output | |
retention-days: 1 | |
deploy: | |
if: (github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'release' | |
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] |