-
Notifications
You must be signed in to change notification settings - Fork 285
387 lines (337 loc) · 12.2 KB
/
Copy pathpublish-selfhost-docker.yml
File metadata and controls
387 lines (337 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: Publish Self-host Docker Image
run-name: "${{ format('publish self-host docker {0}', inputs.tag) }}"
on:
workflow_dispatch:
inputs:
tag:
description: Git tag to publish (e.g. v1.5.0)
required: true
type: string
permissions:
contents: read
concurrency:
group: publish-selfhost-docker-${{ inputs.tag }}
cancel-in-progress: false
# CI is not a user. Without this, executor's own product telemetry reports to the
# production PostHog project from every e2e shard: the analytics layer
# (integration_added, execution_completed, artifact_*) and the
# integrations-registry fetch, which lands as a `hit` event. Each shard is a
# fresh container, so it mints a fresh anonymous id and arrives on a fresh
# runner IP — inflating machine and user counts by roughly an order of
# magnitude. Both opt-outs are the packages' documented CI/test hooks.
env:
DO_NOT_TRACK: "1"
EXECUTOR_DISABLE_ANALYTICS: "1"
EXECUTOR_DISABLE_INTEGRATIONS_FETCH: "1"
jobs:
metadata:
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
outputs:
release_tag: ${{ steps.validate.outputs.tag }}
image: ${{ steps.image.outputs.image }}
tags: ${{ steps.image.outputs.tags }}
legacy_tags: ${{ steps.image.outputs.legacy_tags }}
labels: ${{ steps.image.outputs.labels }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.11
- name: Validate release tag
id: validate
env:
RAW_RELEASE_TAG: ${{ inputs.tag }}
run: bun run scripts/validate-release-ref.ts --tag-env RAW_RELEASE_TAG --write-env RELEASE_TAG --output tag
- name: Checkout release tag
env:
GH_TOKEN: ${{ secrets.RELEASE_PAT || github.token }}
run: |
auth_remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git fetch --force --tags "$auth_remote" "refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG"
git checkout --detach "$RELEASE_TAG"
- name: Resolve image metadata
id: image
shell: bash
run: |
set -euo pipefail
version="${RELEASE_TAG#v}"
owner="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"
image="ghcr.io/${owner}/executor-selfhost"
legacy_image="ghcr.io/rhyssullivan/executor-selfhost"
revision="$(git rev-parse HEAD)"
if [[ "$version" == *-* ]]; then
channel="beta"
else
channel="latest"
fi
{
echo "image=$image"
echo "version=$version"
echo "channel=$channel"
echo "tags<<TAGS"
echo "${image}:${RELEASE_TAG}"
echo "${image}:${version}"
echo "${image}:${channel}"
echo "TAGS"
echo "legacy_tags<<TAGS"
echo "${legacy_image}:${RELEASE_TAG}"
echo "${legacy_image}:${version}"
echo "${legacy_image}:${channel}"
echo "TAGS"
echo "labels<<LABELS"
echo "org.opencontainers.image.title=Executor self-host"
echo "org.opencontainers.image.description=Single-container self-hosted Executor"
echo "org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}"
echo "org.opencontainers.image.revision=${revision}"
echo "org.opencontainers.image.version=${version}"
echo "LABELS"
} >> "$GITHUB_OUTPUT"
build:
needs: metadata
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: blacksmith-4vcpu-ubuntu-2404
- arch: arm64
platform: linux/arm64
runner: blacksmith-4vcpu-ubuntu-2404-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- name: Checkout release tag
uses: actions/checkout@v4
with:
ref: ${{ needs.metadata.outputs.release_tag }}
fetch-depth: 0
persist-credentials: false
- name: Setup Blacksmith Builder
uses: useblacksmith/setup-docker-builder@v1
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push self-host image by digest
id: build
uses: useblacksmith/build-push-action@v2
with:
context: .
file: apps/host-selfhost/Dockerfile
platforms: ${{ matrix.platform }}
labels: ${{ needs.metadata.outputs.labels }}
outputs: type=image,name=${{ needs.metadata.outputs.image }},push-by-digest=true,name-canonical=true,push=true
- name: Export image digest
shell: bash
env:
DIGEST: ${{ steps.build.outputs.digest }}
run: |
set -euo pipefail
if [ -z "$DIGEST" ]; then
echo "Build did not return a digest."
exit 1
fi
mkdir -p "$RUNNER_TEMP/digests"
touch "$RUNNER_TEMP/digests/${DIGEST#sha256:}"
- name: Upload image digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
# Release gate: run the full selfhost-docker e2e project against the exact
# by-digest image each build leg pushed, before any user-visible tag moves.
# Build-only smoke misses startup crashes and feature-path breaks (a package
# resolved at runtime but missing from the packaged runtime shipped broken in
# v1.5.30 exactly this way); per-arch matters too — the libsql native-addon
# bug was arm64-only.
e2e:
needs:
- metadata
- build
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: blacksmith-4vcpu-ubuntu-2404
- arch: arm64
runner: blacksmith-4vcpu-ubuntu-2404-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 40
permissions:
contents: read
packages: read
steps:
- name: Checkout release tag
uses: actions/checkout@v4
with:
ref: ${{ needs.metadata.outputs.release_tag }}
persist-credentials: false
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.11
- name: Cache Bun package cache
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-${{ runner.arch }}-bun-1.3.11-${{ hashFiles('bun.lock') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-bun-1.3.11-
# Scenario helpers spawn Node sidecars; pin the same Node 24 runtime the
# other workflows use.
- uses: actions/setup-node@v4
with:
node-version: 24
- run: bun install --frozen-lockfile
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-${{ runner.arch }}-playwright-1.60.0
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-playwright-
# Install from e2e so bunx resolves ITS pinned playwright (the version
# the tests run against) rather than floating to the latest.
- name: Install Playwright Chromium
run: bunx playwright install --with-deps chromium chromium-headless-shell
working-directory: e2e
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download image digest
uses: actions/download-artifact@v4
with:
name: digests-${{ matrix.arch }}
path: ${{ runner.temp }}/digests
- name: Resolve image reference
id: image_ref
shell: bash
env:
IMAGE: ${{ needs.metadata.outputs.image }}
run: |
set -euo pipefail
digest_file="$(find "$RUNNER_TEMP/digests" -maxdepth 1 -type f | head -n 1)"
if [ -z "$digest_file" ]; then
echo "No image digest was downloaded."
exit 1
fi
ref="${IMAGE}@sha256:$(basename "$digest_file")"
echo "ref=$ref" >> "$GITHUB_OUTPUT"
docker pull "$ref"
- name: Run selfhost-docker scenarios against the published digest
env:
E2E_SELFHOST_DOCKER_IMAGE: ${{ steps.image_ref.outputs.ref }}
run: bunx vitest run --project selfhost-docker --retry=2
working-directory: e2e
- name: Upload run artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-runs-selfhost-docker-${{ matrix.arch }}
path: |
e2e/runs/
e2e/selfhost-docker.boot.log
retention-days: 7
merge:
needs:
- metadata
- build
- e2e
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
packages: write
steps:
- name: Download image digests
uses: actions/download-artifact@v4
with:
pattern: digests-*
path: ${{ runner.temp }}/digests
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish multi-arch self-host image
shell: bash
env:
IMAGE: ${{ needs.metadata.outputs.image }}
TAGS: ${{ needs.metadata.outputs.tags }}
run: |
set -euo pipefail
sources=()
while IFS= read -r digest_file; do
digest="$(basename "$digest_file")"
[[ -n "$digest" ]] || continue
sources+=("${IMAGE}@sha256:${digest}")
done < <(find "$RUNNER_TEMP/digests" -maxdepth 1 -type f | sort)
if [ "${#sources[@]}" -eq 0 ]; then
echo "No image digests were downloaded."
exit 1
fi
tag_args=()
while IFS= read -r tag; do
[[ -n "$tag" ]] || continue
tag_args+=("-t" "$tag")
done <<< "$TAGS"
docker buildx imagetools create "${tag_args[@]}" "${sources[@]}"
# Mirrors each release to the pre-org-move namespace
# (ghcr.io/rhyssullivan/executor-selfhost), which GHCR cannot redirect.
# Deliberately a separate job: the canonical publish above never depends on
# it, and a failure here (an expired GHCR_LEGACY_TOKEN, historically) shows
# as one red job pointing at exactly what to fix.
mirror-legacy:
needs:
- metadata
- merge
runs-on: blacksmith-4vcpu-ubuntu-2404
env:
HAS_LEGACY_TOKEN: ${{ secrets.GHCR_LEGACY_TOKEN != '' }}
steps:
- name: Skip legacy GHCR mirror (GHCR_LEGACY_TOKEN not configured)
if: env.HAS_LEGACY_TOKEN != 'true'
run: echo "GHCR_LEGACY_TOKEN is not configured; skipping legacy GHCR mirror."
- name: Set up Docker Buildx
if: env.HAS_LEGACY_TOKEN == 'true'
uses: docker/setup-buildx-action@v3
- name: Log in to legacy GHCR namespace
if: env.HAS_LEGACY_TOKEN == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: rhyssullivan
password: ${{ secrets.GHCR_LEGACY_TOKEN }}
- name: Mirror release tags to the legacy namespace
if: env.HAS_LEGACY_TOKEN == 'true'
shell: bash
env:
SOURCE_IMAGE: ${{ needs.metadata.outputs.image }}:${{ needs.metadata.outputs.release_tag }}
LEGACY_TAGS: ${{ needs.metadata.outputs.legacy_tags }}
run: |
set -euo pipefail
tag_args=()
while IFS= read -r tag; do
[[ -n "$tag" ]] || continue
tag_args+=("-t" "$tag")
done <<< "$LEGACY_TAGS"
docker buildx imagetools create "${tag_args[@]}" "$SOURCE_IMAGE"