From 0a905b17a2b2d3f942b29297d64a94b13183ede1 Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Fri, 20 Dec 2024 00:22:07 +0100 Subject: [PATCH] fix: release workflow, properly discover released tags Signed-off-by: Ludovic Ortega --- .github/workflows/releases.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 30cba03..c07c1a5 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -35,10 +35,13 @@ jobs: chart=$(basename "$chart_path") # get current version current_version=$(grep '^version:' "$chart_path/Chart.yaml" | awk '{print $2}') - # get current release version + # try to get current release version + set +e oras discover ghcr.io/${GITHUB_REPOSITORY@L}/${chart}:${current_version} + oras_exit_code=$? + set -e - if [ $? -ne 0 ]; then + if [ $oras_exit_code -ne 0 ]; then helm dependency build "$chart_path" helm package "$chart_path" --destination ./.cr-release-packages else @@ -77,6 +80,10 @@ jobs: uses: actions/checkout@v4 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 - name: Downloads artifacts @@ -84,15 +91,21 @@ jobs: with: 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%-*} + 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_digest}"