-
Notifications
You must be signed in to change notification settings - Fork 8
218 lines (190 loc) · 6.74 KB
/
esphome.yaml
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
name: Build ESPHome
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: write
actions: read
checks: write
jobs:
check-tag:
runs-on: ubuntu-latest
outputs:
tag_on_main: ${{ steps.check_tag.outputs.tag_on_main }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if tag is on main branch
id: check_tag
run: |
TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})
MAIN_COMMIT=$(git rev-parse origin/main)
if git merge-base --is-ancestor $TAG_COMMIT $MAIN_COMMIT; then
echo "tag_on_main=true" >> $GITHUB_OUTPUT
echo "Tag is on main branch"
else
echo "tag_on_main=false" >> $GITHUB_OUTPUT
echo "Tag is not on main branch"
fi
build:
needs: check-tag
if: needs.check-tag.outputs.tag_on_main == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
target: [esp32s2, esp32s3]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 0
- name: Create empty secrets file
run: |
touch firmware/secrets.yaml
touch firmware/conf.d/secrets.yaml
- name: Setup yq
uses: vegardit/gha-setup-yq@v1
- name: Set git sha
run: |
SUMMARY=$(git log -1 --pretty=%B)
SUMMARY="${SUMMARY//'%'/'%25'}"
SUMMARY="${SUMMARY//$'\n'/'%0A'}"
SUMMARY="${SUMMARY//$'\r'/'%0D'}"
echo "RELEASE_SUMMARY=$SUMMARY" >> $GITHUB_ENV
- name: Modify version.yaml
run: |
yq -i '.substitutions.version = "${{ github.ref_name }}"' firmware/conf.d/version.yaml
cat firmware/conf.d/version.yaml
- name: Build OpenSpool-Mini firmware
uses: esphome/[email protected]
with:
yaml-file: ${{ github.workspace }}/firmware/openspool-mini.yaml
release-summary: ${{ env.RELEASE_SUMMARY }}
release-url: https://openspool.io/firmware
complete-manifest: false
if: matrix.target == 'esp32s2'
- name: Build OpenSpool-AMS firmware
uses: esphome/[email protected]
with:
yaml-file: ${{ github.workspace }}/firmware/openspool-ams.yaml
release-summary: ${{ env.RELEASE_SUMMARY }}
release-url: https://openspool.io/firmware
complete-manifest: false
if: matrix.target == 'esp32s3'
- name: ls
run: |
ls -la
ls openspool-${{ matrix.target }}/* || true
- name: Generate md5 checksum
run: |
ls -la openspool-${{ matrix.target }}
for file in openspool-${{ matrix.target }}/*.bin; do
md5sum "$file" | awk '{print $1}' > "${file}.md5"
md5_length=$(wc -c < "${file}.md5")
if [ "$md5_length" -ne 33 ]; then
echo "MD5 generation failed for $file (length: $md5_length)"
exit 1
fi
ls -la openspool-${{ matrix.target }}
done
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: openspool-${{ matrix.target }}
path: openspool-${{ matrix.target }}/**/*
retention-days: 5
if-no-files-found: error
combine-manifests:
needs: [check-tag, build]
if: needs.check-tag.outputs.tag_on_main == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: downloaded-artifacts
- name: list artifacts
run: |
ls -ial
- name: Purge local firmware
run: |
rm -f docs/firmware/*.json || true
rm -f docs/firmware/*.bin || true
cp downloaded-artifacts/openspool-esp32s2/*.bin docs/firmware/
cp downloaded-artifacts/openspool-esp32s2/*.md5 docs/firmware/
cp downloaded-artifacts/openspool-esp32s3/*.bin docs/firmware/
cp downloaded-artifacts/openspool-esp32s3/*.md5 docs/firmware/
- name: Combined manifests
run: |
jq -n --arg version "${{ github.ref_name }}" '{
name: "OpenSpool",
version: $version,
builds: [],
new_install_prompt_erase: true
}' > docs/firmware/manifest.json
for target in esp32s2 esp32s3; do
if [ -f "downloaded-artifacts/openspool-$target/manifest.json" ]; then
jq --slurpfile new_build "downloaded-artifacts/openspool-$target/manifest.json" '.builds += $new_build' docs/firmware/manifest.json > temp.json && mv temp.json docs/firmware/manifest.json
else
echo "Warning: manifest for $target not found"
exit 1
fi
done
jq '.' docs/firmware/manifest.json
ls -l docs/firmware
- name: Setup yq
uses: vegardit/gha-setup-yq@v1
- name: Modify version.yaml
run: |
yq -i '.substitutions.version = "${{ github.ref_name }}"' firmware/conf.d/version.yaml
cat firmware/conf.d/version.yaml
- name: Update manifest
run: |
git stash push -m "Stash before switching to main"
git checkout main
git pull origin main
git stash apply
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add firmware/conf.d/version.yaml
git add docs/firmware/*
git diff --staged || true
if git diff --staged --quiet; then
echo "No changes to commit"
exit 1
else
git commit -m "Update version to ${{ github.ref_name }}"
git push origin main
fi
git status
- name: Create Release Folder
run: |
mkdir -p release
cp docs/firmware/manifest.json release/manifest.json
cp docs/firmware/*.bin release/
cp docs/firmware/*.md5 release/
- name: Release ${{ github.ref_name }}
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ github.ref_name }}"
prerelease: false
files: |
release/**/*
# - name: Release Latest
# uses: "marvinpinto/action-automatic-releases@latest"
# with:
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
# automatic_release_tag: "latest"
# prerelease: false
# files: |
# release/**/*