From b51678638789f6d49747060d517ce587e13833f1 Mon Sep 17 00:00:00 2001 From: Antony Messerli Date: Thu, 12 Jun 2025 01:07:48 -0500 Subject: [PATCH] Fix CI build failure and tag creation issues in release workflow - Add fetch-tags: true to ensure git tags are available during checkout - Improve tag existence checking with proper git rev-parse verification - Add pre-check to prevent attempting to create tags that already exist - Fix tag creation logic to handle existing tags gracefully Resolves both the 'git rev-list' exit code 129 error and the 'Reference already exists' error in the release workflow. --- .github/workflows/release.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6455665..fd903f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,11 @@ jobs: IMAGE_RELEASE=$(echo ${IMAGE_INFO} | jq -r '.Labels.build_version' | awk '{print $3}') IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $1}') NB_RELEASE_NUMBER=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $2}') - TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE} 2>/dev/null || echo "") + if git rev-parse --verify "refs/tags/${IMAGE_RELEASE}" >/dev/null 2>&1; then + TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE}) + else + TAG_SHA="" + fi if [ -z "${MULTIDIGEST}" ] || [ "${MULTIDIGEST}" == "null" ]; then echo "**** No existing container build found, assuming first build ****" VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1 @@ -138,8 +142,20 @@ jobs: ghcr.io/netbootxyz/netbootxyz:${{ env.VERSION_TAG }} labels: ${{ steps.meta.outputs.labels }} - - name: Bump version and push tag + - name: Check if tag exists if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success' + id: check_tag + run: | + if git rev-parse --verify "refs/tags/${{ env.VERSION_TAG }}" >/dev/null 2>&1; then + echo "Tag ${{ env.VERSION_TAG }} already exists, skipping tag creation" + echo "tag_exists=true" >> $GITHUB_OUTPUT + else + echo "Tag ${{ env.VERSION_TAG }} does not exist, will create" + echo "tag_exists=false" >> $GITHUB_OUTPUT + fi + + - name: Bump version and push tag + if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success' && steps.check_tag.outputs.tag_exists == 'false' id: tag_version uses: anothrNick/github-tag-action@1.73.0 env: