Skip to content

Commit 274d394

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

File tree

1 file changed

+86
-29
lines changed

1 file changed

+86
-29
lines changed

.github/workflows/release.yml

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

2121
jobs:
22-
build:
22+
test:
2323
runs-on: ubuntu-latest
2424
permissions:
2525
contents: read
26-
packages: write
26+
outputs:
27+
tag: ${{ steps.vars.outputs.tag }}
28+
built_at: ${{ steps.date.outputs.built_at }}
2729
steps:
2830
- name: Checkout code
2931
uses: actions/checkout@v5
@@ -46,78 +48,128 @@ jobs:
4648
id: vars
4749
run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
4850
- name: Set Release Date
51+
id: date
4952
run: |
50-
echo "BUILT_AT=$(date --rfc-3339=date)" >> ${GITHUB_ENV}
53+
echo "built_at=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT
5154
55+
build-zookeeper-apache:
56+
runs-on: ubuntu-latest
57+
needs: test
58+
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
59+
permissions:
60+
contents: read
61+
packages: write
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v5
5265
- name: Set up QEMU
5366
uses: docker/setup-qemu-action@v3
5467
- name: Set up Docker Buildx
5568
uses: docker/setup-buildx-action@v3
56-
# Login against Docker Hub
5769
- name: Login to DockerHub Registry
5870
uses: docker/login-action@v3
5971
with:
6072
username: ${{ secrets.DOCKER_USERNAME }}
6173
password: ${{ secrets.DOCKER_PASSWORD }}
62-
# Login against GitHub Container Registry
6374
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
6475
uses: docker/login-action@v3
6576
with:
6677
registry: ${{ env.GHCR_REGISTRY }}
6778
username: ${{ github.actor }}
6879
password: ${{ secrets.GITHUB_TOKEN }}
69-
70-
# Extract metadata for zookeeper Apache image
7180
- name: Extract Docker metadata for zookeeper Apache
72-
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
7381
id: meta-zk-apache
7482
uses: docker/metadata-action@v5
7583
with:
7684
images: |
7785
${{ env.DOCKERHUB_ZK_IMAGE }}
7886
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
7987
tags: |
80-
type=raw,value=3.8.4-apache-${{ steps.vars.outputs.tag }}
88+
type=raw,value=3.8.4-apache-${{ needs.test.outputs.tag }}
8189
labels: |
8290
org.opencontainers.image.description=Apache Zookeeper 3.8.4 with OpenJDK 21
8391
- name: Build and push zookeeper Apache image
8492
uses: docker/build-push-action@v6
85-
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
8693
with:
8794
context: docker/zookeeper-image
8895
platforms: linux/amd64,linux/arm64
8996
tags: ${{ steps.meta-zk-apache.outputs.tags }}
9097
labels: ${{ steps.meta-zk-apache.outputs.labels }}
9198
annotations: ${{ steps.meta-zk-apache.outputs.annotations }}
92-
push: ${{ startsWith(github.ref, 'refs/tags/zk') }}
99+
push: true
93100

94-
# Extract metadata for zookeeper image
101+
build-zookeeper:
102+
runs-on: ubuntu-latest
103+
needs: test
104+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
105+
permissions:
106+
contents: read
107+
packages: write
108+
steps:
109+
- name: Checkout code
110+
uses: actions/checkout@v5
111+
- name: Set up QEMU
112+
uses: docker/setup-qemu-action@v3
113+
- name: Set up Docker Buildx
114+
uses: docker/setup-buildx-action@v3
115+
- name: Login to DockerHub Registry
116+
uses: docker/login-action@v3
117+
with:
118+
username: ${{ secrets.DOCKER_USERNAME }}
119+
password: ${{ secrets.DOCKER_PASSWORD }}
120+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
121+
uses: docker/login-action@v3
122+
with:
123+
registry: ${{ env.GHCR_REGISTRY }}
124+
username: ${{ github.actor }}
125+
password: ${{ secrets.GITHUB_TOKEN }}
95126
- name: Extract Docker metadata for zookeeper
96-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
97127
id: meta-zk
98128
uses: docker/metadata-action@v5
99129
with:
100130
images: |
101131
${{ env.DOCKERHUB_ZK_IMAGE }}
102132
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
103133
tags: |
104-
type=raw,value=3.8.4-${{ steps.vars.outputs.tag }}
134+
type=raw,value=3.8.4-${{ needs.test.outputs.tag }}
105135
labels: |
106136
org.opencontainers.image.description=Apache Zookeeper image build with java-21
107137
- name: Build and push zookeeper image
108-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
109138
uses: docker/build-push-action@v6
110139
with:
111140
context: docker
112141
platforms: linux/amd64,linux/arm64
113142
tags: ${{ steps.meta-zk.outputs.tags }}
114143
labels: ${{ steps.meta-zk.outputs.labels }}
115144
annotations: ${{ steps.meta-zk.outputs.annotations }}
116-
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
145+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
117146

