Skip to content

Commit 1c00682

Browse files
tlongwell-blocknpub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757
andauthored
feat(push): add public APNs gateway (#1770)
Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
1 parent 52e42cc commit 1c00682

67 files changed

Lines changed: 9635 additions & 79 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/auto-tag-on-release-pr-merge.yml‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
name: Auto-tag on Release PR Merge
22

3-
# Four release lanes share this one workflow. Three use an explicit branch
4-
# prefix; the chart lane also auto-detects a Chart.yaml version bump so a chart
5-
# feature PR can publish its own new version when merged:
3+
# Five release lanes share this one workflow. Four use an explicit branch
4+
# prefix; the main chart lane also auto-detects a Chart.yaml version bump so
5+
# a chart feature PR can publish its own new version when merged:
66
#
77
# version-bump/<v> → tag v<v> → dispatch release.yml (desktop app)
88
# relay-release/<v> → tag relay-v<v> → dispatch docker.yml (relay image)
9-
# chart-release/<v> → tag chart-v<v> → dispatch helm-chart.yml (helm chart)
9+
# chart-release/<v> → tag chart-v<v> → dispatch helm-chart.yml (main helm chart)
10+
# push-chart-release/<v> → tag push-chart-v<v> → dispatch push-gateway-helm-chart.yml
1011
# any internal PR that bumps deploy/charts/buzz/Chart.yaml `version`
1112
# → tag chart-v<v> → dispatch helm-chart.yml (helm chart)
1213
# mobile-release/<v> → tag mobile-v<v> → (manual sprout_ref for buzz-releases build — see below)
@@ -68,6 +69,10 @@ jobs:
6869
VERSION="${BRANCH#chart-release/}"
6970
TAG_PREFIX="chart-v"
7071
DISPATCH="helm-chart" ;;
72+
push-chart-release/*)
73+
VERSION="${BRANCH#push-chart-release/}"
74+
TAG_PREFIX="push-chart-v"
75+
DISPATCH="push-gateway-helm-chart" ;;
7176
mobile-release/*)
7277
VERSION="${BRANCH#mobile-release/}"
7378
TAG_PREFIX="mobile-v"
@@ -134,6 +139,7 @@ jobs:
134139
release) WORKFLOW="release.yml" ;;
135140
docker) WORKFLOW="docker.yml" ;;
136141
helm-chart) WORKFLOW="helm-chart.yml" ;;
142+
push-gateway-helm-chart) WORKFLOW="push-gateway-helm-chart.yml" ;;
137143
*)
138144
echo "::error::Unhandled dispatch target: '$DISPATCH'"
139145
exit 1 ;;

‎.github/workflows/docker.yml‎

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ on:
4747
pull_request:
4848
paths:
4949
- "Dockerfile"
50+
- "Dockerfile.push-gateway"
5051
- ".dockerignore"
5152
- ".github/workflows/docker.yml"
5253
- "Cargo.toml"
@@ -304,3 +305,150 @@ jobs:
304305
echo "gh attestation verify oci://${IMAGE_NAME}@${MERGED_DIGEST} --owner block"
305306
echo '```'
306307
} >> "$GITHUB_STEP_SUMMARY"
308+
309+
push-gateway-build:
310+
name: Build public push gateway (${{ matrix.platform }})
311+
runs-on: ${{ matrix.runner }}
312+
timeout-minutes: 60
313+
permissions:
314+
contents: read
315+
packages: write
316+
strategy:
317+
fail-fast: false
318+
matrix:
319+
include:
320+
- platform: linux/amd64
321+
runner: ubuntu-24.04
322+
arch: amd64
323+
- platform: linux/arm64
324+
runner: ubuntu-24.04-arm
325+
arch: arm64
326+
steps:
327+
- name: Checkout
328+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
329+
with:
330+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
331+
persist-credentials: false
332+
- name: Set up Docker Buildx
333+
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
334+
with:
335+
buildkitd-config-inline: |
336+
[worker.oci]
337+
max-parallelism = 2
338+
- name: Log in to GHCR
339+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
340+
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
341+
with:
342+
registry: ghcr.io
343+
username: ${{ github.repository_owner }}
344+
password: ${{ secrets.GITHUB_TOKEN }}
345+
- name: Extract metadata
346+
id: meta
347+
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
348+
with:
349+
images: ghcr.io/block/buzz-push-gateway
350+
labels: |
351+
org.opencontainers.image.title=Buzz Push Gateway
352+
org.opencontainers.image.description=Capability-gated APNs last hop for Buzz
353+
org.opencontainers.image.licenses=Apache-2.0
354+
- name: Build and push by digest
355+
id: build
356+
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
357+
with:
358+
context: .
359+
file: ./Dockerfile.push-gateway
360+
platforms: ${{ matrix.platform }}
361+
labels: ${{ steps.meta.outputs.labels }}
362+
outputs: type=image,name=ghcr.io/block/buzz-push-gateway,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
363+
cache-from: type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:${{ matrix.arch }}
364+
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) || '' }}
365+
- name: Export digest
366+
if: github.event_name != 'pull_request'
367+
env:
368+
DIGEST: ${{ steps.build.outputs.digest }}
369+
run: mkdir -p /tmp/gateway-digests && touch "/tmp/gateway-digests/${DIGEST#sha256:}"
370+
- name: Upload digest
371+
if: github.event_name != 'pull_request'
372+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
373+
with:
374+
name: gateway-digests-${{ matrix.arch }}
375+
path: /tmp/gateway-digests/*
376+
if-no-files-found: error
377+
retention-days: 1
378+
379+
push-gateway-merge:
380+
name: Publish public push gateway image
381+
if: github.event_name != 'pull_request'
382+
runs-on: ubuntu-24.04
383+
needs: push-gateway-build
384+
timeout-minutes: 15
385+
permissions:
386+
contents: read
387+
packages: write
388+
id-token: write
389+
attestations: write
390+
steps:
391+
- name: Download per-arch digests
392+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
393+
with:
394+
path: /tmp/gateway-digests
395+
pattern: gateway-digests-*
396+
merge-multiple: true
397+
- name: Set up Docker Buildx
398+
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
399+
- name: Log in to GHCR
400+
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
401+
with:
402+
registry: ghcr.io
403+
username: ${{ github.repository_owner }}
404+
password: ${{ secrets.GITHUB_TOKEN }}
405+
- name: Extract metadata
406+
id: meta
407+
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
408+
with:
409+
images: ghcr.io/block/buzz-push-gateway
410+
tags: |
411+
type=ref,event=branch,enable=${{ github.event_name != 'workflow_dispatch' || inputs.version == '' }}
412+
type=sha,prefix=sha-,format=short,enable=${{ github.event_name != 'workflow_dispatch' || inputs.version == '' }}
413+
type=semver,pattern={{version}},match=^relay-v(.*)$,value=${{ inputs.version }}
414+
type=semver,pattern={{major}}.{{minor}},match=^relay-v(.*)$,value=${{ inputs.version }}
415+
- name: Merge and publish manifest
416+
id: manifest
417+
working-directory: /tmp/gateway-digests
418+
env:
419+
META_TAGS: ${{ steps.meta.outputs.tags }}
420+
run: |
421+
set -euo pipefail
422+
tags=(); while IFS= read -r tag; do [ -n "$tag" ] && tags+=("-t" "$tag"); done <<< "$META_TAGS"
423+
digests=(); for digest in *; do digests+=("ghcr.io/block/buzz-push-gateway@sha256:${digest}"); done
424+
docker buildx imagetools create "${tags[@]}" "${digests[@]}"
425+
first_tag=$(echo "$META_TAGS" | head -n1)
426+
digest=$(docker buildx imagetools inspect "$first_tag" --format '{{json .Manifest}}' | jq -r '.digest')
427+
echo "digest=${digest}" >> "$GITHUB_OUTPUT"
428+
- name: Attest gateway image provenance
429+
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
430+
with:
431+
subject-name: ghcr.io/block/buzz-push-gateway
432+
subject-digest: ${{ steps.manifest.outputs.digest }}
433+
push-to-registry: true
434+
- name: Gateway publication summary
435+
env:
436+
GATEWAY_DIGEST: ${{ steps.manifest.outputs.digest }}
437+
GATEWAY_TAGS: ${{ steps.meta.outputs.tags }}
438+
run: |
439+
set -euo pipefail
440+
{
441+
echo "### Published \`ghcr.io/block/buzz-push-gateway\`"
442+
echo
443+
printf "**Digest:** \`%s\`\n" "$GATEWAY_DIGEST"
444+
echo
445+
echo '**Tags:**'
446+
echo "\`\`\`"
447+
printf '%s\n' "$GATEWAY_TAGS"
448+
echo "\`\`\`"
449+
echo
450+
echo 'Verify provenance before deployment:'
451+
echo "\`\`\`"
452+
printf 'gh attestation verify oci://ghcr.io/block/buzz-push-gateway@%s --owner block\n' "$GATEWAY_DIGEST"
453+
echo "\`\`\`"
454+
} >> "$GITHUB_STEP_SUMMARY"

‎.github/workflows/helm-chart.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ on:
4040
pull_request:
4141
paths:
4242
- "deploy/charts/buzz/**"
43+
- "deploy/charts/buzz-push-gateway/**"
4344
- ".github/workflows/helm-chart.yml"
4445
- "ct.yaml"
4546

@@ -88,6 +89,9 @@ jobs:
8889
- name: Build chart dependencies
8990
run: helm dependency build deploy/charts/buzz
9091

92+
- name: Push gateway chart lint + render guard
93+
run: deploy/charts/buzz-push-gateway/tests/render.sh
94+
9195
- name: ct lint
9296
run: ct lint --config ct.yaml --all
9397

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: push gateway helm chart
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Chart semver (without push-chart-v prefix)"
8+
required: true
9+
ref:
10+
description: "Matching push-chart-v tag"
11+
required: true
12+
push:
13+
tags: ["push-chart-v[0-9]*"]
14+
pull_request:
15+
paths:
16+
- "deploy/charts/buzz-push-gateway/**"
17+
- ".github/workflows/push-gateway-helm-chart.yml"
18+
permissions: {}
19+
env:
20+
CHART_REPO: oci://ghcr.io/block/buzz/charts
21+
jobs:
22+
validate:
23+
runs-on: ubuntu-latest
24+
permissions: { contents: read }
25+
steps:
26+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
27+
with:
28+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
29+
fetch-depth: 0
30+
- uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4
31+
with: { version: v3.16.4 }
32+
- run: deploy/charts/buzz-push-gateway/tests/render.sh
33+
- run: deploy/charts/buzz-push-gateway/tests/release-contract.sh
34+
publish:
35+
if: github.event_name != 'pull_request'
36+
needs: validate
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: read
40+
packages: write
41+
steps:
42+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
43+
with:
44+
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}
45+
fetch-depth: 0
46+
persist-credentials: false
47+
- uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4
48+
with: { version: v3.16.4 }
49+
- name: Verify release tag and chart version
50+
env:
51+
INPUT_VERSION: ${{ inputs.version }}
52+
REF_NAME: ${{ github.ref_name }}
53+
run: |
54+
set -euo pipefail
55+
version="${INPUT_VERSION:-${REF_NAME#push-chart-v}}"
56+
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]
57+
test "$(helm show chart deploy/charts/buzz-push-gateway | awk '/^version:/ {print $2}')" = "$version"
58+
if [ -n "$INPUT_VERSION" ]; then
59+
test "$(git rev-parse HEAD)" = "$(git rev-parse "refs/tags/push-chart-v${version}^{commit}")"
60+
fi
61+
echo "VERSION=$version" >> "$GITHUB_ENV"
62+
- uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee
63+
with:
64+
registry: ghcr.io
65+
username: ${{ github.repository_owner }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
- run: helm package deploy/charts/buzz-push-gateway --destination dist
68+
- run: helm push "dist/buzz-push-gateway-${VERSION}.tgz" "$CHART_REPO"

0 commit comments

Comments
 (0)