Skip to content

Commit 789f8cf

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

File tree

16 files changed

+270
-761
lines changed

16 files changed

+270
-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: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
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+
labels: |
82+
org.opencontainers.image.description=Apache Zookeeper 3.8.4 with OpenJDK 21
83+
- name: Build and push zookeeper Apache image
84+
uses: docker/build-push-action@v6
85+
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
86+
with:
87+
context: docker/zookeeper-image
88+
platforms: linux/amd64,linux/arm64
89+
tags: ${{ steps.meta-zk-apache.outputs.tags }}
90+
labels: ${{ steps.meta-zk-apache.outputs.labels }}
91+
annotations: ${{ steps.meta-zk-apache.outputs.annotations }}
92+
push: ${{ startsWith(github.ref, 'refs/tags/zk') }}
93+
94+
# Extract metadata for zookeeper image
95+
- name: Extract Docker metadata for zookeeper
96+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
97+
id: meta-zk
98+
uses: docker/metadata-action@v5
99+
with:
100+
images: |
101+
${{ env.DOCKERHUB_ZK_IMAGE }}
102+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}/zookeeper
103+
tags: |
104+
type=raw,value=3.8.4-${{ steps.vars.outputs.tag }}
105+
labels: |
106+
org.opencontainers.image.description=Apache Zookeeper image build with java-21
107+
- name: Build and push zookeeper image
108+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
109+
uses: docker/build-push-action@v6
110+
with:
111+
context: docker
112+
platforms: linux/amd64,linux/arm64
113+
tags: ${{ steps.meta-zk.outputs.tags }}
114+
labels: ${{ steps.meta-zk.outputs.labels }}
115+
annotations: ${{ steps.meta-zk.outputs.annotations }}
116+
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
117+
118+
# Extract metadata for zookeeper-operator image
119+
- name: Extract Docker metadata for zookeeper-operator
120+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
121+
id: meta-operator
122+
uses: docker/metadata-action@v5
123+
with:
124+
images: |
125+
${{ env.DOCKERHUB_OPERATOR_IMAGE }}
126+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}
127+
tags: |
128+
type=ref,event=tag
129+
labels: |
130+
org.opencontainers.image.description=Zookeeper Operator for Kubernetes
131+
- name: Build and push zookeeper-operator image
132+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
133+
uses: docker/build-push-action@v6
134+
with:
135+
context: .
136+
platforms: linux/amd64,linux/arm64
137+
build-args: |
138+
VERSION=${{ fromJSON(steps.meta-operator.outputs.json).labels['org.opencontainers.image.version'] }}
139+
BUILT_AT=${{ env.BUILT_AT }}
140+
GIT_SHA=${{ github.sha }}
141+
tags: ${{ steps.meta-operator.outputs.tags }}
142+
labels: ${{ steps.meta-operator.outputs.labels }}
143+
annotations: ${{ steps.meta-operator.outputs.annotations }}
144+
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
145+
146+
# Update Helm Chart version
147+
- name: Update Chart.yaml version
148+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
149+
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
154+
- name: Push Helm Chart to GHCR
155+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
156+
uses: appany/[email protected]
157+
with:
158+
name: zookeeper-operator
159+
repository: ${{ github.repository_owner }}/helm-charts
160+
tag: ${{ steps.vars.outputs.tag }}
161+
path: charts/zookeeper-operator
162+
registry: ${{ env.GHCR_REGISTRY }}
163+
registry_username: ${{ github.actor }}
164+
registry_password: ${{ secrets.GITHUB_TOKEN }}
165+
update_dependencies: 'true'

Dockerfile

Lines changed: 16 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
@@ -32,7 +32,22 @@ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /src/${PROJECT_NAME} \
3232
FROM ${DISTROLESS_DOCKER_REGISTRY:-gcr.io/}distroless/static-debian11:nonroot AS final
3333

3434
ARG PROJECT_NAME=zookeeper-operator
35+
ARG VERSION=0.0.0-localdev
36+
ARG GIT_SHA=0000000
37+
ARG BUILT_AT
3538

3639
COPY --from=go-builder /src/${PROJECT_NAME} /usr/local/bin/${PROJECT_NAME}
3740

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

0 commit comments

Comments
 (0)