From 04ae03677499f6d919eec86ada032e91954fc58e Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Fri, 20 Dec 2024 13:38:02 +0100 Subject: [PATCH] fix: avoid exiting on oras discover Signed-off-by: Ludovic Ortega --- .github/workflows/helm.yml | 45 ++++++++++++------- .../.helmignore | 0 .../Chart.yaml | 2 +- .../README.md | 2 +- .../README.md.gotmpl | 0 .../artifacthub-repo.yml | 0 .../templates/NOTES.txt | 0 .../templates/_helpers.tpl | 0 .../templates/deployment.yaml | 0 .../templates/hpa.yaml | 0 .../templates/ingress.yaml | 0 .../templates/persistentvolumeclaim.yaml | 0 .../templates/service.yaml | 0 .../templates/serviceaccount.yaml | 0 .../templates/tests/test-connection.yaml | 0 .../values.yaml | 0 16 files changed, 31 insertions(+), 18 deletions(-) rename charts/{jellyseerr => jellyseerr-chart}/.helmignore (100%) rename charts/{jellyseerr => jellyseerr-chart}/Chart.yaml (93%) rename charts/{jellyseerr => jellyseerr-chart}/README.md (99%) rename charts/{jellyseerr => jellyseerr-chart}/README.md.gotmpl (100%) rename charts/{jellyseerr => jellyseerr-chart}/artifacthub-repo.yml (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/NOTES.txt (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/_helpers.tpl (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/deployment.yaml (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/hpa.yaml (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/ingress.yaml (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/persistentvolumeclaim.yaml (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/service.yaml (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/serviceaccount.yaml (100%) rename charts/{jellyseerr => jellyseerr-chart}/templates/tests/test-connection.yaml (100%) rename charts/{jellyseerr => jellyseerr-chart}/values.yaml (100%) diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 3447cd376..131e6102f 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -5,9 +5,6 @@ on: branches: - develop -env: - CHART_SUFFIX: "-chart" - jobs: package-helm-chart: name: Package helm chart @@ -41,20 +38,23 @@ jobs: mkdir -p ./.cr-release-packages for chart_path in ./charts/*; do if [ -d "$chart_path" ] && [ -f "$chart_path/Chart.yaml" ]; then - chart=$(basename "$chart_path") + chart_name=$(grep '^name:' "$chart_path/Chart.yaml" | awk '{print $2}') # get current version current_version=$(grep '^version:' "$chart_path/Chart.yaml" | awk '{print $2}') - # get current release version - oras discover ghcr.io/${GITHUB_REPOSITORY@L}/${chart}${CHART_SUFFIX}:${current_version} + # try to get current release version + set +e + oras discover ghcr.io/${GITHUB_REPOSITORY@L}/${chart_name}:${current_version} + oras_exit_code=$? + set -e - if [ "$?" -eq 1 ]; then + if [ $oras_exit_code -ne 0 ]; then helm dependency build "$chart_path" helm package "$chart_path" --destination ./.cr-release-packages else - echo "No version change for $chart. Skipping." + echo "No version change for $chart_name. Skipping." fi else - echo "Skipping $chart: Not a valid Helm chart" + echo "Skipping $chart_name: Not a valid Helm chart" fi done @@ -89,6 +89,12 @@ jobs: with: fetch-depth: 0 + - name: Install helm + uses: azure/setup-helm@v4 + + - name: Install Oras + uses: oras-project/setup-oras@v1 + - name: Install Cosign uses: sigstore/cosign-installer@v3 @@ -98,25 +104,32 @@ jobs: name: artifacts path: .cr-release-packages/ + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Push charts to GHCR env: COSIGN_YES: true run: | for chart_path in `find .cr-release-packages -name '*.tgz' -print`; do - # push chart to OCI - helm push ${chart_path} oci://ghcr.io/${GITHUB_REPOSITORY@L} |& tee helm-push-output.log + # push chart to OCI chart_release_file=$(basename "$chart_path") - chart=${chart_release_file%-*} + chart_name=${chart_release_file%-*} + helm push ${chart_path} oci://ghcr.io/${GITHUB_REPOSITORY@L} |& tee helm-push-output.log chart_digest=$(awk -F "[, ]+" '/Digest/{print $NF}' < helm-push-output.log) # sign chart - cosign sign "ghcr.io/${GITHUB_REPOSITORY@L}/${chart}${CHART_SUFFIX}@${chart_digest}" + cosign sign "ghcr.io/${GITHUB_REPOSITORY@L}/${chart_name}@${chart_digest}" # push artifacthub-repo.yml to OCI oras push \ - ghcr.io/${GITHUB_REPOSITORY@L}/${chart}${CHART_SUFFIX}:artifacthub.io \ + ghcr.io/${GITHUB_REPOSITORY@L}/${chart_name}:artifacthub.io \ --config /dev/null:application/vnd.cncf.artifacthub.config.v1+yaml \ - charts/$chart/artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml \ + charts/$chart_name/artifacthub-repo.yml:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml \ |& tee oras-push-output.log artifacthub_digest=$(grep "Digest:" oras-push-output.log | awk '{print $2}') # sign artifacthub-repo.yml - cosign sign "ghcr.io/${GITHUB_REPOSITORY@L}/${chart}${CHART_SUFFIX}:artifacthub.io@${artifacthub_digest}" + cosign sign "ghcr.io/${GITHUB_REPOSITORY@L}/${chart_name}:artifacthub.io@${artifacthub_digest}" done diff --git a/charts/jellyseerr/.helmignore b/charts/jellyseerr-chart/.helmignore similarity index 100% rename from charts/jellyseerr/.helmignore rename to charts/jellyseerr-chart/.helmignore diff --git a/charts/jellyseerr/Chart.yaml b/charts/jellyseerr-chart/Chart.yaml similarity index 93% rename from charts/jellyseerr/Chart.yaml rename to charts/jellyseerr-chart/Chart.yaml index 8ae865ca6..48f3893d0 100644 --- a/charts/jellyseerr/Chart.yaml +++ b/charts/jellyseerr-chart/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 kubeVersion: ">=1.23.0-0" -name: jellyseerr +name: jellyseerr-chart description: Jellyseerr helm chart for Kubernetes type: application version: 1.2.0 diff --git a/charts/jellyseerr/README.md b/charts/jellyseerr-chart/README.md similarity index 99% rename from charts/jellyseerr/README.md rename to charts/jellyseerr-chart/README.md index 1284d690f..1ce1df6e3 100644 --- a/charts/jellyseerr/README.md +++ b/charts/jellyseerr-chart/README.md @@ -1,4 +1,4 @@ -# jellyseerr +# jellyseerr-chart ![Version: 1.2.0](https://img.shields.io/badge/Version-1.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.1.0](https://img.shields.io/badge/AppVersion-2.1.0-informational?style=flat-square) diff --git a/charts/jellyseerr/README.md.gotmpl b/charts/jellyseerr-chart/README.md.gotmpl similarity index 100% rename from charts/jellyseerr/README.md.gotmpl rename to charts/jellyseerr-chart/README.md.gotmpl diff --git a/charts/jellyseerr/artifacthub-repo.yml b/charts/jellyseerr-chart/artifacthub-repo.yml similarity index 100% rename from charts/jellyseerr/artifacthub-repo.yml rename to charts/jellyseerr-chart/artifacthub-repo.yml diff --git a/charts/jellyseerr/templates/NOTES.txt b/charts/jellyseerr-chart/templates/NOTES.txt similarity index 100% rename from charts/jellyseerr/templates/NOTES.txt rename to charts/jellyseerr-chart/templates/NOTES.txt diff --git a/charts/jellyseerr/templates/_helpers.tpl b/charts/jellyseerr-chart/templates/_helpers.tpl similarity index 100% rename from charts/jellyseerr/templates/_helpers.tpl rename to charts/jellyseerr-chart/templates/_helpers.tpl diff --git a/charts/jellyseerr/templates/deployment.yaml b/charts/jellyseerr-chart/templates/deployment.yaml similarity index 100% rename from charts/jellyseerr/templates/deployment.yaml rename to charts/jellyseerr-chart/templates/deployment.yaml diff --git a/charts/jellyseerr/templates/hpa.yaml b/charts/jellyseerr-chart/templates/hpa.yaml similarity index 100% rename from charts/jellyseerr/templates/hpa.yaml rename to charts/jellyseerr-chart/templates/hpa.yaml diff --git a/charts/jellyseerr/templates/ingress.yaml b/charts/jellyseerr-chart/templates/ingress.yaml similarity index 100% rename from charts/jellyseerr/templates/ingress.yaml rename to charts/jellyseerr-chart/templates/ingress.yaml diff --git a/charts/jellyseerr/templates/persistentvolumeclaim.yaml b/charts/jellyseerr-chart/templates/persistentvolumeclaim.yaml similarity index 100% rename from charts/jellyseerr/templates/persistentvolumeclaim.yaml rename to charts/jellyseerr-chart/templates/persistentvolumeclaim.yaml diff --git a/charts/jellyseerr/templates/service.yaml b/charts/jellyseerr-chart/templates/service.yaml similarity index 100% rename from charts/jellyseerr/templates/service.yaml rename to charts/jellyseerr-chart/templates/service.yaml diff --git a/charts/jellyseerr/templates/serviceaccount.yaml b/charts/jellyseerr-chart/templates/serviceaccount.yaml similarity index 100% rename from charts/jellyseerr/templates/serviceaccount.yaml rename to charts/jellyseerr-chart/templates/serviceaccount.yaml diff --git a/charts/jellyseerr/templates/tests/test-connection.yaml b/charts/jellyseerr-chart/templates/tests/test-connection.yaml similarity index 100% rename from charts/jellyseerr/templates/tests/test-connection.yaml rename to charts/jellyseerr-chart/templates/tests/test-connection.yaml diff --git a/charts/jellyseerr/values.yaml b/charts/jellyseerr-chart/values.yaml similarity index 100% rename from charts/jellyseerr/values.yaml rename to charts/jellyseerr-chart/values.yaml