Skip to content

Commit d2dfa31

Browse files
committed
ci: copy latest archives when overwriting a version release
The 12.2.0 overwrite job failed at checkout because PAT_TOKEN was empty. Use GITHUB_TOKEN as fallback, keep the existing GitHub Release, and replace same-named archives with current latest assets.
1 parent 4cd4a83 commit d2dfa31

1 file changed

Lines changed: 41 additions & 6 deletions

File tree

‎.github/workflows/release-openframeworks.yml‎

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
required: true
99
type: string
1010
overwrite_existing:
11-
description: "Move an existing version tag to latest and rebuild its release"
11+
description: "Move an existing version tag to latest and replace its archives with current latest zips. Keeps the GitHub Release; same filenames are overwritten in place."
1212
required: true
1313
default: false
1414
type: boolean
@@ -29,9 +29,9 @@ jobs:
2929
with:
3030
fetch-depth: 0
3131
ref: latest
32-
# A PAT is required: pushes made with GITHUB_TOKEN do not start the
33-
# existing build-* workflows that upload the platform release assets.
34-
token: ${{ secrets.PAT_TOKEN }}
32+
# Prefer PAT so a tag push can start build-* workflows. GITHUB_TOKEN
33+
# is enough to move the tag and replace release archives.
34+
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
3535

3636
- name: Validate and resolve version
3737
id: release
@@ -85,7 +85,7 @@ jobs:
8585
8686
- name: Create GitHub Release
8787
env:
88-
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
88+
GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
8989
RELEASE_TAG: ${{ steps.release.outputs.tag }}
9090
RELEASE_VERSION: ${{ steps.release.outputs.version }}
9191
SOURCE_SHA: ${{ steps.release.outputs.sha }}
@@ -102,14 +102,49 @@ jobs:
102102
--notes "$notes"
103103
fi
104104
105+
- name: Replace archives from latest
106+
if: ${{ inputs.overwrite_existing }}
107+
env:
108+
GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
109+
RELEASE_TAG: ${{ steps.release.outputs.tag }}
110+
run: |
111+
set -euo pipefail
112+
mkdir -p latest-assets renamed
113+
gh release download latest --dir latest-assets --pattern 'openFrameworksLibs_latest_*'
114+
gh release download latest --dir latest-assets --pattern 'vs2019-*' || true
115+
shopt -s nullglob
116+
count=0
117+
for src in latest-assets/*; do
118+
base="$(basename "$src")"
119+
dest="${base//openFrameworksLibs_latest_/openFrameworksLibs_${RELEASE_TAG}_}"
120+
if [[ "$dest" == *.manifest.json ]]; then
121+
sed "s/openFrameworksLibs_latest_/openFrameworksLibs_${RELEASE_TAG}_/g" "$src" > "renamed/$dest"
122+
else
123+
mv "$src" "renamed/$dest"
124+
fi
125+
count=$((count + 1))
126+
done
127+
if [[ "$count" -eq 0 ]]; then
128+
echo "No latest archives found to copy onto ${RELEASE_TAG}." >&2
129+
exit 1
130+
fi
131+
gh release upload "$RELEASE_TAG" renamed/* --clobber
132+
echo "Uploaded ${count} archives from latest onto ${RELEASE_TAG}."
133+
105134
- name: Summary
106135
env:
107136
RELEASE_TAG: ${{ steps.release.outputs.tag }}
108137
SOURCE_SHA: ${{ steps.release.outputs.sha }}
138+
OVERWRITE_EXISTING: ${{ inputs.overwrite_existing }}
109139
run: |
110140
{
111141
echo "## Release started"
112142
echo
113143
echo "Created \`${RELEASE_TAG}\` from \`latest\` at \`${SOURCE_SHA}\`."
114-
echo "The tag push started the enabled platform build workflows; each successful build uploads its archive to this release."
144+
if [[ "${OVERWRITE_EXISTING}" == "true" ]]; then
145+
echo "Existing GitHub Release was kept. Archives were replaced with current \`latest\` assets of the same name."
146+
echo "A PAT_TOKEN tag push may also start platform rebuilds; GITHUB_TOKEN alone does not."
147+
else
148+
echo "The tag push starts platform build workflows when PAT_TOKEN is configured; each successful build uploads its archive to this release."
149+
fi
115150
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)