|
| 1 | +name: Package helm charts |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | +env: |
| 8 | + HELM_VERSION_TO_INSTALL: 3.14.3 |
| 9 | + |
| 10 | +jobs: |
| 11 | + package-helm-charts: |
| 12 | + name: Package and Push Helm Chart |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Install helm |
| 21 | + uses: Azure/setup-helm@v3 |
| 22 | + with: |
| 23 | + version: ${{ env.HELM_VERSION_TO_INSTALL }} |
| 24 | + |
| 25 | + # Check that alpha/beta versions have the form X.Y.Z-alpha.A requried by Helm. |
| 26 | + # An early check saves waiting for the entire build before finding a problem. |
| 27 | + - name: Check helm version tag |
| 28 | + if: ${{ github.ref_type == 'tag' }} |
| 29 | + env: |
| 30 | + VERSION: "${{ github.ref_name }}" |
| 31 | + run: | |
| 32 | + if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-alpha|-beta|-rc).*?$ ]]; then |
| 33 | + echo "Valid version format: ${VERSION}" |
| 34 | + else |
| 35 | + echo "Invalid version: ${VERSION}. Expected: X.Y.Z or X.Y.Z-beta.1 or X.Y.Z-alpha.1" |
| 36 | + exit 1 |
| 37 | + fi |
| 38 | +
|
| 39 | + - name: Package helm charts |
| 40 | + env: |
| 41 | + VERSION: "${{ github.ref_type == 'tag' && github.ref_name || '0.0.0' }}" |
| 42 | + run: | |
| 43 | + set -xe |
| 44 | +
|
| 45 | + mkdir -p charts |
| 46 | + for i in $(find Charts -type d -maxdepth 1 -mindepth 1); do |
| 47 | + if [[ ${i} =~ ^.*-ioc$ ]]; then |
| 48 | + echo "Skipping IOC schema chart: ${i}" |
| 49 | + continue |
| 50 | + fi |
| 51 | + echo "Packaging chart: ${i}" |
| 52 | + helm package -u --app-version ${VERSION} --version ${VERSION} ${i} |
| 53 | + mv $(basename ${i})-*.tgz charts/ |
| 54 | + done |
| 55 | +
|
| 56 | + - name: Upload helm chart values schemas |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: helm-chart-schemas |
| 60 | + path: schemas/* |
| 61 | + |
| 62 | + - name: Push tagged helm chart to registry |
| 63 | + # TODO - switch to using https://github.com/helm/chart-releaser-action of maybe the docker action? |
| 64 | + if: ${{ github.ref_type == 'tag' }} |
| 65 | + run: | |
| 66 | + set -x |
| 67 | +
|
| 68 | + echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io/${{ github.repository_owner }} --username ${{ github.repository_owner }} --password-stdin |
| 69 | + REGISTRY=oci://ghcr.io/${{github.repository_owner }}/charts |
| 70 | + for i in charts/*.tgz; do |
| 71 | + helm push "${i}" ${REGISTRY,,} |
| 72 | + done |
0 commit comments