Skip to content

Commit fa6b179

Browse files
committed
add helm chart release workflow
1 parent 8239580 commit fa6b179

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

.github/workflows/release-helm.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: 🧭 Helm Chart Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'helm-v*'
7+
workflow_dispatch:
8+
inputs:
9+
chart_version:
10+
description: 'Chart version to release'
11+
required: true
12+
type: string
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
CHART_NAME: trigger
17+
18+
jobs:
19+
lint-and-test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Helm
26+
uses: azure/setup-helm@v4
27+
with:
28+
version: "3.18.3"
29+
30+
- name: Lint Helm Chart
31+
run: |
32+
helm lint ./hosting/k8s/helm/
33+
34+
- name: Template and Validate
35+
run: |
36+
helm template test-release ./hosting/k8s/helm/ \
37+
--values ./hosting/k8s/helm/values.yaml \
38+
--output-dir /tmp/helm-output
39+
40+
# Validate generated manifests
41+
find /tmp/helm-output -name "*.yaml" -exec kubectl --dry-run=client apply -f {} \;
42+
43+
release:
44+
needs: lint-and-test
45+
runs-on: ubuntu-latest
46+
permissions:
47+
contents: read
48+
packages: write
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
53+
- name: Set up Helm
54+
uses: azure/setup-helm@v4
55+
with:
56+
version: "3.18.3"
57+
58+
- name: Log in to Container Registry
59+
uses: docker/login-action@v3
60+
with:
61+
registry: ${{ env.REGISTRY }}
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Extract version from tag or input
66+
id: version
67+
run: |
68+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
69+
VERSION="${{ github.event.inputs.chart_version }}"
70+
else
71+
VERSION="${{ github.ref_name }}"
72+
VERSION="${VERSION#helm-v}"
73+
fi
74+
echo "version=$VERSION" >> $GITHUB_OUTPUT
75+
echo "Releasing version: $VERSION"
76+
77+
- name: Check Chart.yaml version matches release version
78+
run: |
79+
VERSION="${{ steps.version.outputs.version }}"
80+
CHART_VERSION=$(grep '^version:' ./hosting/k8s/helm/Chart.yaml | awk '{print $2}')
81+
echo "Chart.yaml version: $CHART_VERSION"
82+
echo "Release version: $VERSION"
83+
if [ "$CHART_VERSION" != "$VERSION" ]; then
84+
echo "❌ Chart.yaml version does not match release version!"
85+
exit 1
86+
fi
87+
echo "✅ Chart.yaml version matches release version."
88+
89+
- name: Package Helm Chart
90+
run: |
91+
helm package ./hosting/k8s/helm/ --destination /tmp/
92+
93+
- name: Push Helm Chart to GHCR
94+
run: |
95+
VERSION="${{ steps.version.outputs.version }}"
96+
CHART_PACKAGE="/tmp/${{ env.CHART_NAME }}-${VERSION}.tgz"
97+
98+
# Push to GHCR OCI registry
99+
helm push "$CHART_PACKAGE" "oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts"
100+
101+
- name: Print Helm Chart URL
102+
run: |
103+
echo "Chart successfully published to:"
104+
echo "oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts/${{ env.CHART_NAME }}"
105+
106+
# Experimental GitHub Release step - disabled for now
107+
# - name: Create GitHub Release
108+
# uses: softprops/action-gh-release@v1
109+
# if: github.event_name == 'push'
110+
# with:
111+
# tag_name: ${{ github.ref_name }}
112+
# name: "Helm Chart ${{ steps.version.outputs.version }}"
113+
# body: |
114+
# ## Helm Chart Release ${{ steps.version.outputs.version }}
115+
116+
# ### Installation
117+
# ```bash
118+
# helm upgrade --install trigger \
119+
# oci://${{ env.REGISTRY }}/${{ github.repository_owner }}/charts/${{ env.CHART_NAME }} \
120+
# --version ${{ steps.version.outputs.version }}
121+
# ```
122+
123+
# ### Changes
124+
# See commit history for detailed changes in this release.
125+
# files: |
126+
# /tmp/${{ env.CHART_NAME }}-${{ steps.version.outputs.version }}.tgz
127+
# env:
128+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)