|
2 | 2 | # Build FPP SD card images for Pi, Pi64, BBB, and BB64. |
3 | 3 | # |
4 | 4 | # 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. |
6 | 12 | # - schedule: nightly at 04:00 UTC |
7 | 13 | # - push (release tag): release build (major version >= 10 only); results are |
8 | 14 | # attached to a GitHub release named from the tag. Tags |
|
24 | 30 | workflow_dispatch: |
25 | 31 | inputs: |
26 | 32 | 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)' |
28 | 34 | required: false |
29 | 35 | default: '' |
30 | 36 | 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 |
32 | 39 | 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 |
34 | 59 | schedule: |
35 | 60 | - cron: '0 4 * * *' |
36 | 61 | push: |
@@ -76,6 +101,19 @@ jobs: |
76 | 101 | V="${GITHUB_REF#refs/tags/}" |
77 | 102 | echo "is_release=true" >> "$GITHUB_OUTPUT" |
78 | 103 | 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" |
79 | 117 | # Manual dispatch with explicit version -> one-off build |
80 | 118 | elif [ -n "${{ github.event.inputs.version }}" ]; then |
81 | 119 | V="${{ github.event.inputs.version }}" |
@@ -129,7 +167,7 @@ jobs: |
129 | 167 | id: gate |
130 | 168 | run: | |
131 | 169 | REQ="${{ github.event.inputs.platforms }}" |
132 | | - if [ -n "$REQ" ]; then |
| 170 | + if [ -n "$REQ" ] && [ "$REQ" != "all" ]; then |
133 | 171 | case ",$REQ," in |
134 | 172 | *",${{ matrix.platform }},"*) echo "skip=false" >> "$GITHUB_OUTPUT" ;; |
135 | 173 | *) echo "skip=true" >> "$GITHUB_OUTPUT" ;; |
@@ -319,14 +357,55 @@ jobs: |
319 | 357 | ls -la release-files/ |
320 | 358 |
|
321 | 359 | - 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' |
322 | 364 | uses: softprops/action-gh-release@v2 |
323 | 365 | with: |
324 | 366 | draft: true |
325 | 367 | name: "FPP ${{ needs.prep.outputs.version }}" |
326 | | - tag_name: ${{ github.ref_name }} |
| 368 | + tag_name: ${{ needs.prep.outputs.version }} |
327 | 369 | files: release-files/* |
328 | 370 | fail_on_unmatched_files: true |
329 | 371 |
|
| 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 | +
|
330 | 409 | nightly_release: |
331 | 410 | # Runs on schedule + schedule-like manual dispatch. Publishes / replaces |
332 | 411 | # the "nightly" pre-release so URLs like |
|
0 commit comments