|
28 | 28 | Write-Host "Building release for version: $version" |
29 | 29 | echo "version=$version" >> $env:GITHUB_OUTPUT |
30 | 30 | |
| 31 | + - name: Check if release already exists |
| 32 | + id: check_release |
| 33 | + run: | |
| 34 | + $version = "${{ steps.get_version.outputs.version }}" |
| 35 | + $tagName = "v$version" |
| 36 | + |
| 37 | + # Fetch tags from remote to ensure we have the latest |
| 38 | + git fetch --tags --quiet 2>$null |
| 39 | + |
| 40 | + # Check if tag exists locally |
| 41 | + $tagExists = $false |
| 42 | + try { |
| 43 | + $result = git rev-parse --verify "refs/tags/$tagName" 2>$null |
| 44 | + if ($LASTEXITCODE -eq 0) { |
| 45 | + $tagExists = $true |
| 46 | + } |
| 47 | + } catch { |
| 48 | + $tagExists = $false |
| 49 | + } |
| 50 | + |
| 51 | + # If not found locally, check remote |
| 52 | + if (-not $tagExists) { |
| 53 | + try { |
| 54 | + $remoteResult = git ls-remote --tags origin "$tagName" 2>$null |
| 55 | + if ($remoteResult -and $remoteResult.Length -gt 0 -and $remoteResult -match $tagName) { |
| 56 | + $tagExists = $true |
| 57 | + } |
| 58 | + } catch { |
| 59 | + $tagExists = $false |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + if ($tagExists) { |
| 64 | + Write-Host "Release tag $tagName already exists. Skipping release creation." |
| 65 | + echo "should_create_release=false" >> $env:GITHUB_OUTPUT |
| 66 | + } else { |
| 67 | + Write-Host "Release tag $tagName does not exist. Will create new release." |
| 68 | + echo "should_create_release=true" >> $env:GITHUB_OUTPUT |
| 69 | + } |
| 70 | + |
31 | 71 | - name: Create logs directory |
32 | 72 | run: | |
33 | 73 | if (-not (Test-Path "logs")) { |
|
80 | 120 | |
81 | 121 | - name: Collect commits for release notes |
82 | 122 | id: collect_commits |
| 123 | + if: steps.check_release.outputs.should_create_release == 'true' |
83 | 124 | run: | |
84 | 125 | # Try to find the last release tag |
85 | 126 | $lastTag = $null |
@@ -118,6 +159,7 @@ jobs: |
118 | 159 | "EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append |
119 | 160 | |
120 | 161 | - name: Create Release |
| 162 | + if: steps.check_release.outputs.should_create_release == 'true' |
121 | 163 | run: | |
122 | 164 | $version = "${{ steps.get_version.outputs.version }}" |
123 | 165 | $exeName = "${{ steps.build_executable.outputs.exe_name }}" |
|
0 commit comments