-
Notifications
You must be signed in to change notification settings - Fork 124
152 lines (143 loc) · 4.43 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Build
on:
push:
branches:
- main
workflow_dispatch:
pull_request:
schedule:
- cron: '0 5 * * 1'
concurrency:
# yamllint disable-line rule:line-length
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.firmware }}-${{ matrix.device }}
runs-on: ubuntu-latest
strategy:
max-parallel: 5
fail-fast: false
matrix:
firmware:
- esp-web-tools
- esphome-web
device:
- esp8266
- esp32
- esp32c3
- esp32s2
- esp32s3
version:
- latest
include:
- firmware: esphome-web
device: pico-w
- firmware: voice-assistant
device: m5stack-atom-echo
steps:
- uses: actions/checkout@v4
- uses: esphome/[email protected]
id: esphome-build
with:
yaml_file: ${{ matrix.firmware }}/${{ matrix.device }}.yaml
version: ${{ matrix.version || 'latest' }}
- 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
- 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: ${{ matrix.firmware }}
path: output
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
- project: esphome-web
name: ESPHome Web
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.project }}
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", "new_install_skip_erase": false, "builds":.}' files/*/manifest.json > manifest.json
- uses: actions/[email protected]
with:
name: ${{ matrix.project }}
path: manifest.json
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
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.project }}
path: files
- name: Generate manifest.json files
run: |
cd files
for device in */; do
mkdir -p ../output/$device
pushd $device
version=$(cat version)
jq --arg version "$version" '{"name": "${{ matrix.name }}", "version": $version, "home_assistant_domain": "esphome", "new_install_skip_erase": false, "builds":[.]}' manifest.json > ../../output/$device/manifest.json
popd
done
- uses: actions/[email protected]
with:
name: ${{ matrix.project }}
path: output
consolidate:
name: Consolidate firmwares
runs-on: ubuntu-latest
needs:
- combined-manifests
- full-manifests
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
with:
path: output
- run: cp -R static/* output/
- uses: actions/[email protected]
with:
path: output
deploy:
if: (github.event_name == 'workflow_dispatch' || github.event_name == 'push') && 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@v3
- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected]