Skip to content

Commit cd25ab5

Browse files
committed
Publish release artifacts (docker images, helm chart) to GHCR
1 parent d8126e0 commit cd25ab5

File tree

13 files changed

+224
-760
lines changed

13 files changed

+224
-760
lines changed

.github/workflows/build-push-docker.yml

Lines changed: 0 additions & 84 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
# GitHub Container Registry
14+
GHCR_REGISTRY: ghcr.io
15+
# github.repository as <account>/<repo>
16+
GHCR_IMAGE_NAME: ${{ github.repository }}
17+
# Docker Hub image names
18+
DOCKERHUB_ZK_IMAGE: adobe/zookeeper
19+
DOCKERHUB_OPERATOR_IMAGE: adobe/zookeeper-operator
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v5
30+
- name: Set up Go 1.25
31+
uses: actions/setup-go@v2
32+
with:
33+
go-version: 1.25
34+
id: go
35+
- name: Set up Go for root
36+
run: |
37+
sudo ln -sf `which go` `sudo which go` || true
38+
sudo go version
39+
- name: get go version
40+
run: go version
41+
- name: Gofmt and License checks
42+
run: make check
43+
- name: unit tests
44+
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}
51+
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v3
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
# Login against Docker Hub
57+
- name: Login to DockerHub Registry
58+
uses: docker/login-action@v3
59+
with:
60+
username: ${{ secrets.DOCKER_USERNAME }}
61+
password: ${{ secrets.DOCKER_PASSWORD }}
62+
# Login against GitHub Container Registry
63+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ${{ env.GHCR_REGISTRY }}
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
# Extract metadata for zookeeper Apache image
71+
- name: Extract Docker metadata for zookeeper Apache
72+
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
73+
id: meta-zk-apache
74+
uses: docker/metadata-action@v5
75+
with:
76+
images: |
77+
${{ env.DOCKERHUB_ZK_IMAGE }}
78+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
79+
tags: |
80+
type=raw,value=3.8.4-apache-${{ steps.vars.outputs.tag }}
81+
- name: Build and push zookeeper Apache image
82+
uses: docker/build-push-action@v6
83+
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
84+
with:
85+
context: docker/zookeeper-image
86+
platforms: linux/amd64,linux/arm64
87+
tags: ${{ steps.meta-zk-apache.outputs.tags }}
88+
labels: ${{ steps.meta-zk-apache.outputs.labels }}
89+
push: ${{ startsWith(github.ref, 'refs/tags/zk') }}
90+
91+
# Extract metadata for zookeeper image
92+
- name: Extract Docker metadata for zookeeper
93+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
94+
id: meta-zk
95+
uses: docker/metadata-action@v5
96+
with:
97+
images: |
98+
${{ env.DOCKERHUB_ZK_IMAGE }}
99+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
100+
tags: |
101+
type=raw,value=3.8.4-${{ steps.vars.outputs.tag }}
102+
labels: |
103+
org.opencontainers.image.description=Apache Zookeeper image build with java-21
104+
- name: Build and push zookeeper image
105+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
106+
uses: docker/build-push-action@v6
107+
with:
108+
context: docker
109+
platforms: linux/amd64,linux/arm64
110+
tags: ${{ steps.meta-zk.outputs.tags }}
111+
labels: ${{ steps.meta-zk.outputs.labels }}
112+
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
113+
114+
# Extract metadata for zookeeper-operator image
115+
- name: Extract Docker metadata for zookeeper-operator
116+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
117+
id: meta-operator
118+
uses: docker/metadata-action@v5
119+
with:
120+
images: |
121+
${{ env.DOCKERHUB_OPERATOR_IMAGE }}
122+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}
123+
tags: |
124+
type=ref,event=tag
125+
labels: |
126+
org.opencontainers.image.description=Zookeeper Operator for Kubernetes
127+
- name: Build and push zookeeper-operator image
128+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
129+
uses: docker/build-push-action@v6
130+
with:
131+
context: .
132+
platforms: linux/amd64,linux/arm64
133+
build-args: |
134+
VERSION=${{ fromJSON(steps.meta-operator.outputs.json).labels['org.opencontainers.image.version'] }}
135+
BUILT_AT=$(date --rfc-3339=date)
136+
GIT_SHA=${{ github.sha }}
137+
tags: ${{ steps.meta-operator.outputs.tags }}
138+
labels: ${{ steps.meta-operator.outputs.labels }}
139+
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
140+
141+
# Update Helm Chart version
142+
- name: Update Chart.yaml version
143+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
144+
run: |
145+
sed -i "s/^version:.*/version: \"${{ steps.vars.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
146+
sed -i "s/^appVersion:.*/appVersion: \"${{ steps.vars.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
147+
sed -i "/^image:/,/^[^ ]/ s/^ tag:.*/ tag: ${{ steps.vars.outputs.tag }}/" charts/zookeeper-operator/values.yaml
148+
# Push Helm Chart to GitHub Container Registry
149+
- name: Push Helm Chart to GHCR
150+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
151+
uses: appany/[email protected]
152+
with:
153+
name: zookeeper-operator
154+
repository: ${{ github.repository_owner }}/helm-charts
155+
tag: ${{ steps.vars.outputs.tag }}
156+
path: charts/zookeeper-operator
157+
registry: ${{ env.GHCR_REGISTRY }}
158+
registry_username: ${{ github.actor }}
159+
registry_password: ${{ secrets.GITHUB_TOKEN }}
160+
update_dependencies: 'true'

0 commit comments

Comments
 (0)