forked from kubeflow/spark-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (162 loc) · 5.88 KB
/
release.yaml
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
name: Release Charts
on:
push:
branches:
- master
env:
REGISTRY_IMAGE: docker.io/kubeflow/spark-operator
jobs:
build-skip-check:
runs-on: ubuntu-latest
outputs:
image_changed: ${{ steps.skip-check.outputs.image_changed }}
chart_changed: ${{ steps.skip-check.outputs.chart_changed }}
app_version_tag: ${{ steps.skip-check.outputs.app_version_tag }}
chart_version_tag: ${{ steps.skip-check.outputs.chart_version_tag }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if build should be skipped
id: skip-check
run: |
app_version_tag=$(cat charts/spark-operator-chart/Chart.yaml | grep "appVersion: .*" | cut -c13-)
chart_version_tag=$(cat charts/spark-operator-chart/Chart.yaml | grep "version: .*" | cut -c10-)
# Initialize flags
image_changed=false
chart_changed=false
if ! git rev-parse -q --verify "refs/tags/$app_version_tag"; then
image_changed=true
git tag $app_version_tag
git push origin $app_version_tag
echo "Spark-Operator Docker Image new tag: $app_version_tag released"
fi
if ! git rev-parse -q --verify "refs/tags/spark-operator-chart-$chart_version_tag"; then
chart_changed=true
git tag spark-operator-chart-$chart_version_tag
git push origin spark-operator-chart-$chart_version_tag
echo "Spark-Operator Helm Chart new tag: spark-operator-chart-$chart_version_tag released"
fi
echo "image_changed=${image_changed}" >> "$GITHUB_OUTPUT"
echo "chart_changed=${chart_changed}" >> "$GITHUB_OUTPUT"
echo "app_version_tag=${app_version_tag}" >> "$GITHUB_OUTPUT"
echo "chart_version_tag=${chart_version_tag}" >> "$GITHUB_OUTPUT"
release:
runs-on: ubuntu-latest
needs:
- build-skip-check
if: needs.build-skip-check.outputs.image_changed == 'true'
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
echo "SCOPE=${platform//\//-}" >> $GITHUB_ENV
- name: Set up QEMU
timeout-minutes: 1
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.14.3
- name: Login to Packages Container registry
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Spark-Operator Docker Image to Docker Hub
id: build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ env.SCOPE }}
cache-from: type=gha,scope=${{ env.SCOPE }}
push: true
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
publish-image:
runs-on: ubuntu-latest
needs:
- release
- build-skip-check
if: needs.build-skip-check.outputs.image_changed == 'true'
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
pattern: digests-*
path: /tmp/digests
merge-multiple: true
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: ${{ needs.build-skip-check.outputs.app_version_tag }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
publish-chart:
runs-on: ubuntu-latest
if: needs.build-skip-check.outputs.chart_changed == 'true'
needs:
- build-skip-check
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.14.3
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Release Spark-Operator Helm Chart
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NAME_TEMPLATE: "spark-operator-chart-{{ .Version }}"