118-
# Extract metadata for zookeeper-operator image
147+
build-operator:
148+
runs-on: ubuntu-latest
149+
needs: test
150+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
151+
permissions:
152+
contents: read
153+
packages: write
154+
steps:
155+
- name: Checkout code
156+
uses: actions/checkout@v5
157+
- name: Set up QEMU
158+
uses: docker/setup-qemu-action@v3
159+
- name: Set up Docker Buildx
160+
uses: docker/setup-buildx-action@v3
161+
- name: Login to DockerHub Registry
162+
uses: docker/login-action@v3
163+
with:
164+
username: ${{ secrets.DOCKER_USERNAME }}
165+
password: ${{ secrets.DOCKER_PASSWORD }}
166+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
167+
uses: docker/login-action@v3
168+
with:
169+
registry: ${{ env.GHCR_REGISTRY }}
170+
username: ${{ github.actor }}
171+
password: ${{ secrets.GITHUB_TOKEN }}
119172
- name: Extract Docker metadata for zookeeper-operator
120-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
121173
id: meta-operator
122174
uses: docker/metadata-action@v5
123175
with:
@@ -129,35 +181,40 @@ jobs:
129181
labels: |
130182
org.opencontainers.image.description=Zookeeper Operator for Kubernetes
131183
- name: Build and push zookeeper-operator image
132-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
133184
uses: docker/build-push-action@v6
134185
with:
135186
context: .
136187
platforms: linux/amd64,linux/arm64
137188
build-args: |
138189
VERSION=${{ fromJSON(steps.meta-operator.outputs.json).labels['org.opencontainers.image.version'] }}
139-
BUILT_AT=${{ env.BUILT_AT }}
190+
BUILT_AT=${{ needs.test.outputs.built_at }}
140191
GIT_SHA=${{ github.sha }}
141192
tags: ${{ steps.meta-operator.outputs.tags }}
142193
labels: ${{ steps.meta-operator.outputs.labels }}
143194
annotations: ${{ steps.meta-operator.outputs.annotations }}
144-
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
195+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
145196

146-
# Update Helm Chart version
197+
release-helm:
198+
runs-on: ubuntu-latest
199+
needs: [test, build-operator]
200+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
201+
permissions:
202+
contents: read
203+
packages: write
204+
steps:
205+
- name: Checkout code
206+
uses: actions/checkout@v5
147207
- name: Update Chart.yaml version
148-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
149208
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
209+
sed -i "s/^version:.*/version: \"${{ needs.test.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
210+
sed -i "s/^appVersion:.*/appVersion: \"${{ needs.test.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
211+
sed -i "/^image:/,/^[^ ]/ s/^ tag:.*/ tag: ${{ needs.test.outputs.tag }}/" charts/zookeeper-operator/values.yaml
154212
- name: Push Helm Chart to GHCR
155-
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
156213
uses: appany/[email protected]
157214
with:
158215
name: zookeeper-operator
159216
repository: ${{ github.repository_owner }}/helm-charts
160-
tag: ${{ steps.vars.outputs.tag }}
217+
tag: ${{ needs.test.outputs.tag }}
161218
path: charts/zookeeper-operator
162219
registry: ${{ env.GHCR_REGISTRY }}
163220
registry_username: ${{ github.actor }}

0 commit comments

Comments
 (0)