From ffca60c2b14ebffb4f0ec6e095cf7e55adbca720 Mon Sep 17 00:00:00 2001 From: Pascal Sthamer <10992664+P4sca1@users.noreply.github.com> Date: Wed, 26 Feb 2025 09:27:46 +0100 Subject: [PATCH 1/2] fix helm release workflow --- .github/workflows/.github/workflows/helm.yml | 41 ------------ .github/workflows/helm-release.yml | 68 ++++++++++++++++++++ charts/shuffle/Chart.yaml | 4 +- 3 files changed, 70 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/.github/workflows/helm.yml create mode 100644 .github/workflows/helm-release.yml diff --git a/.github/workflows/.github/workflows/helm.yml b/.github/workflows/.github/workflows/helm.yml deleted file mode 100644 index c3a6657a..00000000 --- a/.github/workflows/.github/workflows/helm.yml +++ /dev/null @@ -1,41 +0,0 @@ - -name: helm - -on: - workflow_dispatch: - push: - branches: - - main - paths: - - "charts/**" - -permissions: - contents: read - packages: write - -jobs: - main: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install apt dependencies - run: | - curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null - sudo apt-get install apt-transport-https -y --no-install-recommends - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list - sudo apt-get update - sudo apt-get install helm -y --no-install-recommends - - - name: Update helm dependencies - run: helm dependency update ./charts/shuffle - - - name: Package Helm chart - run: helm package ./charts/shuffle --destination ./charts - - - name: Login to OCI registry (ghcr.io) - run: helm registry login ghcr.io --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} - - - name: Push helm chart - run: helm push ./charts/shuffle-*.tgz oci://ghcr.io/shuffle/shuffle/charts diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml new file mode 100644 index 00000000..ee53fb95 --- /dev/null +++ b/.github/workflows/helm-release.yml @@ -0,0 +1,68 @@ +name: Helm Release + +on: + release: + types: [published] + branches: + - main + - nightly + push: + branches: + - nightly + +permissions: + contents: read + packages: write + +jobs: + main: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install apt dependencies + run: | + curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null + sudo apt-get install apt-transport-https -y --no-install-recommends + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list + sudo apt-get update + sudo apt-get install helm -y --no-install-recommends + + - name: Set versions + id: set_versions + run: | + if [[ ${{ github.event_name }} == 'release' ]]; then + CHART_VERSION="${{ github.event.release.tag_name }}" + APP_VERSION="${{ github.event.release.tag_name }}" + else + CHART_VERSION="0.0.0-nightly-untagged-latest" + APP_VERSION="nightly" + fi + + echo "CHART_VERSION set to ${CHART_VERSION}. Validating..." + + # https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + SEMVER_REGEX="^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" + + if echo "${CHART_VERSION}" | grep -Pq "${SEMVER_REGEX}"; then + echo "${CHART_VERSION} is a valid SemVer string"; + else + echo "${CHART_VERSION} is an invalid SemVer string"; + exit 1; + fi + + echo "CHART_VERSION=${CHART_VERSION}" >> $GITHUB_OUTPUT + echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_OUTPUT + + - name: Update helm dependencies + run: helm dependency update ./charts/shuffle + + - name: Package Helm chart + run: helm package ./charts/shuffle --version "${CHART_VERSION}" --app-version="${APP_VERSION}" --destination ./charts + + - name: Login to OCI registry (ghcr.io) + run: helm registry login ghcr.io --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} + + - name: Push helm chart + run: helm push ./charts/shuffle-*.tgz oci://ghcr.io/shuffle/shuffle/charts diff --git a/charts/shuffle/Chart.yaml b/charts/shuffle/Chart.yaml index 67d1de83..f11f1726 100644 --- a/charts/shuffle/Chart.yaml +++ b/charts/shuffle/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: shuffle description: A Helm chart for deploying Shuffle on Kubernetes type: application -version: 0.1.0 -appVersion: nightly +version: 0.0.0 +appVersion: 0.0.0 dependencies: - name: common version: ^2.23.0 From 1a47c46a5fe60dc0dc0a242a7a2990b5062d8698 Mon Sep 17 00:00:00 2001 From: Pascal Sthamer <10992664+P4sca1@users.noreply.github.com> Date: Wed, 26 Feb 2025 09:33:42 +0100 Subject: [PATCH 2/2] only run when charts folder changes Signed-off-by: Pascal Sthamer <10992664+P4sca1@users.noreply.github.com> --- .github/workflows/helm-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml index ee53fb95..67af8ea7 100644 --- a/.github/workflows/helm-release.yml +++ b/.github/workflows/helm-release.yml @@ -9,6 +9,8 @@ on: push: branches: - nightly + paths: + - "charts/**" permissions: contents: read