Skip to content

Commit fbe9b1a

Browse files
feat: add GitHub Actions workflow for OCI chart releases
1 parent 46979e4 commit fbe9b1a

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release Helm Chart
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*' # Trigger on version tags like v1.0.0, v1.2.3, etc.
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
CHART_NAME: patchmon
11+
12+
jobs:
13+
release:
14+
runs-on: self-hosted
15+
permissions:
16+
contents: write
17+
packages: write
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Extract version from tag
24+
id: version
25+
run: |
26+
# Remove 'v' prefix from tag (v1.2.3 -> 1.2.3)
27+
VERSION=${GITHUB_REF_NAME#v}
28+
echo "version=$VERSION" >> $GITHUB_OUTPUT
29+
echo "Tag version: $VERSION"
30+
31+
- name: Verify Chart.yaml version matches tag
32+
run: |
33+
CHART_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}' | tr -d '"')
34+
TAG_VERSION="${{ steps.version.outputs.version }}"
35+
36+
echo "Chart.yaml version: $CHART_VERSION"
37+
echo "Git tag version: $TAG_VERSION"
38+
39+
if [ "$CHART_VERSION" != "$TAG_VERSION" ]; then
40+
echo "ERROR: Chart version ($CHART_VERSION) does not match git tag ($TAG_VERSION)"
41+
exit 1
42+
fi
43+
44+
echo "Version verification passed"
45+
46+
- name: Set up Helm
47+
uses: azure/setup-helm@v4
48+
with:
49+
version: '3.14.0'
50+
51+
- name: Log in to GitHub Container Registry
52+
run: |
53+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.REGISTRY }} \
54+
--username ${{ github.actor }} \
55+
--password-stdin
56+
57+
- name: Package Helm chart
58+
run: |
59+
helm package . --destination .helm-package
60+
echo "Chart packaged successfully"
61+
62+
- name: Push chart to OCI registry
63+
run: |
64+
CHART_PACKAGE=$(ls .helm-package/${{ env.CHART_NAME }}-*.tgz)
65+
REPO_OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
66+
helm push "$CHART_PACKAGE" oci://${{ env.REGISTRY }}/${REPO_OWNER_LOWER}/charts
67+
echo "Chart pushed to OCI registry"
68+
69+
- name: Create GitHub Release
70+
uses: softprops/action-gh-release@v1
71+
with:
72+
files: .helm-package/${{ env.CHART_NAME }}-*.tgz
73+
generate_release_notes: true
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Output installation instructions
78+
run: |
79+
REPO_OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
80+
echo "🎉 Chart released successfully!"
81+
echo ""
82+
echo "Install with:"
83+
echo " helm install patchmon oci://${{ env.REGISTRY }}/${REPO_OWNER_LOWER}/charts/${{ env.CHART_NAME }} --version ${{ steps.version.outputs.version }}"
84+
echo ""
85+
echo "Or upgrade with:"
86+
echo " helm upgrade patchmon oci://${{ env.REGISTRY }}/${REPO_OWNER_LOWER}/charts/${{ env.CHART_NAME }} --version ${{ steps.version.outputs.version }}"

0 commit comments

Comments
 (0)