Skip to content

Commit 3e871d9

Browse files
authored
Merge pull request #3 from 5dive-ai/dive-3531-publish-on-tags
DIVE-3531: gate this fork's GHCR publishes on release tags, not on any non-PR run
2 parents 6285728 + 8fc8cec commit 3e871d9

3 files changed

Lines changed: 60 additions & 24 deletions

File tree

‎.github/workflows/docker.yml‎

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,24 @@ name: Docker image
1616
# the relay image version tracks crates/buzz-relay/Cargo.toml, never desktop.
1717
#
1818
# Triggers:
19-
# - push to main → :main + :sha-<7>
20-
# + :debug-main + :debug-sha-<7>
19+
# - push to main → build both images, publish nothing
20+
# (was :main/:sha-<7> — see PUBLISH GATE below)
2121
# - push tags relay-v*.*.* → :{version} + :{major}.{minor} + :{major}
2222
# + matching :debug-* tags
2323
# (+ :latest/:debug-latest for stable releases)
2424
# - pull_request → build only (no push), cache stays warm
2525
# - workflow_dispatch → manual relay-tag rescue at the tag itself
2626
#
27+
# PUBLISH GATE (5dive fork): every write to the registry — the image push, the
28+
# buildcache export, the merged manifest and its attestation — fires only on a
29+
# `relay-v*` tag push or a rescue `workflow_dispatch`, never on a `main` push or
30+
# a PR. Same shape as helm-chart.yml's publish job. `main` pushes and PRs still
31+
# build both images on both arches, so the compile signal is intact; they just
32+
# cannot write to IMAGE_NAME's namespace, which on this fork defaults to
33+
# upstream `ghcr.io/block/*` and is not ours to write to. This makes the
34+
# namespace boundary a control in the workflow rather than an accident of which
35+
# credentials happen to be missing.
36+
#
2737
# Why workflow_dispatch carries a version input:
2838
# Normal releases arrive through the push:tags trigger above. The input is
2939
# retained only for an operator to rerun publication manually at an immutable
@@ -175,11 +185,11 @@ jobs:
175185
# Push by digest, not by tag — the merge job assembles the tags
176186
# into one multi-arch manifest. This is what makes the native-arm
177187
# matrix possible.
178-
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
188+
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
179189
cache-from: |
180190
type=registry,ref=${{ env.IMAGE_NAME }}-buildcache:${{ matrix.arch }}
181191
cache-to: |
182-
${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && format('type=registry,ref={0}-buildcache:{1},mode=max,compression=zstd', env.IMAGE_NAME, matrix.arch) || '' }}
192+
${{ (github.ref_type == 'tag' || github.event_name == 'workflow_dispatch') && format('type=registry,ref={0}-buildcache:{1},mode=max,compression=zstd', env.IMAGE_NAME, matrix.arch) || '' }}
183193
184194
- name: Build and push debug image by digest
185195
id: build-debug
@@ -190,12 +200,12 @@ jobs:
190200
target: runtime-debug
191201
platforms: ${{ matrix.platform }}
192202
labels: ${{ steps.meta.outputs.labels }}
193-
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
203+
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
194204
cache-from: |
195205
type=registry,ref=${{ env.IMAGE_NAME }}-buildcache:${{ matrix.arch }}
196206
197207
- name: Export release and debug digests
198-
if: github.event_name != 'pull_request'
208+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
199209
env:
200210
RELEASE_DIGEST: ${{ steps.build-release.outputs.digest }}
201211
DEBUG_DIGEST: ${{ steps.build-debug.outputs.digest }}
@@ -205,7 +215,7 @@ jobs:
205215
touch "/tmp/digests-debug/${DEBUG_DIGEST#sha256:}"
206216
207217
- name: Upload release digest
208-
if: github.event_name != 'pull_request'
218+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
209219
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
210220
with:
211221
name: digests-release-${{ matrix.arch }}
@@ -214,7 +224,7 @@ jobs:
214224
retention-days: 1
215225

216226
- name: Upload debug digest
217-
if: github.event_name != 'pull_request'
227+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
218228
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
219229
with:
220230
name: digests-debug-${{ matrix.arch }}
@@ -224,7 +234,7 @@ jobs:
224234

225235
merge:
226236
name: Merge ${{ matrix.variant }} multi-arch manifest
227-
if: github.event_name != 'pull_request'
237+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
228238
runs-on: ubuntu-24.04
229239
needs: build
230240
timeout-minutes: 15
@@ -400,16 +410,16 @@ jobs:
400410
file: ./Dockerfile.push-gateway
401411
platforms: ${{ matrix.platform }}
402412
labels: ${{ steps.meta.outputs.labels }}
403-
outputs: type=image,name=ghcr.io/block/buzz-push-gateway,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
413+
outputs: type=image,name=ghcr.io/block/buzz-push-gateway,push-by-digest=true,name-canonical=true,push=${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
404414
cache-from: type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:${{ matrix.arch }}
405-
cache-to: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && format('type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:{0},mode=max,compression=zstd', matrix.arch) || '' }}
415+
cache-to: ${{ (github.ref_type == 'tag' || github.event_name == 'workflow_dispatch') && format('type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:{0},mode=max,compression=zstd', matrix.arch) || '' }}
406416
- name: Export digest
407-
if: github.event_name != 'pull_request'
417+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
408418
env:
409419
DIGEST: ${{ steps.build.outputs.digest }}
410420
run: mkdir -p /tmp/gateway-digests && touch "/tmp/gateway-digests/${DIGEST#sha256:}"
411421
- name: Upload digest
412-
if: github.event_name != 'pull_request'
422+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
413423
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
414424
with:
415425
name: gateway-digests-${{ matrix.arch }}
@@ -419,7 +429,7 @@ jobs:
419429

