-
-
Notifications
You must be signed in to change notification settings - Fork 2
705 lines (633 loc) · 27.5 KB
/
versioning.yml
File metadata and controls
705 lines (633 loc) · 27.5 KB
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
# This GitHub Actions workflow handles version bumping, pre-built firmware, releases, and tag updates.
#
# Triggered by merging a PR to the main branch, it automatically:
# 1. Bumps the CalVer version (YYYY.M.seq)
# 2. Calculates the minimum upstream version (current month minus 2, YYYY.M.0)
# 3. Resolves the "next" sentinel in min_blueprint_version, if set
# 4. Updates min_esphome_compiler_version and blueprint homeassistant.min_version
# 5. Updates the bug report template with current version placeholders
# 6. Updates the blueprint version and display name
# 7. Commits all version changes and pushes to main
# 8. Builds pre-built firmware binaries in parallel (nspanel-easy, wall-display)
# 9. Commits the compiled binaries, checksums, and manifests to main
# 10. Creates a version tag and GitHub Release
# 11. Updates the stable and latest floating tags
# 12. Announces the release on Discord
#
# The workflow skips execution if the merge commit message contains
# [skip-versioning] to prevent loops from its own version bump commits.
---
name: Version, Release & Tags
on: # yamllint disable-line rule:truthy
pull_request:
types:
- closed
branches:
- main
paths-ignore:
- 'versioning/version.yaml'
jobs:
# ---------------------------------------------------------------------------
# Bump version, update bug template, and push to main.
# All downstream jobs depend on this one completing successfully.
# ---------------------------------------------------------------------------
bump:
name: Bump version
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
concurrency:
group: version-and-release
cancel-in-progress: false
permissions:
contents: write
pull-requests: read
outputs:
skip: ${{ steps.skip_check.outputs.skip }}
version: ${{ steps.next_version.outputs.version }}
release_sha: ${{ steps.capture_sha.outputs.sha }}
pr_title: ${{ fromJson(steps.pr_info.outputs.result).title }}
pr_body: ${{ fromJson(steps.pr_info.outputs.result).body }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for skip marker
id: skip_check
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
if echo "$COMMIT_MESSAGE" | grep -q "\[skip-versioning\]"; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "Skipping workflow due to [skip-versioning] marker"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
# -------------------------------------------------------------------
# Version bump and file updates
# -------------------------------------------------------------------
- name: Set up Git
if: steps.skip_check.outputs.skip == 'false'
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Set up yq
if: steps.skip_check.outputs.skip == 'false'
uses: mikefarah/yq@v4.52.5
- name: Get PR information
id: pr_info
if: steps.skip_check.outputs.skip == 'false'
uses: actions/github-script@v8
with:
script: |
try {
const pr = context.payload.pull_request;
return {
title: pr.title,
body: pr.body || 'No description provided',
number: pr.number,
found: true
};
} catch (error) {
console.log('Could not get PR info:', error.message);
return {
title: 'Version update',
body: 'Automated version bump',
number: null,
found: false
};
}
- name: Fetch latest main and rebase
if: steps.skip_check.outputs.skip == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Rebase early so the version we read is up-to-date,
# avoiding duplicate versions when PRs merge in quick succession.
git fetch origin main
git rebase origin/main || {
echo "Rebase failed - main has diverged"
exit 1
}
- name: Calculate next version
id: next_version
if: steps.skip_check.outputs.skip == 'false'
run: |
# Read version AFTER rebase to avoid race conditions
CURRENT_VERSION=$(yq eval '.version' ./versioning/version.yaml)
if [[ -z "$CURRENT_VERSION" || "$CURRENT_VERSION" == "null" ]]; then
echo "Error: Could not read version from versioning/version.yaml"
exit 1
fi
# Validate the current version format (CalVer: YYYY.M.seq)
if ! [[ "$CURRENT_VERSION" =~ ^[0-9]{4}\.[0-9]{1,2}\.[0-9]+$ ]]; then
echo "Error: Invalid version format: $CURRENT_VERSION"
exit 1
fi
# Extract components
CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%-m) # No leading zero
CURRENT_SEQ=$(echo "$CURRENT_VERSION" | awk -F. '{print $3}')
VERSION_YEAR=$(echo "$CURRENT_VERSION" | awk -F. '{print $1}')
VERSION_MONTH=$(echo "$CURRENT_VERSION" | awk -F. '{print $2}')
# Increment sequence or reset for a new month
if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" \
&& "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then
NEXT_SEQ=$((CURRENT_SEQ + 1))
else
NEXT_SEQ=1
fi
NEXT_VERSION="${CURRENT_YEAR}.${CURRENT_MONTH}.${NEXT_SEQ}"
echo "version=${NEXT_VERSION}" >> "$GITHUB_OUTPUT"
echo "Bumping version: $CURRENT_VERSION -> $NEXT_VERSION"
- name: Calculate minimum upstream versions
id: min_upstream
if: steps.skip_check.outputs.skip == 'false'
run: |
# Minimum upstream version is always 2 months behind the current month,
# with patch fixed at 0 (e.g. April 2026 -> 2026.2.0, Jan 2026 -> 2025.11.0).
# This is the contract for the minimum ESPHome compiler and Home Assistant
# versions required to build and run NSPanel Easy.
CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%-m) # No leading zero
MIN_MONTH=$((CURRENT_MONTH - 2))
MIN_YEAR=$CURRENT_YEAR
if [[ $MIN_MONTH -le 0 ]]; then
MIN_MONTH=$((MIN_MONTH + 12))
MIN_YEAR=$((MIN_YEAR - 1))
fi
MIN_UPSTREAM_VERSION="${MIN_YEAR}.${MIN_MONTH}.0"
echo "version=${MIN_UPSTREAM_VERSION}" >> "$GITHUB_OUTPUT"
echo "Minimum upstream version: ${MIN_UPSTREAM_VERSION}"
- name: Update version.yaml file
if: steps.skip_check.outputs.skip == 'false'
env:
NEW_VERSION: ${{ steps.next_version.outputs.version }}
run: |
yq eval '.version = strenv(NEW_VERSION)' -i ./versioning/version.yaml
- name: Resolve min_blueprint_version sentinel and update upstream versions
if: steps.skip_check.outputs.skip == 'false'
env:
NEW_VERSION: ${{ steps.next_version.outputs.version }}
MIN_UPSTREAM_VERSION: ${{ steps.min_upstream.outputs.version }}
run: |
ESPHOME_VERSION_FILE="esphome/nspanel_esphome_version.yaml"
# sed is used intentionally here instead of yq — yq strips the !!merge
# tag from the !include line and removes blank lines, corrupting the file.
# If min_blueprint_version is set to the sentinel "next" or "${version}",
# replace it with the actual version being released, tying the compatibility
# requirement to this exact release.
if grep -qE '^ min_blueprint_version: (next|\$\{version\})$' "$ESPHOME_VERSION_FILE"; then
sed -i \
"s/^ min_blueprint_version: .*/ min_blueprint_version: ${NEW_VERSION}/" \
"$ESPHOME_VERSION_FILE"
if ! grep -q "^ min_blueprint_version: ${NEW_VERSION}$" "$ESPHOME_VERSION_FILE"; then
echo "ERROR: Failed to resolve min_blueprint_version sentinel in $ESPHOME_VERSION_FILE"
exit 1
fi
echo "Resolved min_blueprint_version sentinel to ${NEW_VERSION}"
else
MIN_BP=$(grep "^ min_blueprint_version:" "$ESPHOME_VERSION_FILE" | awk '{print $2}')
echo "min_blueprint_version is already set to ${MIN_BP}, no sentinel to resolve"
fi
# Always update the minimum ESPHome compiler version to 2 months ago,
# keeping the upstream contract in sync with the release date.
sed -i \
"s/^ min_esphome_compiler_version: .*/ min_esphome_compiler_version: ${MIN_UPSTREAM_VERSION}/" \
"$ESPHOME_VERSION_FILE"
if ! grep -q "^ min_esphome_compiler_version: ${MIN_UPSTREAM_VERSION}$" "$ESPHOME_VERSION_FILE"; then
echo "ERROR: Failed to update min_esphome_compiler_version in $ESPHOME_VERSION_FILE"
exit 1
fi
echo "Updated min_esphome_compiler_version to ${MIN_UPSTREAM_VERSION}"
- name: Extract cross-component version information
id: versions
if: steps.skip_check.outputs.skip == 'false'
run: |
VERSION=$(yq eval '.version' ./versioning/version.yaml)
MIN_BLUEPRINT_VERSION=$(yq eval \
'.substitutions.min_blueprint_version' \
esphome/nspanel_esphome_version.yaml)
MIN_TFT_VERSION=$(yq eval \
'.substitutions.min_tft_version' \
esphome/nspanel_esphome_version.yaml)
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "min_blueprint_version=${MIN_BLUEPRINT_VERSION}" >> "$GITHUB_OUTPUT"
echo "min_tft_version=${MIN_TFT_VERSION}" >> "$GITHUB_OUTPUT"
- name: Update bug report template with current versions
if: steps.skip_check.outputs.skip == 'false'
env:
VERSION: ${{ steps.versions.outputs.version }}
MIN_BLUEPRINT_VERSION: ${{ steps.versions.outputs.min_blueprint_version }}
MIN_TFT_VERSION: ${{ steps.versions.outputs.min_tft_version }}
run: |
# Use label-anchored Python script to avoid fragile body index references.
python3 .github/scripts/update_bug_template.py \
.github/ISSUE_TEMPLATE/bug.yml \
"$MIN_TFT_VERSION" \
"$VERSION" \
"$MIN_BLUEPRINT_VERSION"
- name: Update blueprint version and name
if: steps.skip_check.outputs.skip == 'false'
env:
NEW_VERSION: ${{ steps.next_version.outputs.version }}
MIN_UPSTREAM_VERSION: ${{ steps.min_upstream.outputs.version }}
run: |
BLUEPRINT="nspanel_easy_blueprint.yaml"
# sed is used intentionally here instead of yq — the blueprint contains
# a large icon table with unicode escape sequences (\uXXXX) that yq would
# silently convert to their literal UTF-8 characters, corrupting the file.
# Update the blueprint display name shown in the HA Blueprints dashboard.
sed -i \
"s/^ name: NSPanel Easy Configuration.*/ name: NSPanel Easy Configuration (v${NEW_VERSION})/" \
"$BLUEPRINT"
if ! grep -q "^ name: NSPanel Easy Configuration (v${NEW_VERSION})" "$BLUEPRINT"; then
echo "ERROR: Failed to update blueprint display name in $BLUEPRINT"
exit 1
fi
# Update the blueprint's own version number, used by ESPHome to verify
# compatibility against min_blueprint_version at runtime.
sed -i \
"s/^ blueprint_version: .*/ blueprint_version: ${NEW_VERSION}/" \
"$BLUEPRINT"
if ! grep -q "^ blueprint_version: ${NEW_VERSION}$" "$BLUEPRINT"; then
echo "ERROR: Failed to update blueprint_version in $BLUEPRINT"
exit 1
fi
# Update the minimum Home Assistant version required to run this blueprint,
# kept 2 months behind the release date to match the upstream contract.
sed -i \
"s/^ min_version: .*/ min_version: ${MIN_UPSTREAM_VERSION}/" \
"$BLUEPRINT"
if ! grep -q "^ min_version: ${MIN_UPSTREAM_VERSION}$" "$BLUEPRINT"; then
echo "ERROR: Failed to update min_version in $BLUEPRINT"
exit 1
fi
- name: Restore YAML document end markers
if: steps.skip_check.outputs.skip == 'false'
run: |
# yq strips the YAML document end marker (...) on in-place edits.
# Re-append it to all files modified by yq.
for file in ./versioning/version.yaml; do
if [ -f "$file" ] && ! tail -1 "$file" | grep -qx '\.\.\.'; then
echo '...' >> "$file"
fi
done
- name: Commit version and template changes
if: steps.skip_check.outputs.skip == 'false'
env:
NEW_VERSION: ${{ steps.next_version.outputs.version }}
run: |
git add ./versioning/version.yaml .github/ISSUE_TEMPLATE/bug.yml \
esphome/nspanel_esphome_version.yaml nspanel_easy_blueprint.yaml
git commit -m "Bump version to ${NEW_VERSION} [skip-versioning]"
- name: Push changes to main
if: steps.skip_check.outputs.skip == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Rebase in case main advanced during workflow execution
git fetch origin main
git rebase origin/main || {
echo "Rebase failed - main has diverged"
exit 1
}
git push origin HEAD:main
- name: Capture post-bump SHA
id: capture_sha
if: steps.skip_check.outputs.skip == 'false'
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
# ---------------------------------------------------------------------------
# Build pre-built firmware: nspanel-easy
# Runs in parallel with build-wall-display once bump completes.
# ---------------------------------------------------------------------------
build-nspanel:
name: Build pre-built (nspanel-easy)
needs: bump
if: needs.bump.outputs.skip == 'false'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout post-bump main
uses: actions/checkout@v6
with:
ref: ${{ needs.bump.outputs.release_sha }}
fetch-depth: 1
- name: Build firmware
uses: edwardtfn/build-action@add-substitutions-support
with:
yaml-file: prebuilt/nspanel_esphome_prebuilt.yaml
substitutions: |
ref_name=${{ needs.bump.outputs.release_sha }}
ref_url=https://github.com/edwardtfn/NSPanel-Easy
- name: Locate compiled binaries
id: locate
run: |
BIN=$(find prebuilt/.esphome/build -name "firmware.bin" | head -1)
BIN_FACTORY=$(find prebuilt/.esphome/build -name "firmware-factory.bin" | head -1)
if [ -z "$BIN" ]; then
echo "ERROR: firmware.bin not found after build"
echo "Build directory contents:"
find prebuilt/.esphome/build -type f 2>/dev/null || echo "Build directory does not exist"
exit 1
fi
echo "bin=${BIN}" >> "$GITHUB_OUTPUT"
echo "bin_factory=${BIN_FACTORY}" >> "$GITHUB_OUTPUT"
- name: Copy artifacts to staging directory
env:
BIN: ${{ steps.locate.outputs.bin }}
BIN_FACTORY: ${{ steps.locate.outputs.bin_factory }}
run: |
mkdir -p staging
cp "$BIN" staging/nspanel_esphome_prebuilt.bin
if [ -n "$BIN_FACTORY" ]; then
cp "$BIN_FACTORY" staging/nspanel_esphome_prebuilt-factory.bin
fi
- name: Generate checksums
run: |
md5sum staging/nspanel_esphome_prebuilt.bin \
| awk '{print $1}' > staging/nspanel_esphome_prebuilt.bin.md5
if [ -f staging/nspanel_esphome_prebuilt-factory.bin ]; then
md5sum staging/nspanel_esphome_prebuilt-factory.bin \
| awk '{print $1}' > staging/nspanel_esphome_prebuilt-factory.bin.md5
fi
- name: Generate update manifest
env:
NEW_VERSION: ${{ needs.bump.outputs.version }}
run: |
MD5=$(cat staging/nspanel_esphome_prebuilt.bin.md5)
jq -n \
--arg name "NSPanel Easy Pre-built" \
--arg version "$NEW_VERSION" \
--arg path "nspanel_esphome_prebuilt.bin" \
--arg md5 "$MD5" \
--arg summary "NSPanel Easy Pre-built v${NEW_VERSION}" \
--arg url "https://github.com/edwardtfn/NSPanel-Easy/releases/tag/v${NEW_VERSION}" \
'{
name: $name,
version: $version,
home_assistant_domain: "esphome",
new_install_prompt_erase: false,
builds: [{
chipFamily: "ESP32",
ota: {path: $path, md5: $md5, summary: $summary, release_url: $url}
}]
}' > staging/nspanel_esphome_prebuilt.manifest.json
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: prebuilt-nspanel
path: staging/
retention-days: 1
# ---------------------------------------------------------------------------
# Build pre-built firmware: wall-display
# Runs in parallel with build-nspanel once bump completes.
# ---------------------------------------------------------------------------
build-wall-display:
name: Build pre-built (wall-display)
needs: bump
if: needs.bump.outputs.skip == 'false'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout post-bump main
uses: actions/checkout@v6
with:
ref: ${{ needs.bump.outputs.release_sha }}
fetch-depth: 1
- name: Build firmware
uses: edwardtfn/build-action@add-substitutions-support
with:
yaml-file: prebuilt/wall_display.yaml
substitutions: |
ref_name=${{ needs.bump.outputs.release_sha }}
ref_url=https://github.com/edwardtfn/NSPanel-Easy
- name: Locate compiled binaries
id: locate
run: |
BIN=$(find prebuilt/.esphome/build -name "firmware.bin" | head -1)
BIN_FACTORY=$(find prebuilt/.esphome/build -name "firmware-factory.bin" | head -1)
if [ -z "$BIN" ]; then
echo "ERROR: firmware.bin not found after build"
echo "Build directory contents:"
find prebuilt/.esphome/build -type f 2>/dev/null || echo "Build directory does not exist"
exit 1
fi
echo "bin=${BIN}" >> "$GITHUB_OUTPUT"
echo "bin_factory=${BIN_FACTORY}" >> "$GITHUB_OUTPUT"
- name: Copy artifacts to staging directory
env:
BIN: ${{ steps.locate.outputs.bin }}
BIN_FACTORY: ${{ steps.locate.outputs.bin_factory }}
run: |
mkdir -p staging
cp "$BIN" staging/wall_display.bin
if [ -n "$BIN_FACTORY" ]; then
cp "$BIN_FACTORY" staging/wall_display-factory.bin
fi
- name: Generate checksums
run: |
md5sum staging/wall_display.bin \
| awk '{print $1}' > staging/wall_display.bin.md5
if [ -f staging/wall_display-factory.bin ]; then
md5sum staging/wall_display-factory.bin \
| awk '{print $1}' > staging/wall_display-factory.bin.md5
fi
- name: Generate update manifest
env:
NEW_VERSION: ${{ needs.bump.outputs.version }}
run: |
MD5=$(cat staging/wall_display.bin.md5)
jq -n \
--arg name "NSPanel Easy - Wall Display" \
--arg version "$NEW_VERSION" \
--arg path "wall_display.bin" \
--arg md5 "$MD5" \
--arg summary "NSPanel Easy Wall Display v${NEW_VERSION}" \
--arg url "https://github.com/edwardtfn/NSPanel-Easy/releases/tag/v${NEW_VERSION}" \
'{
name: $name,
version: $version,
home_assistant_domain: "esphome",
new_install_prompt_erase: false,
builds: [{
chipFamily: "ESP32",
ota: {path: $path, md5: $md5, summary: $summary, release_url: $url}
}]
}' > staging/wall_display.manifest.json
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: prebuilt-wall-display
path: staging/
retention-days: 1
# ---------------------------------------------------------------------------
# Collect both firmware artifacts, commit to main, tag, and release.
# Runs only after both build jobs succeed.
# ---------------------------------------------------------------------------
commit-and-release:
name: Commit artifacts & release
needs: [bump, build-nspanel, build-wall-display]
if: needs.bump.outputs.skip == 'false'
runs-on: ubuntu-latest
concurrency:
group: version-and-release
cancel-in-progress: false
permissions:
contents: write
outputs:
released: ${{ steps.push_tag.outcome == 'success' }}
version: ${{ needs.bump.outputs.version }}
release_url: ${{ steps.create_release.outputs.url }}
steps:
- name: Checkout post-bump main
uses: actions/checkout@v6
with:
ref: ${{ needs.bump.outputs.release_sha }}
fetch-depth: 0
- name: Set up Git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
- name: Remove previously committed generated artifacts
run: |
# Remove all known generated files so stale artifacts from a previous
# release (e.g. factory binaries) are not silently carried forward.
rm -f \
prebuilt/nspanel_esphome_prebuilt.bin \
prebuilt/nspanel_esphome_prebuilt.bin.md5 \
prebuilt/nspanel_esphome_prebuilt.manifest.json \
prebuilt/nspanel_esphome_prebuilt-factory.bin \
prebuilt/nspanel_esphome_prebuilt-factory.bin.md5 \
prebuilt/wall_display.bin \
prebuilt/wall_display.bin.md5 \
prebuilt/wall_display.manifest.json \
prebuilt/wall_display-factory.bin \
prebuilt/wall_display-factory.bin.md5
- name: Download nspanel-easy artifacts
uses: actions/download-artifact@v8
with:
name: prebuilt-nspanel
path: prebuilt/
- name: Download wall-display artifacts
uses: actions/download-artifact@v8
with:
name: prebuilt-wall-display
path: prebuilt/
- name: Verify pre-built artifacts
run: |
# Check all required files exist and are non-empty (-s: exists and size > 0).
# Factory binaries are optional and excluded from this check.
ok=true
for f in \
prebuilt/nspanel_esphome_prebuilt.bin \
prebuilt/nspanel_esphome_prebuilt.bin.md5 \
prebuilt/nspanel_esphome_prebuilt.manifest.json \
prebuilt/wall_display.bin \
prebuilt/wall_display.bin.md5 \
prebuilt/wall_display.manifest.json; do
if [ ! -s "$f" ]; then
echo "ERROR: missing or empty file: $f"
ok=false
else
echo "OK: $f ($(wc -c < "$f") bytes)"
fi
done
[ "$ok" = true ] || exit 1
- name: Commit pre-built artifacts
env:
NEW_VERSION: ${{ needs.bump.outputs.version }}
run: |
# Stage all changes under prebuilt/ including deletions of stale files.
git add -A prebuilt/
git diff --cached --quiet || \
git commit -m "build: pre-built firmware for v${NEW_VERSION} [skip-versioning]"
- name: Push artifacts to main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Push directly — no rebase. If main has advanced since the bump job
# pushed, abort rather than silently tagging the wrong revision.
git push origin HEAD:main || {
echo "ERROR: main has advanced since artifacts were built; aborting to avoid tagging the wrong revision"
exit 1
}
# -------------------------------------------------------------------
# Tag and release (after binary commit, so tag points to final state)
# -------------------------------------------------------------------
- name: Build tag message from PR
env:
NEW_VERSION: ${{ needs.bump.outputs.version }}
PR_TITLE: ${{ needs.bump.outputs.pr_title }}
PR_BODY: ${{ needs.bump.outputs.pr_body }}
run: |
{
printf '# v%s - %s\n\n' "$NEW_VERSION" "$PR_TITLE"
printf '%s\n' "$PR_BODY"
} > tag_message.txt
- name: Create and push version tag
id: push_tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_VERSION: ${{ needs.bump.outputs.version }}
run: |
git tag -a "v${NEW_VERSION}" -F tag_message.txt
git push origin "v${NEW_VERSION}"
- name: Create GitHub Release
id: create_release
if: steps.push_tag.outcome == 'success'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.bump.outputs.version }}
name: v${{ needs.bump.outputs.version }} - ${{ needs.bump.outputs.pr_title }}
generate_release_notes: true
# -------------------------------------------------------------------
# Update floating tags (stable & latest)
# -------------------------------------------------------------------
- name: Update stable tag
if: steps.push_tag.outcome == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if git rev-parse --verify stable >/dev/null 2>&1; then
echo "Previous stable: $(git rev-parse stable)"
fi
git tag -fa stable -F tag_message.txt
git push origin stable --force
- name: Update latest tag
if: steps.push_tag.outcome == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if git rev-parse --verify latest >/dev/null 2>&1; then
echo "Previous latest: $(git rev-parse latest)"
fi
git tag -fa latest -F tag_message.txt
git push origin latest --force
# ---------------------------------------------------------------------------
# Announce the new release on Discord.
# Always runs last — only when a release was actually published.
# ---------------------------------------------------------------------------
notify-discord:
name: Notify Discord
needs: [commit-and-release]
if: needs.commit-and-release.outputs.released == 'true'
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Send release message to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_CH_GENERAL_WEBHOOK }}
RELEASE_TAG: v${{ needs.commit-and-release.outputs.version }}
RELEASE_URL: ${{ needs.commit-and-release.outputs.release_url }}
run: |
MESSAGE="🚀 New NSPanel Easy release published
${RELEASE_TAG}
${RELEASE_URL}"
jq -n --arg content "$MESSAGE" '{content: $content}' \
| curl --fail-with-body \
-H "Content-Type: application/json" \
-d @- \
"$DISCORD_WEBHOOK"
...