Skip to content

Commit f252e38

Browse files
committed
add helm chart publishing
1 parent 50fe871 commit f252e38

4 files changed

Lines changed: 93 additions & 1 deletion

File tree

.github/workflows/_helm.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Package helm charts
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
HELM_VERSION_TO_INSTALL: 3.14.3
8+
9+
jobs:
10+
package-helm-charts:
11+
name: Test helm chart packaging
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install helm
20+
uses: Azure/setup-helm@v3
21+
with:
22+
version: ${{ env.HELM_VERSION_TO_INSTALL }}
23+
24+
# an early check for correct tag saves waiting for the build to find problems
25+
- name: Check helm version tag
26+
if: ${{ github.ref_type == 'tag' }}
27+
env:
28+
VERSION: "${{ github.ref_name }}"
29+
run: |
30+
set -xeuo pipefail
31+
32+
VERSION=${{ github.ref_name }}
33+
34+
# Check that alpha/beta versions have the form 2025.8.1+b1 requried by Helm
35+
if [[ "${VERSION}" =~ '^[0-9]+\.[0-9]+\.[0-9]+(\+.*)?$' ]]; then
36+
echo "Valid version format: ${VERSION}"
37+
else
38+
echo "Invalid version format: ${VERSION}. Expected format: X.Y.Z or X.Y.Z+string"
39+
return 1
40+
fi
41+
42+
- name: Package helm charts
43+
env:
44+
VERSION: "${{ github.ref_type == 'tag' && github.ref_name || '0.0.0' }}"
45+
run: |
46+
set -xeuo pipefail
47+
48+
mkdir -p charts
49+
cd helm
50+
helm package -u --app-version ${VERSION} --version ${VERSION} .
51+
mv *.tgz ../../charts
52+
53+
- name: Upload helm charts as artifacts
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: charts
57+
path: charts

.github/workflows/_release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ jobs:
2020
rm -rf $GITHUB_REF_NAME
2121
fi
2222
23+
- name: Push tagged helm chart to registry
24+
run: |
25+
set -x
26+
27+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io/${{ github.repository_owner }} --username ${{ github.repository_owner }} --password-stdin
28+
29+
IFS='@' read -r NAME VERSION <<< "${GITHUB_REF_NAME}"
30+
REGISTRY=oci://ghcr.io/diamondlightsource
31+
32+
helm push "${NAME}-${VERSION}.tgz" ${REGISTRY}
33+
2334
- name: Create GitHub Release
2435
# We pin to the SHA, not the tag, for security reasons.
2536
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ jobs:
5151
permissions:
5252
id-token: write
5353

54+
helm:
55+
uses: ./.github/workflows/_helm.yml
56+
5457
release:
5558
if: github.ref_type == 'tag'
56-
needs: [dist, docs]
59+
needs: [dist, docs, helm]
5760
uses: ./.github/workflows/_release.yml
5861
permissions:
5962
contents: write

package-helm-chart.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/env bash
2+
3+
set -xeuo pipefail
4+
5+
FULL_REF=$(git describe --tags)
6+
VERSION="${FULL_REF#*@}"
7+
8+
# Check that alpha/beta versions have the form 2025.8.1+b1 requried by Helm
9+
if [[ "${VERSION}" =~ '^[0-9]+\.[0-9]+\.[0-9]+(\+.*)?$' ]]; then
10+
echo "Valid version format: ${VERSION}"
11+
else
12+
echo "Invalid version format: ${VERSION}. Expected format: X.Y.Z or X.Y.Z+string"
13+
return 1
14+
fi
15+
16+
mkdir -p charts
17+
18+
cd helm
19+
20+
helm package -u --app-version ${VERSION} --version ${VERSION} .
21+
mv *.tgz ../../charts

0 commit comments

Comments
 (0)