@@ -95,12 +95,17 @@ jobs:
9595 echo "Tag v${{ steps.get_version.outputs.version }} does not exist"
9696 fi
9797
98- - name : Fail if tag exists
98+ - name : Handle existing tag
9999 if : steps.check_tag.outputs.exists == 'true'
100100 run : |
101- echo "Error: Version ${{ steps.get_version.outputs.version }} already exists as a tag"
102- echo "Please update the version in package.json before releasing"
103- exit 1
101+ if [ "${{ inputs.docker-enabled }}" == "true" ]; then
102+ echo "Warning: Version ${{ steps.get_version.outputs.version }} already exists as a tag"
103+ echo "Proceeding with Docker image build and push only"
104+ else
105+ echo "Error: Version ${{ steps.get_version.outputs.version }} already exists as a tag"
106+ echo "Please update the version in package.json before releasing"
107+ exit 1
108+ fi
104109
105110 - name : Check Dockerfile exists
106111 if : inputs.docker-enabled && !inputs.dry-run
@@ -142,15 +147,29 @@ jobs:
142147 docker push ${{ secrets.ACR_URL }}/${{ inputs.docker-image-name }}:latest
143148
144149 - name : Create and push tag
145- if : ' !inputs.dry-run'
150+ if : ' !inputs.dry-run && steps.check_tag.outputs.exists != '' true '' '
146151 run : |
147152 git config user.name github-actions
148153 git config user.email github-actions@github.com
149154 git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release version ${{ steps.get_version.outputs.version }}"
150155 git push origin "v${{ steps.get_version.outputs.version }}"
151156
152- - name : Create GitHub Release
157+ - name : Check if release exists
158+ id : check_release
153159 if : ' !inputs.dry-run'
160+ run : |
161+ if gh release view "v${{ steps.get_version.outputs.version }}" --repo ${{ inputs.repository }} >/dev/null 2>&1; then
162+ echo "exists=true" >> $GITHUB_OUTPUT
163+ echo "Release v${{ steps.get_version.outputs.version }} already exists"
164+ else
165+ echo "exists=false" >> $GITHUB_OUTPUT
166+ echo "Release v${{ steps.get_version.outputs.version }} does not exist"
167+ fi
168+ env :
169+ GH_TOKEN : ${{ secrets.GH_PAT }}
170+
171+ - name : Create GitHub Release
172+ if : ' !inputs.dry-run && steps.check_release.outputs.exists != '' true'' '
154173 uses : actions/create-release@v1
155174 env :
156175 GITHUB_TOKEN : ${{ secrets.GH_PAT }}
@@ -168,6 +187,24 @@ jobs:
168187 draft : false
169188 prerelease : false
170189
190+ - name : Update existing release
191+ if : ' !inputs.dry-run && steps.check_release.outputs.exists == '' true'' && inputs.docker-enabled'
192+ run : |
193+ echo "Release already exists, updating with Docker image information"
194+ BODY="## Release v${{ steps.get_version.outputs.version }}
195+
196+ # ## Changes
197+ - See commit history for changes
198+
199+ # ## Docker Image
200+ Docker image available at : \`${{ secrets.ACR_URL }}/${{ inputs.docker-image-name }}:${{ steps.get_version.outputs.version }}\`"
201+
202+ gh release edit "v${{ steps.get_version.outputs.version }}" \
203+ --repo ${{ inputs.repository }} \
204+ --notes "$BODY"
205+ env :
206+ GH_TOKEN : ${{ secrets.GH_PAT }}
207+
171208 - name : Summary
172209 run : |
173210 echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
0 commit comments