Skip to content

Commit b605237

Browse files
ci: add GitHub Actions workflows for chart validation and release (#1)
* ci: add GitHub Actions workflows for chart validation and release - helm-lint workflow for PR validation with chart-testing - helm-release workflow for automated OCI publishing on tags - Auto-generated changelog from git commits - Chart versioning from git tags
1 parent 9e0cf9f commit b605237

File tree

10 files changed

+207
-9
lines changed

10 files changed

+207
-9
lines changed

.github/workflows/helm-lint.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Helm Chart Lint and Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- '**/*.yaml'
9+
- '**/*.yml'
10+
- '**/*.tpl'
11+
- 'Chart.yaml'
12+
- 'values.yaml'
13+
push:
14+
branches:
15+
- main
16+
paths:
17+
- '**/*.yaml'
18+
- '**/*.yml'
19+
- '**/*.tpl'
20+
- 'Chart.yaml'
21+
- 'values.yaml'
22+
23+
jobs:
24+
lint-test:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set up Helm
33+
uses: azure/setup-helm@v4
34+
with:
35+
version: v3.16.4
36+
37+
- name: Set up Python
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.12'
41+
42+
- name: Set up chart-testing
43+
uses: helm/chart-testing-action@v2.7.0
44+
45+
- name: Run chart-testing (lint)
46+
run: ct lint --charts charts/hub --validate-maintainers=false
47+
48+
- name: Helm lint
49+
run: helm lint charts/hub
50+
51+
- name: Helm template
52+
run: |
53+
helm template test charts/hub > /dev/null
54+
helm template test charts/hub --values examples/minimal-values.yaml > /dev/null
55+
helm template test charts/hub --values examples/production-values.yaml > /dev/null
56+
helm template test charts/hub --values examples/external-database.yaml > /dev/null
57+
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Release Helm Chart
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Configure Git
22+
run: |
23+
git config user.name "$GITHUB_ACTOR"
24+
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
25+
26+
- name: Set up Helm
27+
uses: azure/setup-helm@v4
28+
with:
29+
version: v3.16.4
30+
31+
- name: Extract version from tag
32+
id: version
33+
run: |
34+
VERSION=${GITHUB_REF#refs/tags/v}
35+
echo "version=$VERSION" >> $GITHUB_OUTPUT
36+
echo "Chart will be versioned as: $VERSION"
37+
38+
- name: Update Chart.yaml with release version
39+
run: |
40+
VERSION="${{ steps.version.outputs.version }}"
41+
sed -i "s/^version:.*/version: $VERSION/" charts/hub/Chart.yaml
42+
sed -i "s/^appVersion:.*/appVersion: \"$VERSION\"/" charts/hub/Chart.yaml
43+
cat charts/hub/Chart.yaml
44+
45+
- name: Package Helm chart
46+
run: |
47+
helm package charts/hub --dependency-update
48+
echo "Packaged chart:"
49+
ls -lh *.tgz
50+
51+
- name: Login to GitHub Container Registry
52+
uses: docker/login-action@v3
53+
with:
54+
registry: ghcr.io
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Push chart to GHCR
59+
run: |
60+
CHART_FILE=$(ls hub-*.tgz)
61+
helm push $CHART_FILE oci://ghcr.io/${{ github.repository_owner }}/charts
62+
echo "Chart pushed to: oci://ghcr.io/${{ github.repository_owner }}/charts/hub:${{ steps.version.outputs.version }}"
63+
64+
- name: Generate changelog
65+
id: changelog
66+
run: |
67+
# Get previous tag
68+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
69+
70+
if [ -z "$PREVIOUS_TAG" ]; then
71+
# First release - get all commits
72+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges)
73+
else
74+
# Get commits since last tag
75+
CHANGELOG=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
76+
fi
77+
78+
# Save to file for use in release
79+
echo "$CHANGELOG" > changelog.txt
80+
81+
# Output for GitHub Actions
82+
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
83+
84+
- name: Create GitHub Release
85+
uses: softprops/action-gh-release@v2
86+
with:
87+
files: |
88+
hub-*.tgz
89+
body: |
90+
## Helm Chart Release ${{ steps.version.outputs.version }}
91+
92+
### Installation
93+
94+
```bash
95+
helm install hub oci://ghcr.io/${{ github.repository_owner }}/charts/hub --version ${{ steps.version.outputs.version }}
96+
```
97+
98+
### Pull Chart
99+
100+
```bash
101+
helm pull oci://ghcr.io/${{ github.repository_owner }}/charts/hub --version ${{ steps.version.outputs.version }}
102+
```
103+
104+
### Changes in this Release
105+
106+
${{ steps.changelog.outputs.previous_tag && format('Changes since {0}:', steps.changelog.outputs.previous_tag) || 'Initial release' }}
107+
108+
$(cat changelog.txt)
109+
110+
---
111+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.changelog.outputs.previous_tag }}...v${{ steps.version.outputs.version }}
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
115+
- name: Chart release summary
116+
run: |
117+
echo "## Helm Chart Released Successfully" >> $GITHUB_STEP_SUMMARY
118+
echo "" >> $GITHUB_STEP_SUMMARY
119+
echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
120+
echo "**Registry:** ghcr.io/${{ github.repository_owner }}/charts/hub" >> $GITHUB_STEP_SUMMARY
121+
echo "" >> $GITHUB_STEP_SUMMARY
122+
echo "### Installation Command" >> $GITHUB_STEP_SUMMARY
123+
echo '```bash' >> $GITHUB_STEP_SUMMARY
124+
echo "helm install hub oci://ghcr.io/${{ github.repository_owner }}/charts/hub --version ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
125+
echo '```' >> $GITHUB_STEP_SUMMARY

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ helm lint charts/hub
7878

