Skip to content

Commit 3fb6b9d

Browse files
committed
Publish release artifacts (docker images, helm chart) to GHCR
1 parent 789f8cf commit 3fb6b9d

File tree

1 file changed

+97
-34
lines changed

1 file changed

+97
-34
lines changed

.github/workflows/release.yml

Lines changed: 97 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,26 @@ env:
1919
DOCKERHUB_OPERATOR_IMAGE: adobe/zookeeper-operator
2020

2121
jobs:
22-
build:
22+
prepare:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
outputs:
27+
tag: ${{ steps.vars.outputs.tag }}
28+
built_at: ${{ steps.date.outputs.built_at }}
29+
steps:
30+
- name: Get tag name
31+
id: vars
32+
run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
33+
- name: Set Release Date
34+
id: date
35+
run: |
36+
echo "built_at=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT
37+
38+
operator-test:
2339
runs-on: ubuntu-latest
2440
permissions:
2541
contents: read
26-
packages: write
2742
steps:
2843
- name: Checkout code
2944
uses: actions/checkout@v5
@@ -42,82 +57,125 @@ jobs:
4257
run: make check
4358
- name: unit tests
4459
run: make test
45-
- name: Get tag name
46-
id: vars
47-
run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
48-
- name: Set Release Date
49-
run: |
50-
echo "BUILT_AT=$(date --rfc-3339=date)" >> ${GITHUB_ENV}
5160

61+
build-zookeeper-apache:
62+
runs-on: ubuntu-latest
63+
needs: prepare
64+
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
65+
permissions:
66+
contents: read
67+
packages: write
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v5
5271
- name: Set up QEMU
5372
uses: docker/setup-qemu-action@v3
5473
- name: Set up Docker Buildx
5574
uses: docker/setup-buildx-action@v3
56-
# Login against Docker Hub
5775
- name: Login to DockerHub Registry
5876
uses: docker/login-action@v3
5977
with:
6078
username: ${{ secrets.DOCKER_USERNAME }}
6179
password: ${{ secrets.DOCKER_PASSWORD }}
62-
# Login against GitHub Container Registry
6380
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
6481
uses: docker/login-action@v3
6582
with:
6683
registry: ${{ env.GHCR_REGISTRY }}
6784
username: ${{ github.actor }}
6885
password: ${{ secrets.GITHUB_TOKEN }}
69-
70-
# Extract metadata for zookeeper Apache image
7186
- name: Extract Docker metadata for zookeeper Apache
72-
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
7387
id: meta-zk-apache
7488
uses: docker/metadata-action@v5
7589
with:
7690
images: |
7791
${{ env.DOCKERHUB_ZK_IMAGE }}
7892
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
7993
tags: |
80-
type=raw,value=3.8.4-apache-${{ steps.vars.outputs.tag }}
94+
type=raw,value=3.8.4-apache-${{ needs.prepare.outputs.tag }}
8195
labels: |
8296
org.opencontainers.image.description=Apache Zookeeper 3.8.4 with OpenJDK 21
8397
- name: Build and push zookeeper Apache image
8498
uses: docker/build-push-action@v6
85-
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
8699
with:
87100
context: docker/zookeeper-image
88101
platforms: linux/amd64,linux/arm64
89102
tags: ${{ steps.meta-zk-apache.outputs.tags }}
90103
labels: ${{ steps.meta-zk-apache.outputs.labels }}
91104
annotations: ${{ steps.meta-zk-apache.outputs.annotations }}
92-
push: ${{ startsWith(github.ref, 'refs/tags/zk') }}
105+
push: true
93106

94-
# Extract metadata for zookeeper image
107+
build-zookeeper:
108+
runs-on: ubuntu-latest
109+
needs: [prepare, operator-test]
110+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
111+
permissions:
112+
contents: read
113+
packages: write
114+
steps:
115+
- name: Checkout code
116+
uses: actions/checkout@v5
117+
- name: Set up QEMU
118+
uses: docker/setup-qemu-action@v3
119+
- name: Set up Docker Buildx
120+
uses: docker/setup-buildx-action@v3
121+
- name: Login to DockerHub Registry
122+
uses: docker/login-action@v3
123+
with:
124+
username: ${{ secrets.DOCKER_USERNAME }}
125+
password: ${{ secrets.DOCKER_PASSWORD }}
126+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
127+
uses: docker/login-action@v3
128+
with:
129+
registry: ${{ env.GHCR_REGISTRY }}
130+
username: ${{ github.actor }}
131+
password: ${{ secrets.GITHUB_TOKEN }}
95132
- name: Extract Docker metadata for zookeeper
96-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
97133
id: meta-zk
98134
uses: docker/metadata-action@v5
99135
with:
100136
images: |
101137
${{ env.DOCKERHUB_ZK_IMAGE }}
102138
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
103139
tags: |
104-
type=raw,value=3.8.4-${{ steps.vars.outputs.tag }}
140+
type=raw,value=3.8.4-${{ needs.prepare.outputs.tag }}
105141
labels: |
106142
org.opencontainers.image.description=Apache Zookeeper image build with java-21
107143
- name: Build and push zookeeper image
108-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
109144
uses: docker/build-push-action@v6
110145
with:
111146
context: docker
112147
platforms: linux/amd64,linux/arm64
113148
tags: ${{ steps.meta-zk.outputs.tags }}
114149
labels: ${{ steps.meta-zk.outputs.labels }}
115150
annotations: ${{ steps.meta-zk.outputs.annotations }}
116-
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
151+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
117152

