Skip to content

Commit a543e9e

Browse files
committed
Update release workflow
Signed-off-by: Yi Chen <[email protected]>
1 parent 3ebe3d0 commit a543e9e

File tree

1 file changed

+136
-13
lines changed

1 file changed

+136
-13
lines changed

.github/workflows/release.yaml

Lines changed: 136 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ concurrency:
1414
env:
1515
SEMVER_PATTERN: '^v([0-9]+)\.([0-9]+)\.([0-9]+)(-rc\.([0-9]+))?$'
1616
IMAGE_REGISTRY: ghcr.io
17-
IMAGE_REPOSITORY: kubeflow/spark-operator/controller
17+
OPERATOR_IMAGE_REPOSITORY: kubeflow/spark-operator/controller
18+
KUBECTL_IMAGE_REPOSITORY: kubeflow/spark-operator/kubectl
1819

1920
jobs:
2021
check-release:
@@ -65,7 +66,7 @@ jobs:
6566
echo "Tag '${VERSION}' does not exist."
6667
fi
6768
68-
build_images:
69+
build_operator_images:
6970
needs:
7071
- check-release
7172

@@ -96,7 +97,7 @@ jobs:
9697
id: meta
9798
uses: docker/metadata-action@v5
9899
with:
99-
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}
100+
images: ${{ env.IMAGE_REGISTRY }}/${{ env.OPERATOR_IMAGE_REPOSITORY }}
100101
tags: |
101102
type=semver,pattern={{version}},value=${{ env.VERSION }}
102103
@@ -119,7 +120,7 @@ jobs:
119120
with:
120121
platforms: ${{ matrix.platform }}
121122
labels: ${{ steps.meta.outputs.labels }}
122-
outputs: type=image,name=${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }},push-by-digest=true,name-canonical=true,push=true
123+
outputs: type=image,name=${{ env.IMAGE_REGISTRY }}/${{ env.OPERATOR_IMAGE_REPOSITORY }},push-by-digest=true,name-canonical=true,push=true
123124

