Skip to content

Commit a4c9894

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

File tree

16 files changed

+334
-761
lines changed

16 files changed

+334
-761
lines changed

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

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

.github/workflows/release.yml

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
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+
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:
39+
runs-on: ubuntu-latest
40+
permissions:
41+
contents: read
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v5
45+
- name: Set up Go 1.25
46+
uses: actions/setup-go@v2
47+
with:
48+
go-version: 1.25
49+
id: go
50+
- name: Set up Go for root
51+
run: |
52+
sudo ln -sf `which go` `sudo which go` || true
53+
sudo go version
54+
- name: get go version
55+
run: go version
56+
- name: Gofmt and License checks
57+
run: make check
58+
- name: unit tests
59+
run: make test
60+
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
71+
- name: Set up QEMU
72+
uses: docker/setup-qemu-action@v3
73+
- name: Set up Docker Buildx
74+
uses: docker/setup-buildx-action@v3
75+
- name: Login to DockerHub Registry
76+
uses: docker/login-action@v3
77+
with:
78+
username: ${{ secrets.DOCKER_USERNAME }}
79+
password: ${{ secrets.DOCKER_PASSWORD }}
80+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
81+
uses: docker/login-action@v3
82+
with:
83+
registry: ${{ env.GHCR_REGISTRY }}
84+
username: ${{ github.actor }}
85+
password: ${{ secrets.GITHUB_TOKEN }}
86+
- name: Extract Docker metadata for zookeeper Apache
87+
id: meta-zk-apache
88+
uses: docker/metadata-action@v5
89+
with:
90+
images: |
91+
${{ env.DOCKERHUB_ZK_IMAGE }}
92+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
93+
tags: |
94+
type=raw,value=3.8.4-apache-${{ needs.prepare.outputs.tag }}
95+
labels: |
96+
org.opencontainers.image.description=Apache Zookeeper 3.8.4 with OpenJDK 21
97+
- name: Build and push zookeeper Apache image
98+
uses: docker/build-push-action@v6
99+
with:
100+
context: docker/zookeeper-image
101+
platforms: linux/amd64,linux/arm64
102+
tags: ${{ steps.meta-zk-apache.outputs.tags }}
103+
labels: ${{ steps.meta-zk-apache.outputs.labels }}
104+
annotations: ${{ steps.meta-zk-apache.outputs.annotations }}
105+
push: true
106+
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 }}
132+
- name: Extract Docker metadata for zookeeper
133+
id: meta-zk
134+
uses: docker/metadata-action@v5
135+
with:
136+
images: |
137+
${{ env.DOCKERHUB_ZK_IMAGE }}
138+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
139+
tags: |
140+
type=raw,value=3.8.4-${{ needs.prepare.outputs.tag }}
141+
labels: |
142+
org.opencontainers.image.description=Apache Zookeeper image build with java-21
143+
- name: Build and push zookeeper image
144+
uses: docker/build-push-action@v6
145+
with:
146+
context: docker
147+
platforms: linux/amd64,linux/arm64
148+
tags: ${{ steps.meta-zk.outputs.tags }}
149+
labels: ${{ steps.meta-zk.outputs.labels }}
150+
annotations: ${{ steps.meta-zk.outputs.annotations }}
151+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
152+
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 }}
178+
- name: Extract Docker metadata for zookeeper-operator
179+
id: meta-operator
180+
uses: docker/metadata-action@v5
181+
with:
182+
images: |
183+
${{ env.DOCKERHUB_OPERATOR_IMAGE }}
184+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}
185+
tags: |
186+
type=ref,event=tag
187+
labels: |
188+
org.opencontainers.image.description=Zookeeper Operator for Kubernetes
189+
- name: Build and push zookeeper-operator image
190+
uses: docker/build-push-action@v6
191+
with:
192+
context: .
193+
platforms: linux/amd64,linux/arm64
194+
build-args: |
195+
VERSION=${{ fromJSON(steps.meta-operator.outputs.json).labels['org.opencontainers.image.version'] }}
196+
BUILT_AT=${{ needs.prepare.outputs.built_at }}
197+
GIT_SHA=${{ github.sha }}
198+
tags: ${{ steps.meta-operator.outputs.tags }}
199+
labels: ${{ steps.meta-operator.outputs.labels }}
200+
annotations: ${{ steps.meta-operator.outputs.annotations }}
201+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
202+
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
213+
- name: Update Chart.yaml version
214+
run: |
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
218+
- name: Push Helm Chart to GHCR
219+
uses: appany/[email protected]
220+
with:
221+
name: zookeeper-operator
222+
repository: ${{ github.repository_owner }}/helm-charts
223+
tag: ${{ needs.prepare.outputs.tag }}
224+
path: charts/zookeeper-operator
225+
registry: ${{ env.GHCR_REGISTRY }}
226+
registry_username: ${{ github.actor }}
227+
registry_password: ${{ secrets.GITHUB_TOKEN }}
228+
update_dependencies: 'true'

Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG ALPINE_VERSION=3.22
44
FROM ${DOCKER_REGISTRY:+$DOCKER_REGISTRY/}golang:1.25-alpine${ALPINE_VERSION} AS go-builder
55

66
ARG PROJECT_NAME=zookeeper-operator
7-
ARG REPO_PATH=github.com/pravega/$PROJECT_NAME
7+
ARG REPO_PATH=github.com/adobe/$PROJECT_NAME
88

99
# Build version and commit should be passed in when performing docker build
1010
ARG VERSION=0.0.0-localdev
@@ -31,8 +31,24 @@ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /src/${PROJECT_NAME} \
3131

3232
FROM ${DISTROLESS_DOCKER_REGISTRY:-gcr.io/}distroless/static-debian11:nonroot AS final
3333

34+
# Re-declare ARG variables for the final stage
3435
ARG PROJECT_NAME=zookeeper-operator
36+
ARG VERSION=0.0.0-localdev
37+
ARG GIT_SHA=0000000
38+
ARG BUILT_AT
3539

3640
COPY --from=go-builder /src/${PROJECT_NAME} /usr/local/bin/${PROJECT_NAME}
3741

42+
# OCI standard labels
43+
LABEL org.opencontainers.image.title="Zookeeper Operator"
44+
LABEL org.opencontainers.image.description="Zookeeper Operator for Kubernetes"
45+
LABEL org.opencontainers.image.version="${VERSION}"
46+
LABEL org.opencontainers.image.revision="${GIT_SHA}"
47+
LABEL org.opencontainers.image.created="${BUILT_AT}"
48+
LABEL org.opencontainers.image.source="https://github.com/adobe/zookeeper-operator"
49+
LABEL org.opencontainers.image.url="https://github.com/adobe/zookeeper-operator"
50+
LABEL org.opencontainers.image.documentation="https://github.com/adobe/zookeeper-operator"
51+
LABEL org.opencontainers.image.vendor="Adobe"
52+
LABEL org.opencontainers.image.licenses="Apache-2.0"
53+
3854
ENTRYPOINT ["/usr/local/bin/zookeeper-operator"]

0 commit comments

Comments
 (0)