Skip to content

Commit 482a5d7

Browse files
committed
Publish release artifacts (docker images, helm chart) to GHCR
1 parent fb7a63b commit 482a5d7

File tree

10 files changed

+159
-702
lines changed

10 files changed

+159
-702
lines changed
Lines changed: 98 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
1-
name: build-publish-docker-image
1+
name: release
22

33
on:
44
push:
55
tags:
66
- '*'
77

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+
821
jobs:
922
build:
1023
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
1127
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v5
1230
- name: Set up Go 1.25
1331
uses: actions/setup-go@v2
1432
with:
@@ -18,7 +36,6 @@ jobs:
1836
run: |
1937
sudo ln -sf `which go` `sudo which go` || true
2038
sudo go version
21-
- uses: actions/checkout@v2
2239
- name: get go version
2340
run: go version
2441
- name: Gofmt and License checks
@@ -27,58 +44,112 @@ jobs:
2744
run: make test
2845
- name: Get tag name
2946
id: vars
47+
run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
48+
- name: Set Release Date
3049
run: |
31-
ref=${GITHUB_REF:10}
32-
ref="${ref////-}"
33-
echo $ref
34-
echo ::set-output name=tag::$ref
35-
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
50+
echo "BUILT_AT=$(date --rfc-3339=date)" >> ${GITHUB_ENV}
3651
3752
- name: Set up QEMU
3853
uses: docker/setup-qemu-action@v3
3954
- name: Set up Docker Buildx
4055
uses: docker/setup-buildx-action@v3
41-
- name: Login to DockerHub
42-
if: startsWith(github.ref, 'refs/tags/')
56+
# Login against Docker Hub
57+
- name: Login to DockerHub Registry
4358
uses: docker/login-action@v3
4459
with:
4560
username: ${{ secrets.DOCKER_USERNAME }}
4661
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 }}
4769

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 }}
4881
- name: Build and push zookeeper Apache image
49-
uses: docker/build-push-action@v5
82+
uses: docker/build-push-action@v6
5083
if: ${{ startsWith(github.ref, 'refs/tags/zk') }}
5184
with:
5285
context: docker/zookeeper-image
5386
platforms: linux/amd64,linux/arm64
54-
tags: adobe/zookeeper:3.8.4-apache-${{ steps.vars.outputs.tag }}
87+
tags: ${{ steps.meta-zk-apache.outputs.tags }}
88+
labels: ${{ steps.meta-zk-apache.outputs.labels }}
5589
push: ${{ startsWith(github.ref, 'refs/tags/zk') }}
56-
labels: |
57-
org.opencontainers.image.source=${{ github.event.repository.html_url }}
58-
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
59-
org.opencontainers.image.revision=${{ github.sha }}
6090

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 }}
61102
- name: Build and push zookeeper image
62103
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
63-
uses: docker/build-push-action@v5
104+
uses: docker/build-push-action@v6
64105
with:
65106
context: docker
66107
platforms: linux/amd64,linux/arm64
67-
tags: adobe/zookeeper:3.8.4-${{ steps.vars.outputs.tag }}
108+
tags: ${{ steps.meta-zk.outputs.tags }}
109+
labels: ${{ steps.meta-zk.outputs.labels }}
68110
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
69-
labels: |
70-
org.opencontainers.image.source=${{ github.event.repository.html_url }}
71-
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
72-
org.opencontainers.image.revision=${{ github.sha }}
73111

112+
# Extract metadata for zookeeper-operator image
113+
- name: Extract Docker metadata for zookeeper-operator
114+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
115+
id: meta-operator
116+
uses: docker/metadata-action@v5
117+
with:
118+
images: |
119+
${{ env.DOCKERHUB_OPERATOR_IMAGE }}
120+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}
121+
tags: |
122+
type=ref,event=tag
74123
- name: Build and push zookeeper-operator image
75124
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
76-
uses: docker/build-push-action@v5
125+
uses: docker/build-push-action@v6
77126
with:
78127
context: .
79-
tags: adobe/zookeeper-operator:${{ steps.vars.outputs.tag }}
128+
platforms: linux/amd64,linux/arm64
129+
build-args: |
130+
VERSION=${{ fromJSON(steps.meta-operator.outputs.json).labels['org.opencontainers.image.version'] }}
131+
BUILT_AT=${{ env.BUILT_AT }}
132+
GIT_SHA=${{ github.sha }}
133+
tags: ${{ steps.meta-operator.outputs.tags }}
134+
labels: ${{ steps.meta-operator.outputs.labels }}
80135
push: ${{ startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk') }}
81-
labels: |
82-
org.opencontainers.image.source=${{ github.event.repository.html_url }}
83-
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
84-
org.opencontainers.image.revision=${{ github.sha }}
136+
137+
# Update Helm Chart version
138+
- name: Update Chart.yaml version
139+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
140+
run: |
141+
sed -i "s/^version:.*/version: \"${{ steps.vars.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
142+
sed -i "s/^appVersion:.*/appVersion: \"${{ steps.vars.outputs.tag }}\"/" charts/zookeeper-operator/Chart.yaml
143+
# Push Helm Chart to GitHub Container Registry
144+
- name: Push Helm Chart to GHCR
145+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
146+
uses: appany/[email protected]
147+
with:
148+
name: zookeeper-operator
149+
repository: ${{ github.repository_owner }}/zookeeper-operator
150+
tag: ${{ steps.vars.outputs.tag }}
151+
path: charts/zookeeper-operator
152+
registry: ${{ env.GHCR_REGISTRY }}
153+
registry_username: ${{ github.actor }}
154+
registry_password: ${{ secrets.GITHUB_TOKEN }}
155+
update_dependencies: 'true'

0 commit comments

Comments
 (0)