Skip to content

Commit be6d416

Browse files
author
amuraru
committed
(build) Update gh release workflow to publish also the helm chart to GHCR
1 parent d9473ba commit be6d416

File tree

2 files changed

+109
-56
lines changed

2 files changed

+109
-56
lines changed

.github/workflows/docker-image.yaml

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

.github/workflows/release.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags: [ '*' ]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
# GitHub Container Registry
13+
GHCR_REGISTRY: ghcr.io
14+
# github.repository as <account>/<repo>
15+
GHCR_IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
prepare:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
outputs:
23+
tag: ${{ steps.vars.outputs.tag }}
24+
built_at: ${{ steps.date.outputs.built_at }}
25+
steps:
26+
- name: Get tag name
27+
id: vars
28+
run: echo "tag=${GITHUB_REF:10}" >> $GITHUB_OUTPUT
29+
- name: Set Release Date
30+
id: date
31+
run: |
32+
echo "built_at=$(date --rfc-3339=date)" >> $GITHUB_OUTPUT
33+
34+
release-docker-image:
35+
runs-on: ubuntu-latest
36+
needs: [prepare]
37+
permissions:
38+
contents: read
39+
packages: write
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v5
43+
- name: Set up QEMU
44+
uses: docker/setup-qemu-action@v3
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v3
47+
- name: Log into GitHub Container Registry ${{ env.GHCR_REGISTRY }}
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ${{ env.GHCR_REGISTRY }}
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
- name: Extract Docker metadata
54+
id: meta
55+
uses: docker/metadata-action@v5
56+
with:
57+
images: |
58+
${{ env.GHCR_REGISTRY }}/${{ env.GHCR_IMAGE_NAME }}
59+
tags: |
60+
type=ref,event=tag
61+
labels: |
62+
org.opencontainers.image.description=KMinion - Prometheus Exporter for Apache Kafka
63+
- name: Build and push Docker image
64+
uses: docker/build-push-action@v6
65+
with:
66+
context: .
67+
platforms: linux/amd64,linux/arm64
68+
build-args: |
69+
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
70+
BUILT_AT=${{ needs.prepare.outputs.built_at }}
71+
COMMIT=${{ github.sha }}
72+
tags: ${{ steps.meta.outputs.tags }}
73+
labels: ${{ steps.meta.outputs.labels }}
74+
annotations: ${{ steps.meta.outputs.annotations }}
75+
push: ${{ startsWith(github.ref, 'refs/tags/') }}
76+
77+
release-helm:
78+
runs-on: ubuntu-latest
79+
needs: [prepare, release-docker-image]
80+
permissions:
81+
contents: read
82+
packages: write
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v5
86+
- name: Update Chart.yaml version, values.yaml image tag, and README.md
87+
run: |
88+
sed -i "s/^version:.*/version: \"${{ needs.prepare.outputs.tag }}\"/" charts/kminion/Chart.yaml
89+
sed -i "s/^appVersion:.*/appVersion: \"${{ needs.prepare.outputs.tag }}\"/" charts/kminion/Chart.yaml
90+
# Ensure consistent space-based indentation and update tag
91+
sed -i 's/\t/ /g' charts/kminion/values.yaml
92+
sed -i "/^image:/,/^[^[:space:]]/ { /^[[:space:]]*tag:.*/s/tag:.*/tag: \"${{ needs.prepare.outputs.tag }}\"/; }" charts/kminion/values.yaml
93+
# Update README.md version references if README exists
94+
if [ -f charts/kminion/README.md ]; then
95+
sed -i "s/--version [0-9]\+\.[0-9]\+\.[0-9]\+-[a-zA-Z0-9-]\+/--version ${{ needs.prepare.outputs.tag }}/g" charts/kminion/README.md
96+
sed -i "s/\`[0-9]\+\.[0-9]\+\.[0-9]\+-[a-zA-Z0-9-]\+\`/\`${{ needs.prepare.outputs.tag }}\`/g" charts/kminion/README.md
97+
fi
98+
- name: Push Helm Chart to GHCR
99+
uses: appany/[email protected]
100+
with:
101+
name: kminion
102+
repository: ${{ github.repository_owner }}/helm-charts
103+
tag: ${{ needs.prepare.outputs.tag }}
104+
path: charts/kminion
105+
registry: ${{ env.GHCR_REGISTRY }}
106+
registry_username: ${{ github.actor }}
107+
registry_password: ${{ secrets.GITHUB_TOKEN }}
108+
update_dependencies: 'true'
109+

0 commit comments

Comments
 (0)