118-
# Extract metadata for zookeeper-operator image
153+
build-operator:
154+
runs-on: ubuntu-latest
155+
needs: [prepare, operator-test]
156+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
157+
permissions:
158+
contents: read
159+
packages: write
160+
steps:
161+
- name: Checkout code
162+
uses: actions/checkout@v5
163+
- name: Set up QEMU
164+
uses: docker/setup-qemu-action@v3
165+
- name: Set up Docker Buildx
166+
uses: docker/setup-buildx-action@v3
167+
- name: Login to DockerHub Registry
168+
uses: docker/login-action@v3
169+
with:
170+
username: ${{ secrets.DOCKER_USERNAME }}
171+
password: ${{ secrets.DOCKER_PASSWORD }}
172+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
173+
uses: docker/login-action@v3
174+
with:
175+
registry: ${{ env.GHCR_REGISTRY }}
176+
username: ${{ github.actor }}
177+
password: ${{ secrets.GITHUB_TOKEN }}
119178
- name: Extract Docker metadata for zookeeper-operator
120-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
121179
id: meta-operator
122180
uses: docker/metadata-action@v5
123181
with:
@@ -129,35 +187,40 @@ jobs:
129187
labels: |
130188
org.opencontainers.image.description=Zookeeper Operator for Kubernetes
131189
- name: Build and push zookeeper-operator image
132-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
133190
uses: docker/build-push-action@v6
134191
with:
135192
context: .
136193
platforms: linux/amd64,linux/arm64
137194
build-args: |
138195
VERSION=${{ fromJSON(steps.meta-operator.outputs.json).labels['org.opencontainers.image.version'] }}
139-
BUILT_AT=${{ env.BUILT_AT }}
196+
BUILT_AT=${{ needs.prepare.outputs.built_at }}
140197
GIT_SHA=${{ github.sha }}
141198
tags: ${{ steps.meta-operator.outputs.tags }}
142199
labels: ${{ steps.meta-operator.outputs.labels }}
143200
annotations: ${{ steps.meta-operator.outputs.annotations }}
144-
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
201+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
145202

146-
# Update Helm Chart version
203+
release-helm:
204+
runs-on: ubuntu-latest
205+
needs: [prepare, build-zookeeper, build-operator]
206+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
207+
permissions:
208+
contents: read
209+
packages: write
210+
steps:
211+
- name: Checkout code
212+
uses: actions/checkout@v5
147213
- name: Update Chart.yaml version
148-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
149214
run: |
150-
sed -i "s/^version:.*/version: \"${{ steps.vars.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
151-
sed -i "s/^appVersion:.*/appVersion: \"${{ steps.vars.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
152-
sed -i "/^image:/,/^[^ ]/ s/^ tag:.*/ tag: ${{ steps.vars.outputs.tag }}/" charts/zookeeper-operator/values.yaml
153-
# Push Helm Chart to GitHub Container Registry
215+
sed -i "s/^version:.*/version: \"${{ needs.prepare.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
216+
sed -i "s/^appVersion:.*/appVersion: \"${{ needs.prepare.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
217+
sed -i "/^image:/,/^[^ ]/ s/^ tag:.*/ tag: ${{ needs.prepare.outputs.tag }}/" charts/zookeeper-operator/values.yaml
154218
- name: Push Helm Chart to GHCR
155-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
156219
uses: appany/[email protected]
157220
with:
158221
name: zookeeper-operator
159222
repository: ${{ github.repository_owner }}/helm-charts
160-
tag: ${{ steps.vars.outputs.tag }}
223+
tag: ${{ needs.prepare.outputs.tag }}
161224
path: charts/zookeeper-operator
162225
registry: ${{ env.GHCR_REGISTRY }}
163226
registry_username: ${{ github.actor }}

0 commit comments

Comments
 (0)