From b2770d536113f6b48810922137151ab6e14df9b3 Mon Sep 17 00:00:00 2001 From: Andrew Melnick Date: Tue, 9 Jan 2024 21:08:51 -0700 Subject: [PATCH] Use OCI for helm charts --- .github/workflows/helm.yml | 51 +++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 3e01a83..46e131a 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -6,7 +6,9 @@ on: tags: [ 'v*.*.*' ] env: + REGISTRY: ghcr.io CHART_DIR: helm/kink + HELM_REPO: "oci://ghcr.io/${{ github.repository }}/charts" jobs: release: @@ -31,37 +33,30 @@ jobs: uses: olegtarasov/get-tag@v2.1 - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: v3.8.1 - - - name: Install YQ - uses: chrisdickinson/setup-yq@latest - with: - yq-version: v4.27.2 + run: + make helm - - name: Set Chart Version + - name: Lint run: | - if [ -n "${{ steps.tagName.outputs.tag }}" ]; then - yq -i '.version = "${{ steps.tagName.outputs.tag }}"' '${{ env.CHART_DIR }}/Chart.yaml' - yq -i '.appVersion = "${{ steps.tagName.outputs.tag }}"' '${{ env.CHART_DIR }}/Chart.yaml' - else - yq -i '.version = .version + "-'"${GITHUB_SHA}"'"' '${{ env.CHART_DIR }}/Chart.yaml' - yq -i '.appVersion = "sha-'"${GITHUB_SHA}"'"' '${{ env.CHART_DIR }}/Chart.yaml' + bin/helm lint "${CHART_DIR}" + bin/helm template "${CHART_DIR}" + # Release charts + - name: Push Charts + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' + run: | + set -x + bin/helm registry login "${REGISTRY}" -u "${GITHUB_ACTOR}" -p "${GITHUB_TOKEN}" + GIT_TAG="${{ steps.tagName.outputs.tag }}" + if [ -n "${GIT_TAG}" ]; then + NEW_VERSION="${GIT_TAG}" + NEW_APP_VERSION="${GIT_TAG}" + else + NEW_VERSION="" + NEW_APP_VERSION="sha-${GITHUB_SHA}" fi + make chart CHART_VERSION="${NEW_VERSION}" CHART_APP_VERSION="${NEW_APP_VERSION}" CHART_GIT_SHA="${GITHUB_SHA}" + bin/helm push bin/charts/kink-*.tgz "${HELM_REPO}" - - name: Lint - run: | - helm lint '${{ env.CHART_DIR }}' - helm template '${{ env.CHART_DIR }}' - # Need to do this otherwise it will end up publishing the test chart - rm -rf helm/kink-test - - - name: Run chart-releaser - uses: helm/chart-releaser-action@v1.4.0 - env: - CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - with: - charts_dir: helm