420430
push-gateway-merge:
421431
name: Publish public push gateway image
422-
if: github.event_name != 'pull_request'
432+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
423433
runs-on: ubuntu-24.04
424434
needs: push-gateway-build
425435
timeout-minutes: 15

‎.github/workflows/sprig-image.yml‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@ name: Sprig image
1010
# No QEMU emulation.
1111
#
1212
# Triggers:
13-
# - push to main (paths-filtered) → :main + :sha-<7>
13+
# - push to main (paths-filtered) → build only, publish nothing
14+
# (see PUBLISH GATE below)
1415
# - tag sprig-v* → semver family (shared with sprig.yml's
1516
# binary release — one tag versions both)
1617
# - pull_request (paths-filtered) → build only, no push
1718
# - workflow_dispatch → manual publish at the current ref
1819
#
20+
# PUBLISH GATE (5dive fork): the image push, the buildcache export and the
21+
# merged manifest fire only on a `sprig-v*` tag push or a workflow_dispatch,
22+
# never on a `main` push or a PR — IMAGE_NAME defaults to upstream
23+
# `ghcr.io/block/buzz-sprig`, which this fork cannot and must not write to.
24+
# Mirrors docker.yml and helm-chart.yml. Builds still run on main and PRs.
25+
#
26+
# Residual: this workflow's `push:` trigger carries a `paths` filter, which
27+
# GitHub applies to TAG pushes too (see helm-chart.yml's note). A `sprig-v*`
28+
# tag on a commit touching none of those paths would therefore not publish.
29+
# Left as-is: a release commit bumps Cargo.toml, which is in the filter.
30+
#
1931
# NOTE: the first push creates the GHCR package PRIVATE by default. An org
2032
# admin must flip ghcr.io/block/buzz-sprig to public once (Package settings →
2133
# Change visibility). Subsequent pushes keep the visibility.
@@ -120,22 +132,22 @@ jobs:
120132
file: ./Dockerfile.sprig
121133
platforms: ${{ matrix.platform }}
122134
labels: ${{ steps.meta.outputs.labels }}
123-
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
135+
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.ref_type == 'tag' || github.event_name == 'workflow_dispatch' }}
124136
cache-from: |
125137
type=registry,ref=${{ env.IMAGE_NAME }}-buildcache:${{ matrix.arch }}
126138
cache-to: |
127-
${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && format('type=registry,ref={0}-buildcache:{1},mode=max,compression=zstd', env.IMAGE_NAME, matrix.arch) || '' }}
139+
${{ (github.ref_type == 'tag' || github.event_name == 'workflow_dispatch') && format('type=registry,ref={0}-buildcache:{1},mode=max,compression=zstd', env.IMAGE_NAME, matrix.arch) || '' }}
128140
129141
- name: Export digest
130-
if: github.event_name != 'pull_request'
142+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
131143
env:
132144
DIGEST: ${{ steps.build.outputs.digest }}
133145
run: |
134146
mkdir -p /tmp/digests
135147
touch "/tmp/digests/${DIGEST#sha256:}"
136148
137149
- name: Upload digest
138-
if: github.event_name != 'pull_request'
150+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
139151
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
140152
with:
141153
name: sprig-digest-${{ matrix.arch }}
@@ -145,7 +157,7 @@ jobs:
145157

146158
merge:
147159
name: Merge multi-arch manifest
148-
if: github.event_name != 'pull_request'
160+
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
149161
runs-on: ubuntu-24.04
150162
needs: build
151163
timeout-minutes: 15

‎.github/workflows/sprig.yml‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,24 @@ jobs:
139139
TITLE="Sprig (rolling)"
140140
NOTES="Rolling Linux build of Sprig (all-in-one buzz-acp + buzz-agent + buzz-dev-mcp), tracking \`main\` (\`${SHA}\`)."
141141
142-
gh release edit "$TAG" \
143-
--prerelease \
144-
--title "$TITLE" \
145-
--notes "$NOTES"
142+
# `gh release edit` exits 1 with "release not found" on the first
143+
# ever run in a repo, because a fork inherits no releases. Create it
144+
# then, edit it after. `sprig-latest` matches none of this repo's six
145+
# tag triggers (relay-v*, sprig-v*, chart-v*, push-chart-v*,
146+
# desktop-v*) and no workflow here listens on the `release` event, so
147+
# creating the tag cannot start a workflow loop.
148+
if gh release view "$TAG" >/dev/null 2>&1; then
149+
gh release edit "$TAG" \
150+
--prerelease \
151+
--title "$TITLE" \
152+
--notes "$NOTES"
153+
else
154+
gh release create "$TAG" \
155+
--target "$SHA" \
156+
--prerelease \
157+
--title "$TITLE" \
158+
--notes "$NOTES"
159+
fi
146160
gh release upload "$TAG" dist/* --clobber
147161
148162
publish-tag:

0 commit comments

Comments
 (0)