Skip to content

Commit 6b77004

Browse files
authored
CI: recreate the latest release in the build jobs, not a separate workflow that can run after uploads (#698)
1 parent 808f310 commit 6b77004

5 files changed

Lines changed: 58 additions & 33 deletions

File tree

‎.github/workflows/build-linux.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ jobs:
3737
with:
3838
key: ${{ matrix.cfg.target }}
3939

40+
- name: Recreate the latest release for this commit
41+
if: github.repository == 'openframeworks/projectGenerator' && github.event_name == 'push' && github.ref == 'refs/heads/master'
42+
shell: bash
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: ./scripts/ci_latest_release.sh
4046
- name: Determine Release
4147
id: vars
4248
shell: bash
@@ -141,6 +147,12 @@ jobs:
141147
with:
142148
key: ubuntu22-linux
143149

150+
- name: Recreate the latest release for this commit
151+
if: github.repository == 'openframeworks/projectGenerator' && github.event_name == 'push' && github.ref == 'refs/heads/master'
152+
shell: bash
153+
env:
154+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
run: ./scripts/ci_latest_release.sh
144156
- name: Determine Release
145157
shell: bash
146158
run: |
@@ -219,6 +231,12 @@ jobs:
219231
with:
220232
key: arm64-linux
221233

234+
- name: Recreate the latest release for this commit
235+
if: github.repository == 'openframeworks/projectGenerator' && github.event_name == 'push' && github.ref == 'refs/heads/master'
236+
shell: bash
237+
env:
238+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
239+
run: ./scripts/ci_latest_release.sh
222240
- name: Determine Release
223241
shell: bash
224242
run: |

‎.github/workflows/build-macos.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ jobs:
3737
node-version: 26
3838
- name: Setup
3939
run: ./scripts/osx/setup_environment.sh
40+
- name: Recreate the latest release for this commit
41+
if: github.repository == 'openframeworks/projectGenerator' && github.event_name == 'push' && github.ref == 'refs/heads/master'
42+
shell: bash
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: ./scripts/ci_latest_release.sh
4046
- name: Determine Release
4147
id: vars
4248
shell: bash

‎.github/workflows/build-vs.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ jobs:
4242
zip
4343
rsync
4444
wget
45+
- name: Recreate the latest release for this commit
46+
if: github.repository == 'openframeworks/projectGenerator' && github.event_name == 'push' && github.ref == 'refs/heads/master'
47+
shell: bash
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: ./scripts/ci_latest_release.sh
4551
- name: Determine Release
4652
id: vars
4753
shell: bash

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

Lines changed: 0 additions & 33 deletions
This file was deleted.

‎scripts/ci_latest_release.sh‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
# master builds upload to the "latest" release. The first build job of a push recreates it at that
4+
# commit, so its date and tag are this build's; jobs that start later (a runner can queue for half
5+
# an hour) see the tag already there and leave it, so nothing already uploaded is deleted.
6+
# Re-running an older master build doesn't touch a newer latest.
7+
8+
REPO="${GITHUB_REPOSITORY:?}"
9+
SHA="${GITHUB_SHA:?}"
10+
11+
head=$(gh api "repos/$REPO/commits/master" --jq '.sha' 2>/dev/null || true)
12+
if [ "$head" != "$SHA" ]; then
13+
echo "${SHA:0:7} isn't the master head (${head:0:7}) - leaving latest"
14+
exit 0
15+
fi
16+
17+
current=$(gh api "repos/$REPO/git/ref/tags/latest" --jq '.object.sha' 2>/dev/null || true)
18+
if [ "$current" = "$SHA" ]; then
19+
echo "latest is already at ${SHA:0:7}"
20+
exit 0
21+
fi
22+
23+
echo "recreating latest at ${SHA:0:7} (was ${current:0:7})"
24+
gh release delete latest --repo "$REPO" --cleanup-tag --yes || echo "no latest release yet"
25+
# another build job may create it at the same moment
26+
gh release create latest --repo "$REPO" --target "$SHA" --title latest --latest=false \
27+
--notes "Latest master build from ${SHA:0:7} (copied to nightly every night). Files are added as each platform finishes building." \
28+
|| gh release view latest --repo "$REPO" > /dev/null

0 commit comments

Comments
 (0)