124125
- name: Export digest
125126
run: |
@@ -130,14 +131,85 @@ jobs:
130131
- name: Upload digest
131132
uses: actions/upload-artifact@v4
132133
with:
133-
name: digests-${{ env.PLATFORM_PAIR }}
134+
name: digests-operator-${{ env.PLATFORM_PAIR }}
134135
path: /tmp/digests/*
135136
if-no-files-found: error
136137
retention-days: 1
137138

138-
release_images:
139+
build_kubectl_images:
139140
needs:
140-
- build_images
141+
- check-release
142+
143+
runs-on: ubuntu-latest
144+
145+
strategy:
146+
fail-fast: false
147+
matrix:
148+
platform:
149+
- linux/amd64
150+
- linux/arm64
151+
152+
steps:
153+
- name: Prepare
154+
run: |
155+
platform=${{ matrix.platform }}
156+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
157+
158+
- name: Checkout source code
159+
uses: actions/checkout@v4
160+
161+
- name: Read version from VERSION file
162+
run: |
163+
VERSION=$(cat VERSION)
164+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
165+
166+
- name: Docker meta
167+
id: meta
168+
uses: docker/metadata-action@v5
169+
with:
170+
images: ${{ env.IMAGE_REGISTRY }}/${{ env.KUBECTL_IMAGE_REPOSITORY }}
171+
tags: |
172+
type=semver,pattern={{version}},value=${{ env.VERSION }}
173+
174+
- name: Set up QEMU
175+
uses: docker/setup-qemu-action@v3
176+
177+
- name: Set up Docker buildx
178+
uses: docker/setup-buildx-action@v3
179+
180+
- name: Login to container registry
181+
uses: docker/login-action@v3
182+
with:
183+
registry: ${{ env.IMAGE_REGISTRY }}
184+
username: ${{ github.actor }}
185+
password: ${{ secrets.GITHUB_TOKEN }}
186+
187+
- name: Build and push by digest
188+
id: build
189+
uses: docker/build-push-action@v6
190+
with:
191+
file: docker/Dockerfile.kubectl
192+
platforms: ${{ matrix.platform }}
193+
labels: ${{ steps.meta.outputs.labels }}
194+
outputs: type=image,name=${{ env.IMAGE_REGISTRY }}/${{ env.KUBECTL_IMAGE_REPOSITORY }},push-by-digest=true,name-canonical=true,push=true
195+
196+
- name: Export digest
197+
run: |
198+
mkdir -p /tmp/digests
199+
digest="${{ steps.build.outputs.digest }}"
200+
touch "/tmp/digests/${digest#sha256:}"
201+
202+
- name: Upload digest
203+
uses: actions/upload-artifact@v4
204+
with:
205+
name: digests-kubectl-${{ env.PLATFORM_PAIR }}
206+
path: /tmp/digests/*
207+
if-no-files-found: error
208+
retention-days: 1
209+
210+
release_operator_images:
211+
needs:
212+
- build_operator_images
141213

142214
runs-on: ubuntu-latest
143215

@@ -154,7 +226,7 @@ jobs:
154226
id: meta
155227
uses: docker/metadata-action@v5
156228
with:
157-
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}
229+
images: ${{ env.IMAGE_REGISTRY }}/${{ env.OPERATOR_IMAGE_REPOSITORY }}
158230
tags: |
159231
type=semver,pattern={{version}},value=${{ env.VERSION }}
160232
@@ -179,15 +251,66 @@ jobs:
179251
working-directory: /tmp/digests
180252
run: |
181253
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
182-
$(printf '${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}@sha256:%s ' *)
254+
$(printf '${{ env.IMAGE_REGISTRY }}/${{ env.OPERATOR_IMAGE_REPOSITORY }}@sha256:%s ' *)
255+
256+
- name: Inspect image
257+
run: |
258+
docker buildx imagetools inspect ${{ env.IMAGE_REGISTRY }}/${{ env.OPERATOR_IMAGE_REPOSITORY }}:${{ steps.meta.outputs.version }}
259+
260+
release_kubectl_images:
261+
needs:
262+
- build_kubectl_images
263+
264+
runs-on: ubuntu-latest
265+
266+
steps:
267+
- name: Checkout source code
268+
uses: actions/checkout@v4
269+
270+
- name: Read version from VERSION file
271+
run: |
272+
VERSION=$(cat VERSION)
273+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
274+
275+
- name: Docker meta
276+
id: meta
277+
uses: docker/metadata-action@v5
278+
with:
279+
images: ${{ env.IMAGE_REGISTRY }}/${{ env.KUBECTL_IMAGE_REPOSITORY }}
280+
tags: |
281+
type=semver,pattern={{version}},value=${{ env.VERSION }}
282+
283+
- name: Download digests
284+
uses: actions/download-artifact@v4
285+
with:
286+
path: /tmp/digests
287+
pattern: digests-kubectl-*
288+
merge-multiple: true
289+
290+
- name: Set up Docker buildx
291+
uses: docker/setup-buildx-action@v3
292+
293+
- name: Login to container registry
294+
uses: docker/login-action@v3
295+
with:
296+
registry: ${{ env.IMAGE_REGISTRY }}
297+
username: ${{ github.actor }}
298+
password: ${{ secrets.GITHUB_TOKEN }}
299+
300+
- name: Create manifest list and push
301+
working-directory: /tmp/digests
302+
run: |
303+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
304+
$(printf '${{ env.IMAGE_REGISTRY }}/${{ env.KUBECTL_IMAGE_REPOSITORY }}@sha256:%s ' *)
183305
184306
- name: Inspect image
185307
run: |
186-
docker buildx imagetools inspect ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_REPOSITORY }}:${{ steps.meta.outputs.version }}
308+
docker buildx imagetools inspect ${{ env.IMAGE_REGISTRY }}/${{ env.KUBECTL_IMAGE_REPOSITORY }}:${{ steps.meta.outputs.version }}
187309
188310
push_tag:
189311
needs:
190-
- release_images
312+
- release_operator_images
313+
- release_kubectl_images
191314

192315
runs-on: ubuntu-latest
193316

@@ -209,7 +332,7 @@ jobs:
209332
210333
- name: Create and push tag
211334
run: |
212-
git tag -a "${VERSION}" -m "Spark Operator Official Release ${VERSION}"
335+
git tag -a "${VERSION}" -m "Official Release ${VERSION}"
213336
git push origin "${VERSION}"
214337
215338
draft_release:
@@ -251,7 +374,7 @@ jobs:
251374
uses: softprops/action-gh-release@v2
252375
with:
253376
token: ${{ secrets.GITHUB_TOKEN }}
254-
name: "Spark Operator ${{ env.VERSION }}"
377+
name: ${{ env.VERSION }}
255378
tag_name: ${{ env.VERSION }}
256379
prerelease: ${{ contains(env.VERSION, 'rc') }}
257380
target_commitish: ${{ github.sha }}

0 commit comments

Comments
 (0)