Skip to content

Commit 8c2516b

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

4 files changed

Lines changed: 91 additions & 2 deletions

File tree

.github/workflows/_helm.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
# Check that alpha/beta versions have the form 2025.8.1+b1 requried by Helm.
25+
# An early check saves waiting for the build to find problems.
26+
- name: Check helm version tag
27+
if: ${{ github.ref_type == 'tag' }}
28+
env:
29+
VERSION: "${{ github.ref_name }}"
30+
run: |
31+
if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(\+.*)?$ ]]; then
32+
echo "Valid version format: ${VERSION}"
33+
else
34+
echo "Invalid version format: ${VERSION}. Expected format: X.Y.Z or X.Y.Z+string"
35+
exit 1
36+
fi
37+
38+
- name: Package helm charts
39+
env:
40+
VERSION: "${{ github.ref_type == 'tag' && github.ref_name || '0.0.0' }}"
41+
run: |
42+
set -xe
43+
44+
mkdir -p charts
45+
cd helm
46+
47+
helm package -u --app-version ${VERSION} --version ${VERSION} .
48+
mv *.tgz ../../charts
49+
50+
- name: Upload helm charts as artifacts
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: charts
54+
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ jobs:
4444
if: needs.check.outputs.branch-pr == ''
4545
uses: ./.github/workflows/_dist.yml
4646

47+
helm:
48+
uses: ./.github/workflows/_helm.yml
49+
4750
pypi:
4851
if: github.ref_type == 'tag'
49-
needs: dist
52+
needs: [dist, helm]
5053
uses: ./.github/workflows/_pypi.yml
5154
permissions:
5255
id-token: write
5356

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)