Skip to content

Commit 6a010e4

Browse files
authored
Merge pull request #90 from netbootxyz/ci-workflow-fix
Fix CI build failure and tag creation issues in release workflow
2 parents 2f85e90 + b516786 commit 6a010e4

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ jobs:
7474
IMAGE_RELEASE=$(echo ${IMAGE_INFO} | jq -r '.Labels.build_version' | awk '{print $3}')
7575
IMAGE_VERSION=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $1}')
7676
NB_RELEASE_NUMBER=$(echo ${IMAGE_RELEASE} | awk -F'-nbxyz' '{print $2}')
77-
TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE} 2>/dev/null || echo "")
77+
if git rev-parse --verify "refs/tags/${IMAGE_RELEASE}" >/dev/null 2>&1; then
78+
TAG_SHA=$(git rev-list -n 1 ${IMAGE_RELEASE})
79+
else
80+
TAG_SHA=""
81+
fi
7882
if [ -z "${MULTIDIGEST}" ] || [ "${MULTIDIGEST}" == "null" ]; then
7983
echo "**** No existing container build found, assuming first build ****"
8084
VERSION_TAG=${WEBAPP_RELEASE}-nbxyz1
@@ -138,8 +142,20 @@ jobs:
138142
ghcr.io/netbootxyz/netbootxyz:${{ env.VERSION_TAG }}
139143
labels: ${{ steps.meta.outputs.labels }}
140144

141-
- name: Bump version and push tag
145+
- name: Check if tag exists
142146
if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success'
147+
id: check_tag
148+
run: |
149+
if git rev-parse --verify "refs/tags/${{ env.VERSION_TAG }}" >/dev/null 2>&1; then
150+
echo "Tag ${{ env.VERSION_TAG }} already exists, skipping tag creation"
151+
echo "tag_exists=true" >> $GITHUB_OUTPUT
152+
else
153+
echo "Tag ${{ env.VERSION_TAG }} does not exist, will create"
154+
echo "tag_exists=false" >> $GITHUB_OUTPUT
155+
fi
156+
157+
- name: Bump version and push tag
158+
if: steps.version_check.outcome == 'success' && steps.version_check.conclusion == 'success' && steps.check_tag.outputs.tag_exists == 'false'
143159
id: tag_version
144160
uses: anothrNick/[email protected]
145161
env:

0 commit comments

Comments
 (0)