Skip to content

Commit 9da27e9

Browse files
committed
Publish helm charts in gh-pages
1 parent 5f2fec6 commit 9da27e9

File tree

2 files changed

+119
-1
lines changed

2 files changed

+119
-1
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: release-helm-charts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'charts/**'
9+
tags:
10+
- '*'
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: write
15+
16+
concurrency:
17+
group: chart-release
18+
cancel-in-progress: false
19+
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Configure Git
30+
run: |
31+
git config user.name "github-actions[bot]"
32+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
33+
34+
- name: Extract tag
35+
id: vars
36+
if: startsWith(github.ref, 'refs/tags/')
37+
run: |
38+
TAG="${GITHUB_REF#refs/tags/}"
39+
TAG="${TAG////-}"
40+
echo "Using tag: $TAG"
41+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
42+
43+
- name: Set chart versions to tag
44+
if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/zk')
45+
run: |
46+
set -euo pipefail
47+
for chart in charts/*; do
48+
f="$chart/Chart.yaml"
49+
if [ -f "$f" ]; then
50+
echo "Updating version in $f to ${TAG:-${{ steps.vars.outputs.tag }}}"
51+
# Replace the version field at start of line (optional leading spaces)
52+
sed -i.bak -E "s|^[[:space:]]*version:[[:space:]]*.*$|version: ${{ steps.vars.outputs.tag }}|" "$f"
53+
rm -f "$f.bak"
54+
fi
55+
done
56+
57+
- name: Sync zookeeper chart image.tag with Docker tag
58+
if: startsWith(github.ref, 'refs/tags/')
59+
run: |
60+
set -euo pipefail
61+
ZK_VERSION=$(sed -n "s/^ARG DISTRO_NAME=apache-zookeeper-\([0-9.]*\)-bin$/\1/p" docker/zookeeper-image/Dockerfile | head -n1)
62+
if [ -z "$ZK_VERSION" ]; then
63+
# Fallback to current value in chart values
64+
ZK_VERSION=$(sed -n "s/^[[:space:]]*tag:[[:space:]]*\([0-9.]*\).*/\1/p" charts/zookeeper/values.yaml | head -n1)
65+
fi
66+
TAG="${{ steps.vars.outputs.tag }}"
67+
if [[ "$GITHUB_REF" == refs/tags/zk* ]]; then
68+
NEW_IMG_TAG="${ZK_VERSION}-apache-${TAG}"
69+
else
70+
NEW_IMG_TAG="${ZK_VERSION}-${TAG}"
71+
fi
72+
echo "Setting charts/zookeeper/values.yaml image.tag to ${NEW_IMG_TAG}"
73+
sed -i.bak -E "s|^([[:space:]]*tag:[[:space:]]*).*$|\1${NEW_IMG_TAG}|" charts/zookeeper/values.yaml
74+
rm -f charts/zookeeper/values.yaml.bak
75+
76+
- name: Set up Helm
77+
uses: azure/setup-helm@v4
78+
with:
79+
version: v3.14.4
80+
81+
- name: Lint Helm charts
82+
run: |
83+
set -euo pipefail
84+
found=0
85+
for chart in charts/*; do
86+
if [ -f "$chart/Chart.yaml" ]; then
87+
found=1
88+
echo "Linting $chart"
89+
helm lint "$chart"
90+
fi
91+
done
92+
if [ "$found" -eq 0 ]; then
93+
echo "No charts found under charts/." >&2
94+
exit 1
95+
fi
96+
97+
- name: Build chart dependencies (if any)
98+
run: |
99+
set -euo pipefail
100+
for chart in charts/*; do
101+
if [ -f "$chart/Chart.yaml" ] && [ -f "$chart/Chart.yaml" ]; then
102+
if [ -f "$chart/Chart.yaml" ] && grep -q "^dependencies:" "$chart/Chart.yaml"; then
103+
echo "Updating dependencies for $chart"
104+
helm dependency update "$chart"
105+
fi
106+
fi
107+
done
108+
109+
- name: Release charts to GitHub Pages
110+
if: ${{ !startsWith(github.ref, 'refs/tags/zk') }}
111+
uses: helm/[email protected]
112+
env:
113+
CR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
with:
115+
charts_dir: charts
116+
# URL where charts will be hosted (GitHub Pages)
117+
charts_repo_url: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
118+
skip_existing: true

charts/zookeeper-operator/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ appVersion: 0.2.15
66
keywords:
77
- zookeeper
88
- storage
9-
home: https://github.com/pravega/zookeeper-operator
9+
home: https://github.com/adobe/zookeeper-operator
1010
icon: https://zookeeper.apache.org/images/zookeeper_small.gif

0 commit comments

Comments
 (0)