This repository was archived by the owner on Jul 23, 2026. It is now read-only.
forked from 0xShug0/audio.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
306 lines (274 loc) · 10.9 KB
/
Copy pathdocker.yml
File metadata and controls
306 lines (274 loc) · 10.9 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
# audio.cpp — Build and publish Docker images
#
# Produces multi-arch (amd64, arm64) images on ghcr.io:
# full-cpu (latest, mutable)
# full-cpu-YYYYMMDD-HHHHHHH (pinned to date + short SHA, immutable)
# full-cuda12 (latest, mutable)
# full-cuda12-YYYYMMDD-HHHHHHH (pinned to date + short SHA, immutable)
# full-cuda13 (latest, mutable)
# full-cuda13-YYYYMMDD-HHHHHHH (pinned to date + short SHA, immutable)
name: Build and publish Docker images
on:
# Runs daily at 03:21 UTC
schedule:
- cron: '21 3 * * *'
# or when triggered manually
workflow_dispatch:
inputs:
force_build:
description: 'Force build even if no new commits'
type: boolean
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
packages: write
env:
IMAGE_REPO: ${{ github.repository }}
jobs:
# ── Check for new commits ───────────────────────────────────────────────────
check-commits:
name: Check for new commits
runs-on: ubuntu-24.04
outputs:
skip_build: ${{ steps.check.outputs.skip }}
short_sha: ${{ steps.check.outputs.short_sha }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Check for new commits
id: check
run: |
SHORT_SHA=$(git rev-parse --short=7 HEAD)
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.force_build }}" == 'true' ]]; then
echo "Manual trigger (force_build=true) — building"
echo "skip=false" >> "$GITHUB_OUTPUT"
else
LAST_TAG=$(git tag -l 'last-docker-build' | head -1)
if [[ -n "$LAST_TAG" ]]; then
LAST_SHA=$(git rev-list -1 "$LAST_TAG" 2>/dev/null || echo "")
HEAD_SHA=$(git rev-parse HEAD)
if [[ "$LAST_SHA" == "$HEAD_SHA" ]]; then
echo "No new commits since last daily build — skipping"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "New commits found — building"
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
else
echo "No previous build tag found — building"
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
fi
# ── Shared metadata (date computed once for all jobs) ───────────────────────
metadata:
name: Generate metadata
needs: check-commits
if: ${{ needs.check-commits.outputs.skip_build != 'true' }}
runs-on: ubuntu-24.04
outputs:
build_date: ${{ steps.date.outputs.date }}
date_tag: ${{ steps.date.outputs.tag }}
steps:
- name: Get build date
id: date
run: |
echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"
echo "tag=$(date -u +'%Y%m%d')" >> "$GITHUB_OUTPUT"
# ── Build each arch, push by digest ─────────────────────────────────────────
build:
name: Build (${{ matrix.tag }}, ${{ matrix.platforms }})
needs: [check-commits, metadata]
if: ${{ needs.check-commits.outputs.skip_build != 'true' }}
runs-on: ${{ matrix.runs_on }}
strategy:
fail-fast: false
matrix:
include:
# ── CPU ──
- tag: cpu
dockerfile: .devops/cpu.Dockerfile
platforms: linux/amd64
arch: amd64
runs_on: ubuntu-24.04
enabled: true
- tag: cpu
dockerfile: .devops/cpu.Dockerfile
platforms: linux/arm64
arch: arm64
runs_on: ubuntu-24.04-arm
enabled: true
# ── CUDA 12 ──
- tag: cuda12
dockerfile: .devops/cuda.Dockerfile
platforms: linux/amd64
arch: amd64
runs_on: ubuntu-24.04
cuda_version: "12.9.2"
enabled: true
- tag: cuda12
dockerfile: .devops/cuda.Dockerfile
platforms: linux/arm64
arch: arm64
runs_on: ubuntu-24.04-arm
cuda_version: "12.9.2"
enabled: true
# ── CUDA 13 ──
- tag: cuda13
dockerfile: .devops/cuda.Dockerfile
platforms: linux/amd64
arch: amd64
runs_on: ubuntu-24.04
cuda_version: "13.3.0"
enabled: true
- tag: cuda13
dockerfile: .devops/cuda.Dockerfile
platforms: linux/arm64
arch: arm64
runs_on: ubuntu-24.04-arm
cuda_version: "13.3.0"
enabled: true
steps:
- name: Skip when not enabled
if: ${{ matrix.enabled != true }}
run: echo "Skipping ${{ matrix.tag }} build"
- name: Checkout
if: ${{ matrix.enabled == true }}
uses: actions/checkout@v5
- name: Set up Docker Buildx
if: ${{ matrix.enabled == true }}
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
if: ${{ matrix.enabled == true }}
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: push
if: ${{ matrix.enabled == true }}
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
target: full
platforms: ${{ matrix.platforms }}
provenance: false
outputs: type=image,name=ghcr.io/${{ env.IMAGE_REPO }},push-by-digest=true,name-canonical=true,push=true,oci-mediatypes=true
build-args: |
BUILD_DATE=${{ needs.metadata.outputs.build_date }}
APP_VERSION=${{ github.sha }}
APP_REVISION=${{ github.sha }}
IMAGE_URL=${{ github.server_url }}/${{ github.repository }}
IMAGE_SOURCE=${{ github.server_url }}/${{ github.repository }}
ENGINE_ENABLE_NATIVE_CPU=OFF
${{ matrix.cuda_version && format('CUDA_VERSION={0}', matrix.cuda_version) || '' }}
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_REPO }}:cache-${{ matrix.arch }}-${{ matrix.tag }}
cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_REPO }}:cache-${{ matrix.arch }}-${{ matrix.tag }},mode=max
- name: Upload digest
if: ${{ matrix.enabled == true }}
shell: bash
run: |
set -euo pipefail
mkdir -p /tmp/digests
digest="${{ steps.push.outputs.digest }}"
if [[ "$digest" != sha256:* ]]; then
echo "::error::Invalid digest format: $digest"
exit 1
fi
printf '%s\n' "$digest" > "/tmp/digests/${{ matrix.tag }}-${{ matrix.arch }}.txt"
- name: Save digest artifact
if: ${{ matrix.enabled == true }}
uses: actions/upload-artifact@v7
with:
name: digest-${{ matrix.arch }}-${{ matrix.tag }}
path: /tmp/digests/
if-no-files-found: error
# ── Merge per-arch digests into multi-arch manifests ────────────────────────
merge:
name: Merge (${{ matrix.tag }})
needs: [check-commits, metadata, build]
# Merge will only run if there was actually a new commit to act on and
# if all build jobs succeeded. As soon as one build fails, we won't
# produce any merged images.
if: ${{ needs.check-commits.outputs.skip_build != 'true' && needs.build.result == 'success' }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
tag: [cpu, cuda12, cuda13]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download digests
uses: actions/download-artifact@v8
with:
pattern: digest-*
path: /tmp/digests
merge-multiple: true
- name: Create manifest
shell: bash
run: |
set -euo pipefail
repo="ghcr.io/${{ env.IMAGE_REPO }}"
date_tag="${{ needs.metadata.outputs.date_tag }}"
short_sha="${{ needs.check-commits.outputs.short_sha }}"
tag="${{ matrix.tag }}"
build_date="${{ needs.metadata.outputs.build_date }}"
image_url="${{ github.server_url }}/${{ github.repository }}"
mutable="full-${tag}"
immutable="full-${tag}-${date_tag}-${short_sha}"
# Collect per-arch digests.
# Because this job is gated on needs.build.result == 'success', a missing
# digest can only mean the variant was intentionally disabled (enabled: false).
expected_arches=(amd64 arm64)
refs=()
for arch in "${expected_arches[@]}"; do
file="/tmp/digests/${tag}-${arch}.txt"
[ -f "$file" ] || continue
refs+=("${repo}@$(cat "$file")")
done
echo "${tag}: ${#refs[@]}/${#expected_arches[@]} digests merged"
if [ ${#refs[@]} -eq 0 ]; then
echo " → skipping (all variants disabled)"
exit 0
fi
# OCI annotations for the merged manifest
annotations=(
--annotation "index:org.opencontainers.image.created=${build_date}"
--annotation "index:org.opencontainers.image.revision=${{ github.sha }}"
--annotation "index:org.opencontainers.image.url=${image_url}"
--annotation "index:org.opencontainers.image.source=${image_url}"
)
echo " → ${mutable}"
docker buildx imagetools create "${annotations[@]}" --tag "${repo}:${mutable}" "${refs[@]}"
echo " → ${immutable}"
docker buildx imagetools create "${annotations[@]}" --tag "${repo}:${immutable}" "${refs[@]}"
# ── Update last-docker-build tag ────────────────────────────────────────────
update-tag:
name: Update build tag
needs: [check-commits, merge]
if: ${{ needs.check-commits.outputs.skip_build != 'true' && needs.merge.result == 'success' }}
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Update last-docker-build tag
run: |
set -euo pipefail
git tag -f last-docker-build HEAD
git push origin last-docker-build -f