7979
3. Template the chart:
8080
```bash
81-
helm template test charts/hub --values charts/hub/examples/minimal-values.yaml
81+
helm template test charts/hub --values examples/minimal-values.yaml
8282
```
8383

8484
4. Test installation on a local cluster (kind/minikube):

charts/hub/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ This command removes all the Kubernetes components associated with the chart and
144144

145145
### Production Deployment
146146

147-
See [examples/production-values.yaml](./examples/production-values.yaml) for a complete production configuration with:
147+
See [examples/production-values.yaml](../../examples/production-values.yaml) for a complete production configuration with:
148148
- High availability (3 replicas)
149149
- Autoscaling
150150
- CloudNativePG with backups
@@ -159,7 +159,7 @@ helm install hub oci://ghcr.io/formbricks/charts/hub \
159159

160160
### External Database
161161

162-
See [examples/external-database.yaml](./examples/external-database.yaml) for using a managed database service (AWS RDS, Google Cloud SQL, etc.):
162+
See [examples/external-database.yaml](../../examples/external-database.yaml) for using a managed database service (AWS RDS, Google Cloud SQL, etc.):
163163

164164
```bash
165165
helm install hub oci://ghcr.io/formbricks/charts/hub \
@@ -168,7 +168,7 @@ helm install hub oci://ghcr.io/formbricks/charts/hub \
168168

169169
### Minimal Development Setup
170170

171-
See [examples/minimal-values.yaml](./examples/minimal-values.yaml) for a minimal configuration suitable for development:
171+
See [examples/minimal-values.yaml](../../examples/minimal-values.yaml) for a minimal configuration suitable for development:
172172

173173
```bash
174174
helm install hub oci://ghcr.io/formbricks/charts/hub \

charts/hub/ci/ci-values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ cloudnativepg:
2929
enabled: true
3030
cluster:
3131
instances: 1
32+
imageName: ghcr.io/cloudnative-pg/postgresql:18.0-standard-bookworm
3233
storage:
3334
size: 1Gi
3435
resources:

charts/hub/templates/database.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{- if .Values.cloudnativepg.enabled }}
2+
apiVersion: postgresql.cnpg.io/v1
3+
kind: Database
4+
metadata:
5+
name: {{ include "hub.fullname" . }}
6+
labels:
7+
{{- include "hub.labels" . | nindent 4 }}
8+
spec:
9+
cluster:
10+
name: {{ include "hub.fullname" . }}
11+
name: {{ .Values.cloudnativepg.cluster.bootstrap.initdb.database }}
12+
owner: {{ .Values.cloudnativepg.cluster.bootstrap.initdb.owner }}
13+
ensure: present
14+
extensions:
15+
- name: vector
16+
ensure: present
17+
{{- end }}

charts/hub/values.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ cloudnativepg:
226226
## Number of instances in the cluster
227227
instances: 3
228228

229-
## PostgreSQL version
230-
imageName: ghcr.io/cloudnative-pg/postgresql:18
229+
## PostgreSQL version (standard image includes pgvector)
230+
imageName: ghcr.io/cloudnative-pg/postgresql:18.0-standard-bookworm
231231

232232
## Storage configuration
233233
storage:
@@ -249,7 +249,6 @@ cloudnativepg:
249249
work_mem: "2621kB"
250250
min_wal_size: "1GB"
251251
max_wal_size: "4GB"
252-
shared_preload_libraries: "vector"
253252

254253
## Bootstrap configuration
255254
bootstrap:
File renamed without changes.

charts/hub/examples/production-values.yaml renamed to examples/production-values.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ cloudnativepg:
9393
enabled: true
9494
cluster:
9595
instances: 3
96-
imageName: ghcr.io/cloudnative-pg/postgresql:18
96+
imageName: ghcr.io/cloudnative-pg/postgresql:18.0-standard-bookworm
9797
storage:
9898
size: 50Gi
9999
storageClass: "gp3"
@@ -103,7 +103,6 @@ cloudnativepg:
103103
shared_buffers: "512MB"
104104
effective_cache_size: "2GB"
105105
maintenance_work_mem: "128MB"
106-
shared_preload_libraries: "vector"
107106
backup:
108107
enabled: true
109108
schedule: "0 2 * * *"

0 commit comments

Comments
 (0)