Skip to content

Commit 85b1e41

Browse files
committed
fix(release): correct version detection + workflow changes
1 parent 71b217e commit 85b1e41

2 files changed

Lines changed: 86 additions & 7 deletions

File tree

.github/workflows/build-images.yml

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
# Build FPP SD card images for Pi, Pi64, BBB, and BB64.
33
#
44
# Runs:
5-
# - workflow_dispatch: manual trigger with optional version string
5+
# - workflow_dispatch: manual trigger. Pick the branch/tag to build from the
6+
# "Use workflow from" dropdown. Options: build a subset
7+
# of platforms (for quickly testing this workflow), and
8+
# optionally check "make_release" to create/update a
9+
# release for that ref (name = ref, "v" prefix stripped)
10+
# -- add "overwrite_existing" to replace an existing
11+
# release's assets in place instead of failing.
612
# - schedule: nightly at 04:00 UTC
713
# - push (release tag): release build (major version >= 10 only); results are
814
# attached to a GitHub release named from the tag. Tags
@@ -24,13 +30,32 @@ on:
2430
workflow_dispatch:
2531
inputs:
2632
version:
27-
description: 'FPP version string (blank = nightly-YYYYMMDD)'
33+
description: 'One-off build version string (ignored if "Create/update a release" is checked; blank = nightly-YYYYMMDD)'
2834
required: false
2935
default: ''
3036
platforms:
31-
description: 'Comma-separated subset of platforms to build (blank = all)'
37+
description: 'Platforms to build (use a subset to test this workflow quickly)'
38+
type: choice
3239
required: false
33-
default: ''
40+
default: 'all'
41+
options:
42+
- 'all'
43+
- 'pi'
44+
- 'pi64'
45+
- 'bb64'
46+
- 'bbb'
47+
- 'pi,pi64'
48+
- 'bb64,bbb'
49+
make_release:
50+
description: 'Create/update a release from the branch or tag picked above ("Use workflow from"). Release name always matches that ref (leading "v" stripped).'
51+
type: boolean
52+
required: false
53+
default: false
54+
overwrite_existing:
55+
description: 'If a release already exists for that ref, replace its assets in place instead of failing'
56+
type: boolean
57+
required: false
58+
default: false
3459
schedule:
3560
- cron: '0 4 * * *'
3661
push:
@@ -76,6 +101,19 @@ jobs:
76101
V="${GITHUB_REF#refs/tags/}"
77102
echo "is_release=true" >> "$GITHUB_OUTPUT"
78103
echo "is_nightly=false" >> "$GITHUB_OUTPUT"
104+
# Manual dispatch, "make_release" checked -> release build from
105+
# whatever branch/tag was picked in the "Use workflow from" dropdown.
106+
# The release name always matches that ref (never the free-typed
107+
# "version" input), same as the tag-push path above; a leading "v"
108+
# is stripped since branches follow "vX.Y" but tags/releases/
109+
# fppversion.sh all use the bare "X.Y" form (see header comment).
110+
elif [ "${{ github.event.inputs.make_release }}" = "true" ]; then
111+
V="${{ github.ref_name }}"
112+
case "$V" in
113+
v[0-9]*) V="${V#v}" ;;
114+
esac
115+
echo "is_release=true" >> "$GITHUB_OUTPUT"
116+
echo "is_nightly=false" >> "$GITHUB_OUTPUT"
79117
# Manual dispatch with explicit version -> one-off build
80118
elif [ -n "${{ github.event.inputs.version }}" ]; then
81119
V="${{ github.event.inputs.version }}"
@@ -129,7 +167,7 @@ jobs:
129167
id: gate
130168
run: |
131169
REQ="${{ github.event.inputs.platforms }}"
132-
if [ -n "$REQ" ]; then
170+
if [ -n "$REQ" ] && [ "$REQ" != "all" ]; then
133171
case ",$REQ," in
134172
*",${{ matrix.platform }},"*) echo "skip=false" >> "$GITHUB_OUTPUT" ;;
135173
*) echo "skip=true" >> "$GITHUB_OUTPUT" ;;
@@ -319,14 +357,55 @@ jobs:
319357
ls -la release-files/
320358
321359
- name: Create draft release
360+
# Skipped for manual "overwrite_existing" runs: this step always
361+
# creates fresh, so it would fail with "already_exists" whenever the
362+
# release we're meant to be replacing assets on is already there.
363+
if: github.event.inputs.overwrite_existing != 'true'
322364
uses: softprops/action-gh-release@v2
323365
with:
324366
draft: true
325367
name: "FPP ${{ needs.prep.outputs.version }}"
326-
tag_name: ${{ github.ref_name }}
368+
tag_name: ${{ needs.prep.outputs.version }}
327369
files: release-files/*
328370
fail_on_unmatched_files: true
329371

372+
- name: Create or update release (overwrite existing assets)
373+
# Manual-dispatch-only path (overwrite_existing is only ever set via
374+
# workflow_dispatch inputs; a tag push leaves it unset/false). Moves
375+
# the release's tag to the commit that was just built -- needed when
376+
# re-releasing from a branch dropdown pick rather than a fresh tag
377+
# push -- then upserts the release and replaces its assets in place,
378+
# mirroring the nightly_release job's non-destructive pattern.
379+
if: github.event.inputs.overwrite_existing == 'true'
380+
env:
381+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
382+
GH_REPO: ${{ github.repository }}
383+
run: |
384+
set -euo pipefail
385+
TAG="${{ needs.prep.outputs.version }}"
386+
TITLE="FPP ${{ needs.prep.outputs.version }}"
387+
388+
if gh api "repos/${{ github.repository }}/git/refs/tags/$TAG" >/dev/null 2>&1; then
389+
echo "Moving '$TAG' tag to ${{ github.sha }}..."
390+
gh api -X PATCH "repos/${{ github.repository }}/git/refs/tags/$TAG" \
391+
-f sha="${{ github.sha }}" -F force=true >/dev/null
392+
else
393+
echo "Creating '$TAG' tag at ${{ github.sha }}..."
394+
gh api -X POST "repos/${{ github.repository }}/git/refs" \
395+
-f ref="refs/tags/$TAG" -f sha="${{ github.sha }}" >/dev/null
396+
fi
397+
398+
if gh release view "$TAG" >/dev/null 2>&1; then
399+
echo "Release '$TAG' already exists; replacing its assets in place."
400+
gh release upload "$TAG" release-files/* --clobber
401+
else
402+
echo "No existing release for '$TAG'; creating a new draft."
403+
gh release create "$TAG" release-files/* \
404+
--draft \
405+
--title "$TITLE" \
406+
--verify-tag
407+
fi
408+
330409
nightly_release:
331410
# Runs on schedule + schedule-like manual dispatch. Publishes / replaces
332411
# the "nightly" pre-release so URLs like

src/fppversion.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ GITREPOPATH="exported"
3131
cd ${GITTREEDIR}
3232

3333
git status > /dev/null 2>&1
34-
SOURCE_VERSION=$(git describe --dirty || git describe || echo Unknown)
34+
SOURCE_VERSION=$(git describe --tags --dirty || git describe --tags || echo Unknown)
3535
MAJOR_VERSION=$(echo ${SOURCE_VERSION} | cut -f1 -d\.)
3636
MINOR_VERSION=$(echo ${SOURCE_VERSION} | cut -f1 -d- | cut -f2 -d\.)
3737
PATCH_VERSION=$(echo ${SOURCE_VERSION} | cut -f1 -d- | cut -f3 -d\.)

0 commit comments

Comments
 (0)