Skip to content

Commit b9d735e

Browse files
committed
fix: ci
1 parent 1deffc3 commit b9d735e

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,36 @@ jobs:
135135
path: GhostDraw-${{ env.VERSION }}-portable.zip
136136
retention-days: 30
137137

138-
# Only create/update draft release if the tag doesn't exist yet
139-
# This allows CI to run safely whether tag exists or not
140-
- name: Check if tag exists
141-
id: check_tag
138+
# Check if a PUBLISHED (non-draft) release exists for this version
139+
# If only a draft exists, we should update it with new assets
140+
- name: Check if published release exists
141+
id: check_release
142142
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
143143
shell: pwsh
144+
env:
145+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144146
run: |
145147
$tagName = "v${{ env.VERSION }}"
146-
git fetch --tags
147-
$tagExists = git tag -l $tagName
148-
if ($tagExists) {
149-
Write-Host "Tag $tagName already exists - skipping draft release"
150-
echo "tag_exists=true" >> $env:GITHUB_OUTPUT
148+
149+
# Get release info for this tag (if exists)
150+
$release = gh release view $tagName --json isDraft,name 2>$null
151+
152+
if ($LASTEXITCODE -ne 0) {
153+
Write-Host "No release exists for $tagName - will create draft release"
154+
echo "skip_release=false" >> $env:GITHUB_OUTPUT
151155
} else {
152-
Write-Host "Tag $tagName does not exist - will create/update draft release"
153-
echo "tag_exists=false" >> $env:GITHUB_OUTPUT
156+
$releaseInfo = $release | ConvertFrom-Json
157+
if ($releaseInfo.isDraft) {
158+
Write-Host "Draft release exists for $tagName - will update with new assets"
159+
echo "skip_release=false" >> $env:GITHUB_OUTPUT
160+
} else {
161+
Write-Host "Published release exists for $tagName - skipping"
162+
echo "skip_release=true" >> $env:GITHUB_OUTPUT
163+
}
154164
}
155165
156166
- name: Create or update draft release
157-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_tag.outputs.tag_exists == 'false'
167+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_release.outputs.skip_release == 'false'
158168
uses: softprops/action-gh-release@v2
159169
with:
160170
tag_name: v${{ env.VERSION }}

0 commit comments

Comments
 (0)