forked from volcano-sh/kthena
-
Notifications
You must be signed in to change notification settings - Fork 0
393 lines (355 loc) · 12.7 KB
/
build-push-release.yml
File metadata and controls
393 lines (355 loc) · 12.7 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
388
389
390
391
392
393
name: Build, Push, and Release
on:
push:
branches:
- main
tags:
- "v*.*.*"
- "v*.*.*-*" # Support for pre-release tags like v1.2.3-alpha
paths:
- 'charts/kthena/**'
- 'python/**'
- 'docker/**'
- '**.go'
- 'pkg/**'
- 'cmd/**'
- 'go.mod'
- 'go.sum'
pull_request:
branches:
- main
paths:
- "docker/**"
- 'python/Dockerfile'
jobs:
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
is_tag: ${{ steps.version.outputs.is_tag }}
prerelease: ${{ steps.is_prerelease.outputs.prerelease }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Determine Version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
echo "is_tag=true" >> $GITHUB_OUTPUT
else
VERSION="0.0.0-main-$(date -u +'%Y%m%d%H%M%S')-$(git rev-parse --short HEAD)"
echo "is_tag=false" >> $GITHUB_OUTPUT
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Check for Prerelease
if: steps.version.outputs.is_tag == 'true'
id: is_prerelease
run: |
if [[ "${{ steps.version.outputs.version }}" == *-* ]]; then
echo "prerelease=true" >> $GITHUB_OUTPUT
else
echo "prerelease=false" >> $GITHUB_OUTPUT
fi
build_images:
needs: setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# kthena-router
- service: kthena-router
context: .
dockerfile: ./docker/Dockerfile.kthena-router
os: ubuntu-latest
platform: linux/amd64
- service: kthena-router
context: .
dockerfile: ./docker/Dockerfile.kthena-router
os: ubuntu-24.04-arm
platform: linux/arm64
# kthena-controller-manager
- service: kthena-controller-manager
context: .
dockerfile: ./docker/Dockerfile.kthena-controller-manager
os: ubuntu-latest
platform: linux/amd64
- service: kthena-controller-manager
context: .
dockerfile: ./docker/Dockerfile.kthena-controller-manager
os: ubuntu-24.04-arm
platform: linux/arm64
# downloader
- service: downloader
context: ./python
dockerfile: ./python/Dockerfile
target: downloader
os: ubuntu-latest
platform: linux/amd64
- service: downloader
context: ./python
dockerfile: ./python/Dockerfile
target: downloader
os: ubuntu-24.04-arm
platform: linux/arm64
# runtime
- service: runtime
context: ./python
dockerfile: ./python/Dockerfile
target: runtime
os: ubuntu-latest
platform: linux/amd64
- service: runtime
context: ./python
dockerfile: ./python/Dockerfile
target: runtime
os: ubuntu-24.04-arm
platform: linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Image Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}
tags: |
type=raw,value=${{ needs.setup.outputs.version }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push Docker Images
uses: docker/build-push-action@v6
id: build
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
target: ${{ matrix.target }}
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository_owner }}/${{ matrix.service }},push-by-digest=${{ github.event_name != 'pull_request' }},name-canonical=true,push=${{ github.event_name != 'pull_request' }}
- name: Export digest
if: ${{ github.event_name != 'pull_request' }}
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.service }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
# merge images: Create Multi-Arch Manifests
merge_images:
needs: [ setup, build_images ]
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
strategy:
matrix:
include:
- service: kthena-router
- service: kthena-controller-manager
- service: downloader
- service: runtime
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-${{ matrix.service }}-*
merge-multiple: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Image Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}
tags: |
type=raw,value=${{ needs.setup.outputs.version }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
env:
DOCKER_METADATA_OUTPUT_JSON: ${{ steps.meta.outputs.json }}
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}:${{ needs.setup.outputs.version }}
build_cli:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: linux
arch: amd64
goos: linux
goarch: amd64
ext: ""
- os: linux
arch: arm64
goos: linux
goarch: arm64
ext: ""
- os: darwin
arch: amd64
goos: darwin
goarch: amd64
ext: ""
- os: darwin
arch: arm64
goos: darwin
goarch: arm64
ext: ""
- os: windows
arch: amd64
goos: windows
goarch: amd64
ext: ".exe"
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
go build -o kthena${{ matrix.ext }} ./cli/kthena
- name: Package binary
run: |
VERSION="${{ needs.setup.outputs.version }}"
OS="${{ matrix.os }}"
ARCH="${{ matrix.arch }}"
BINARY_NAME="kthena${{ matrix.ext }}"
ARCHIVE_NAME="kthena-cli-${OS}-${ARCH}"
if [[ "${{ matrix.os }}" == "windows" ]]; then
zip -j "${ARCHIVE_NAME}.zip" "${BINARY_NAME}"
echo "archive_path=${ARCHIVE_NAME}.zip" >> $GITHUB_ENV
else
tar -czf "${ARCHIVE_NAME}.tar.gz" "${BINARY_NAME}"
echo "archive_path=${ARCHIVE_NAME}.tar.gz" >> $GITHUB_ENV
fi
- name: Upload CLI Binary
if: ${{ needs.setup.outputs.is_tag == 'true' }}
uses: actions/upload-artifact@v4
with:
name: cli-binaries-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ env.archive_path }}
retention-days: 1
push_helm_chart:
needs: [ setup, merge_images ]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Helm
uses: azure/setup-helm@v4
- name: Setup yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.1/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Login to GHCR
if: github.event_name != 'pull_request'
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Update Chart and Package
env:
VERSION: ${{ needs.setup.outputs.version }}
run: |
CHART_PATH="charts/kthena"
yq e -i '.version = "'$VERSION'"' $CHART_PATH/Chart.yaml
yq e -i '.appVersion = "'$VERSION'"' $CHART_PATH/Chart.yaml
yq e -i '
.workload.controllerManager.image.tag = "'$VERSION'" |
.workload.controllerManager.downloaderImage.tag = "'$VERSION'" |
.workload.controllerManager.runtimeImage.tag = "'$VERSION'" |
.networking.kthenaRouter.image.tag = "'$VERSION'"
' $CHART_PATH/values.yaml
helm dependency build $CHART_PATH
helm package $CHART_PATH --version $VERSION --app-version $VERSION
mv kthena-${VERSION}.tgz kthena.tgz
- name: Push to GHCR
if: github.event_name != 'pull_request'
env:
VERSION: ${{ needs.setup.outputs.version }}
REPO_OWNER: ${{ github.repository_owner }}
run: |
LOWER_REPO_OWNER=$(echo "$REPO_OWNER" | tr '[:upper:]' '[:lower:]')
helm push kthena.tgz oci://ghcr.io/$LOWER_REPO_OWNER/charts
- name: Prepare Helm Release Artifacts
if: needs.setup.outputs.is_tag == 'true'
run: |
helm template kthena ./charts/kthena --namespace kthena-system --include-crds > kthena-install.yaml
- name: Upload Helm Release Artifacts
if: needs.setup.outputs.is_tag == 'true'
uses: actions/upload-artifact@v4
with:
name: helm-release-artifacts
path: |
./kthena.tgz
./kthena-install.yaml
create_github_release:
needs: [ setup, push_helm_chart, build_cli ]
if: needs.setup.outputs.is_tag == 'true'
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download Helm Release Artifacts
uses: actions/download-artifact@v4
with:
name: helm-release-artifacts
- name: Download CLI Binaries
uses: actions/download-artifact@v4
with:
path: ./cli-binaries
pattern: cli-binaries-*
merge-multiple: true
- name: Create Github Release
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ needs.setup.outputs.prerelease }}
body: |
This release includes the following artifacts:
- **Helm Chart**: `kthena.tgz` (OCI artifact pushed to GHCR)
- **Installation YAML**: `kthena-install.yaml`
- **CLI Binaries**: Pre-built binaries for Linux (amd64/arm64), macOS (amd64/arm64), and Windows (amd64)
### Documentation
- [Installation](https://kthena.volcano.sh/docs/getting-started/installation)
- [Quick Start](https://kthena.volcano.sh/docs/getting-started/quick-start)
- [Helm Chart Values](https://kthena.volcano.sh/docs/reference/helm-chart-values)
- [CLI Reference](https://kthena.volcano.sh/docs/reference/kthena-cli)
---
*Release notes are automatically generated from commits.*
generate_release_notes: true
files: |
./kthena.tgz
./kthena-install.yaml
./cli-binaries/*