-
Notifications
You must be signed in to change notification settings - Fork 4
297 lines (265 loc) · 9.77 KB
/
Copy pathrelease.yml
File metadata and controls
297 lines (265 loc) · 9.77 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
name: release
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
contract:
name: Release Contract
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.version.outputs.value }}
candidate: ${{ steps.version.outputs.candidate }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Match source contract to tag
id: version
shell: bash
run: |
release_version="${GITHUB_REF_NAME#v}"
source_version="$(sed -n 's/^IMAGE_TAG=//p' .env.docker.example)"
if [[ -z "$release_version" || "$source_version" != "$release_version" ]]; then
echo "Tag version $release_version does not match source IMAGE_TAG $source_version." >&2
exit 1
fi
echo "value=$release_version" >> "$GITHUB_OUTPUT"
echo "candidate=$release_version-candidate-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" >> "$GITHUB_OUTPUT"
echo "PUBLIC_RELEASE_VERSION=$release_version" >> "$GITHUB_ENV"
- name: Install contract dependency
run: python -m pip install PyYAML==6.0.3
- name: Verify public release contract
shell: bash
run: |
python - <<'PY'
import runpy
namespace = runpy.run_path("tests/unit/test_public_release_contract.py")
tests = sorted(
(name, value)
for name, value in namespace.items()
if name.startswith("test_") and callable(value)
)
if not tests:
raise SystemExit("No public release contract tests were discovered.")
for name, contract_test in tests:
contract_test()
print(f"passed: {name}")
PY
images:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
needs: contract
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- name: API image
image: opencli-admin-api
context: .
file: Dockerfile
build_args: |
IMAGE_TAG=__VERSION__
suffix: ""
- name: Frontend image
image: opencli-admin-frontend
context: ./frontend
file: ./frontend/Dockerfile
build_args: |
BACKEND_URL=http://api:8000
suffix: ""
- name: Agent image
image: opencli-admin-agent
context: .
file: ./agent/Dockerfile
build_args: ""
suffix: ""
- name: Interactive Chrome image
image: opencli-admin-chrome
context: .
file: ./chrome/Dockerfile
build_args: ""
suffix: ""
- name: Agent Chrome image
image: opencli-admin-agent
context: .
file: ./agent/Dockerfile
suffix: "-chrome"
build_args: |
INSTALL_CHROME=true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Resolve build arguments
id: build_args
shell: bash
env:
MATRIX_BUILD_ARGS: ${{ matrix.build_args }}
RELEASE_VERSION: ${{ needs.contract.outputs.version }}
run: |
{
echo "value<<EOF"
printf '%s\n' "$MATRIX_BUILD_ARGS" | sed "s/__VERSION__/$RELEASE_VERSION/g"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up 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: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
platforms: linux/amd64,linux/arm64
push: true
build-args: ${{ steps.build_args.outputs.value }}
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:${{ needs.contract.outputs.candidate }}${{ matrix.suffix }}
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.name }}
provenance: mode=max
sbom: true
published-image-smoke:
name: Published Image Recovery Smoke
runs-on: ubuntu-24.04
needs:
- contract
- images
permissions:
contents: read
packages: read
env:
API_AUTH_TOKEN: ci-release-token
BOOTSTRAP_ADMIN_TOKEN: ci-bootstrap-admin-token
CREDENTIAL_ENCRYPTION_KEY: MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA=
COMPOSE_PROJECT_NAME: opencli-admin-release-${{ github.run_id }}-${{ github.run_attempt }}
DOCKER_IMAGE_NAMESPACE: ${{ github.repository_owner }}
IMAGE_TAG: ${{ needs.contract.outputs.candidate }}
IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}
CANDIDATE_TAG: ${{ needs.contract.outputs.candidate }}
OPENCLI_DAEMON_GATE_INCLUDE_BUILD_OVERRIDE: "0"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Generate ephemeral test secret
run: echo "SECRET_KEY=$(openssl rand -hex 32)" >> "$GITHUB_ENV"
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Verify Docker systemd precondition
run: sudo systemctl is-active --quiet docker.service
- name: Validate published-image Compose
run: docker compose --env-file .env.docker.example -f docker-compose.yml config --quiet
- name: Pull tag images
run: docker compose --env-file .env.docker.example -f docker-compose.yml pull api frontend agent-1
- name: Start published stack without building
run: docker compose --env-file .env.docker.example -f docker-compose.yml up -d --no-build --wait api frontend agent-1
- name: Verify published endpoints
run: |
curl --fail --silent --show-error http://localhost:3010/login >/dev/null
curl --fail --silent --show-error http://localhost:8031/health >/dev/null
curl --fail --silent --show-error \
-H "Authorization: Bearer ci-bootstrap-admin-token" \
-H "X-API-Token: ci-release-token" \
http://localhost:8031/api/v1/auth/me |
python -c 'import json,sys; assert json.load(sys.stdin)["data"]["subject"] == "bootstrap-admin"'
- name: Verify both published agent variants
run: bash .github/scripts/verify-candidate-agent-images.sh
- name: Verify published Docker daemon restart recovery
run: bash .github/scripts/verify-daemon-restart.sh
- name: Show published logs on failure
if: failure()
run: docker compose --env-file .env.docker.example -f docker-compose.yml logs --tail=200 api frontend agent-1
- name: Stop published stack
if: always()
run: docker compose --env-file .env.docker.example -f docker-compose.yml down -v
promote:
name: Promote Verified Images
runs-on: ubuntu-latest
needs:
- contract
- published-image-smoke
permissions:
contents: read
packages: write
steps:
- name: Set up 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: Promote candidate manifests
shell: bash
env:
IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }}
RELEASE_VERSION: ${{ needs.contract.outputs.version }}
CANDIDATE_TAG: ${{ needs.contract.outputs.candidate }}
run: |
# Candidate tags are retained as release audit artifacts. GHCR deletes
# package versions by shared manifest/digest, so post-promotion deletion
# can also remove the newly attached formal/latest tags.
for image in opencli-admin-api opencli-admin-frontend opencli-admin-chrome; do
docker buildx imagetools create \
--tag "$IMAGE_PREFIX/$image:$RELEASE_VERSION" \
--tag "$IMAGE_PREFIX/$image:latest" \
"$IMAGE_PREFIX/$image:$CANDIDATE_TAG"
done
docker buildx imagetools create \
--tag "$IMAGE_PREFIX/opencli-admin-agent:$RELEASE_VERSION" \
--tag "$IMAGE_PREFIX/opencli-admin-agent:latest" \
"$IMAGE_PREFIX/opencli-admin-agent:$CANDIDATE_TAG"
docker buildx imagetools create \
--tag "$IMAGE_PREFIX/opencli-admin-agent:$RELEASE_VERSION-chrome" \
--tag "$IMAGE_PREFIX/opencli-admin-agent:latest-chrome" \
"$IMAGE_PREFIX/opencli-admin-agent:$CANDIDATE_TAG-chrome"
github-release:
name: GitHub Release
runs-on: ubuntu-latest
needs: promote
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
docker-compose.yml
docker-compose.build.yml
.env.docker.example
scripts/install.sh
scripts/install.ps1