22#
33# Triggered by merging a PR to the main branch, it automatically:
44# 1. Bumps the CalVer version (YYYY.M.seq)
5- # 2. Updates the bug report template with current version placeholders
6- # 3. Commits the changes and pushes to main
7- # 4. Creates a version tag and GitHub Release
8- # 5. Updates the stable and latest floating tags
9- # 6. Announces the release on Discord
5+ # 2. Calculates the minimum upstream version (current month minus 2, YYYY.M.0)
6+ # 3. Resolves the "next" sentinel in min_blueprint_version, if set
7+ # 4. Updates min_esphome_compiler_version and blueprint homeassistant.min_version
8+ # 5. Updates the bug report template with current version placeholders
9+ # 6. Updates the blueprint version and display name
10+ # 7. Commits the changes and pushes to main
11+ # 8. Creates a version tag and GitHub Release
12+ # 9. Updates the stable and latest floating tags
13+ # 10. Announces the release on Discord
1014#
1115# The workflow skips execution if the merge commit message contains
1216# [skip-versioning] to prevent loops from its own version bump commits.
@@ -144,13 +148,63 @@ jobs:
144148 echo "version=${NEXT_VERSION}" >> "$GITHUB_OUTPUT"
145149 echo "Bumping version: $CURRENT_VERSION -> $NEXT_VERSION"
146150
151+ - name : Calculate minimum upstream versions
152+ id : min_upstream
153+ if : steps.skip_check.outputs.skip == 'false'
154+ run : |
155+ # Minimum upstream version is always 2 months behind the current month,
156+ # with patch fixed at 0 (e.g. April 2026 -> 2026.2.0, Jan 2026 -> 2025.11.0).
157+ # This is the contract for the minimum ESPHome compiler and Home Assistant
158+ # versions required to build and run NSPanel Easy.
159+ CURRENT_YEAR=$(date +%Y)
160+ CURRENT_MONTH=$(date +%-m) # No leading zero
161+
162+ MIN_MONTH=$((CURRENT_MONTH - 2))
163+ MIN_YEAR=$CURRENT_YEAR
164+ if [[ $MIN_MONTH -le 0 ]]; then
165+ MIN_MONTH=$((MIN_MONTH + 12))
166+ MIN_YEAR=$((MIN_YEAR - 1))
167+ fi
168+
169+ MIN_UPSTREAM_VERSION="${MIN_YEAR}.${MIN_MONTH}.0"
170+ echo "version=${MIN_UPSTREAM_VERSION}" >> "$GITHUB_OUTPUT"
171+ echo "Minimum upstream version: ${MIN_UPSTREAM_VERSION}"
172+
147173 - name : Update version.yaml file
148174 if : steps.skip_check.outputs.skip == 'false'
149175 env :
150176 NEW_VERSION : ${{ steps.next_version.outputs.version }}
151177 run : |
152178 yq eval '.version = strenv(NEW_VERSION)' -i ./versioning/version.yaml
153179
180+ - name : Resolve min_blueprint_version sentinel and update upstream versions
181+ if : steps.skip_check.outputs.skip == 'false'
182+ env :
183+ NEW_VERSION : ${{ steps.next_version.outputs.version }}
184+ MIN_UPSTREAM_VERSION : ${{ steps.min_upstream.outputs.version }}
185+ run : |
186+ ESPHOME_VERSION_FILE="esphome/nspanel_esphome_version.yaml"
187+ MIN_BP=$(yq eval '.substitutions.min_blueprint_version' "$ESPHOME_VERSION_FILE")
188+
189+ # If min_blueprint_version is set to the sentinel "next", replace it
190+ # with the actual version being released, tying the compatibility
191+ # requirement to this exact release.
192+ if [[ "$MIN_BP" == "next" || "$MIN_BP" == '${version}' ]]; then
193+ yq eval \
194+ '.substitutions.min_blueprint_version = strenv(NEW_VERSION)' \
195+ -i "$ESPHOME_VERSION_FILE"
196+ echo "Resolved min_blueprint_version sentinel to ${NEW_VERSION}"
197+ else
198+ echo "min_blueprint_version is already set to ${MIN_BP}, no sentinel to resolve"
199+ fi
200+
201+ # Always update the minimum ESPHome compiler version to 2 months ago,
202+ # keeping the upstream contract in sync with the release date.
203+ yq eval \
204+ '.substitutions.min_esphome_compiler_version = strenv(MIN_UPSTREAM_VERSION)' \
205+ -i "$ESPHOME_VERSION_FILE"
206+ echo "Updated min_esphome_compiler_version to ${MIN_UPSTREAM_VERSION}"
207+
154208 - name : Extract cross-component version information
155209 id : versions
156210 if : steps.skip_check.outputs.skip == 'false'
@@ -191,12 +245,42 @@ jobs:
191245 '.body[4].attributes.placeholder = ("e.g., " + strenv(MIN_BLUEPRINT_VERSION))' \
192246 -i "$TEMPLATE"
193247
248+ - name : Update blueprint version and name
249+ if : steps.skip_check.outputs.skip == 'false'
250+ env :
251+ NEW_VERSION : ${{ steps.next_version.outputs.version }}
252+ MIN_UPSTREAM_VERSION : ${{ steps.min_upstream.outputs.version }}
253+ run : |
254+ BLUEPRINT="nspanel_easy_blueprint.yaml"
255+
256+ # sed is used intentionally here instead of yq — the blueprint contains
257+ # a large icon table with unicode escape sequences (\uXXXX) that yq would
258+ # silently convert to their literal UTF-8 characters, corrupting the file.
259+
260+ # Update the blueprint display name shown in the HA Blueprints dashboard.
261+ sed -i \
262+ "s/^ name: NSPanel Easy Configuration.*/ name: NSPanel Easy Configuration (v${NEW_VERSION})/" \
263+ "$BLUEPRINT"
264+
265+ # Update the blueprint's own version number, used by ESPHome to verify
266+ # compatibility against min_blueprint_version at runtime.
267+ sed -i \
268+ "s/^ blueprint_version: .*/ blueprint_version: ${NEW_VERSION}/" \
269+ "$BLUEPRINT"
270+
271+ # Update the minimum Home Assistant version required to run this blueprint,
272+ # kept 2 months behind the release date to match the upstream contract.
273+ sed -i \
274+ "s/^ min_version: .*/ min_version: ${MIN_UPSTREAM_VERSION}/" \
275+ "$BLUEPRINT"
276+
194277 - name : Restore YAML document end markers
195278 if : steps.skip_check.outputs.skip == 'false'
196279 run : |
197280 # yq strips the YAML document end marker (...) on in-place edits.
198281 # Re-append it to all files modified by yq.
199- for file in ./versioning/version.yaml .github/ISSUE_TEMPLATE/bug.yml; do
282+ for file in ./versioning/version.yaml .github/ISSUE_TEMPLATE/bug.yml \
283+ esphome/nspanel_esphome_version.yaml; do
200284 if [ -f "$file" ] && ! tail -1 "$file" | grep -qx '\.\.\.'; then
201285 echo '...' >> "$file"
202286 fi
@@ -211,7 +295,8 @@ jobs:
211295 env :
212296 NEW_VERSION : ${{ steps.next_version.outputs.version }}
213297 run : |
214- git add ./versioning/version.yaml .github/ISSUE_TEMPLATE/bug.yml
298+ git add ./versioning/version.yaml .github/ISSUE_TEMPLATE/bug.yml \
299+ esphome/nspanel_esphome_version.yaml nspanel_easy_blueprint.yaml
215300 git commit -m "Bump version to ${NEW_VERSION} [skip-versioning]"
216301
217302 - name : Build tag message from PR
0 commit comments