Skip to content

Commit 30c9388

Browse files
OMG IS THIS WORK NO
1 parent ea22dc9 commit 30c9388

1 file changed

Lines changed: 43 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,30 @@ jobs:
2828
id: check_files
2929
shell: pwsh
3030
run: |
31+
Write-Output "DEBUG: Starting check_files"
32+
Write-Output "DEBUG: PR Event Data - Base: ${{ github.event.pull_request.base.sha }} - Head: ${{ github.event.pull_request.head.sha }}"
33+
3134
$changedFiles = git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
32-
Write-Output "Changed files:"
35+
Write-Output "DEBUG: Changed files found:"
3336
Write-Output $changedFiles
3437
3538
$sourceChanged = $false
3639
foreach ($file in $changedFiles) {
3740
if ($file -match '\.(cpp|h|hpp|c|cc|cxx)$') {
3841
$sourceChanged = $true
39-
Write-Output "Source file changed: $file"
42+
Write-Output "DEBUG: Source file changed: $file"
4043
break
4144
}
4245
}
4346
47+
Write-Output "DEBUG: sourceChanged is $sourceChanged"
48+
4449
if ($sourceChanged) {
4550
Write-Output "should_release=true" >> $env:GITHUB_OUTPUT
46-
Write-Output "Source files changed - will proceed with release"
51+
Write-Output "DEBUG: Setting should_release=true"
4752
} else {
4853
Write-Output "should_release=false" >> $env:GITHUB_OUTPUT
49-
Write-Output "No source files changed - skipping release"
54+
Write-Output "DEBUG: Setting should_release=false"
5055
}
5156
5257
- name: Get latest release tag
@@ -56,33 +61,45 @@ jobs:
5661
env:
5762
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5863
run: |
64+
Write-Output "DEBUG: Starting get_latest_tag"
5965
$repo = "${{ github.repository }}"
66+
Write-Output "DEBUG: Repo is $repo"
67+
6068
$headers = @{"Authorization" = "token $env:GITHUB_TOKEN"; "Accept" = "application/vnd.github.v3+json"}
6169
6270
# Try GitHub Releases API first (includes prereleases)
6371
try {
72+
Write-Output "DEBUG: Fetching releases from API..."
6473
$releases = Invoke-RestMethod -Uri "https://api.github.com/repos/$repo/releases?per_page=100" -Headers $headers -UseBasicParsing
74+
Write-Output "DEBUG: Fetched $($releases.Count) releases"
6575
} catch {
76+
Write-Output "DEBUG: Failed to fetch releases from API: $_"
6677
$releases = @()
6778
}
6879
6980
$candidates = @()
7081
foreach ($r in $releases) {
82+
Write-Output "DEBUG: Checking release tag: $($r.tag_name)"
7183
if ($r.tag_name -match 'v?(\d+)\.(\d+)\.(\d+)') {
7284
$candidates += [PSCustomObject]@{ Tag = $r.tag_name; Major = [int]$Matches[1]; Minor = [int]$Matches[2]; Patch = [int]$Matches[3] }
7385
}
7486
}
7587
7688
if ($candidates.Count -gt 0) {
89+
Write-Output "DEBUG: Found valid candidates in releases."
7790
$sorted = $candidates | Sort-Object -Property @{Expression={$_.Major};Descending=$true}, @{Expression={$_.Minor};Descending=$true}, @{Expression={$_.Patch};Descending=$true}
7891
$latestTag = $sorted[0].Tag
92+
Write-Output "DEBUG: Selected latest tag from API: $latestTag"
7993
Write-Output "latest_tag=$latestTag" >> $env:GITHUB_OUTPUT
8094
exit 0
8195
}
8296
8397
# Fallback: ensure tags are fetched and inspect local tags
98+
Write-Output "DEBUG: Fallback to local git tags"
8499
git fetch --tags --prune || true
85100
$local = git tag -l "v[0-9]*.[0-9]*.[0-9]*"
101+
Write-Output "DEBUG: Local tags found: $local"
102+
86103
if ($local) {
87104
$sortedTags = $local | ForEach-Object {
88105
if ($_ -match 'v?(\d+)\.(\d+)\.(\d+)') {
@@ -91,11 +108,14 @@ jobs:
91108
} | Sort-Object -Property @{Expression={$_.Major};Descending=$true}, @{Expression={$_.Minor};Descending=$true}, @{Expression={$_.Patch};Descending=$true}
92109
if ($sortedTags.Count -gt 0) {
93110
$latestTag = $sortedTags[0].Tag
111+
Write-Output "DEBUG: Selected latest tag from local tags: $latestTag"
94112
Write-Output "latest_tag=$latestTag" >> $env:GITHUB_OUTPUT
95113
} else {
114+
Write-Output "DEBUG: No valid semantic version tags found locally. Defaulting to v0.0.0"
96115
Write-Output "latest_tag=v0.0.0" >> $env:GITHUB_OUTPUT
97116
}
98117
} else {
118+
Write-Output "DEBUG: No local tags found. Defaulting to v0.0.0"
99119
Write-Output "latest_tag=v0.0.0" >> $env:GITHUB_OUTPUT
100120
}
101121
@@ -105,12 +125,15 @@ jobs:
105125
shell: pwsh
106126
run: |
107127
$latestTag = "${{ steps.get_latest_tag.outputs.latest_tag }}"
128+
Write-Output "DEBUG: Starting next_version. Input latestTag: $latestTag"
129+
108130
if ($latestTag -match 'v?(\d+)\.(\d+)\.(\d+)') {
109131
$major = [int]$Matches[1]
110132
$minor = [int]$Matches[2]
111133
$patch = [int]$Matches[3]
112134
$patch = $patch + 1
113135
$newVersion = "v$major.$minor.$patch"
136+
Write-Output "DEBUG: Calculated new version: $newVersion"
114137
Write-Output "version=$newVersion" >> $env:GITHUB_OUTPUT
115138
Write-Output "version_number=$major.$minor.$patch" >> $env:GITHUB_OUTPUT
116139
} else {
@@ -123,7 +146,10 @@ jobs:
123146
id: parse_commit
124147
shell: pwsh
125148
run: |
149+
Write-Output "DEBUG: Starting parse_commit"
126150
$commitMsg = git log -1 --pretty=%B
151+
Write-Output "DEBUG: Commit message: $commitMsg"
152+
127153
$commitSubject = $commitMsg.Split("`n")[0]
128154
$commitBodyLines = $commitMsg.Split("`n") | Select-Object -Skip 1
129155
$commitBody = ($commitBodyLines -join "`n").Trim()
@@ -157,10 +183,12 @@ jobs:
157183
$releaseNotes += "`n$commitBody`n"
158184
}
159185
186+
Write-Output "DEBUG: releaseNotes: $releaseNotes"
160187
$commitSha = git rev-parse --short HEAD
161188
$releaseNotes += "`n---`n*Commit: $commitSha*"
162189

163190
$delimiter = "EOF_$(Get-Random)"
191+
Write-Output "DEBUG: Writing notes to output using delimiter $delimiter"
164192
Write-Output "notes<<$delimiter" >> $env:GITHUB_OUTPUT
165193
Write-Output $releaseNotes >> $env:GITHUB_OUTPUT
166194
Write-Output $delimiter >> $env:GITHUB_OUTPUT
@@ -237,6 +265,10 @@ jobs:
237265
shell: bash
238266
run: |
239267
set -e
268+
echo "DEBUG: Ensure Release Tag Exists"
269+
echo "DEBUG: received version: '${{ needs.prepare.outputs.version }}'"
270+
echo "DEBUG: received sha: $(git rev-parse HEAD)"
271+
240272
git config user.name "github-actions[bot]"
241273
git config user.email "github-actions[bot]@users.noreply.github.com"
242274
@@ -247,13 +279,17 @@ jobs:
247279
exit 1
248280
fi
249281
if git rev-parse "$TAG" >/dev/null 2>&1; then
250-
echo "Tag $TAG already exists locally"
282+
echo "DEBUG: Tag $TAG already exists locally"
251283
else
252-
git tag -a "$TAG" -m "Release $TAG"
253-
echo "Created local tag $TAG"
284+
# Explicitly tag the HEAD sha to match the checked out state
285+
HEAD_SHA=$(git rev-parse HEAD)
286+
echo "DEBUG: Creating tag $TAG on $HEAD_SHA"
287+
git tag -a "$TAG" -m "Release $TAG" "$HEAD_SHA"
288+
echo "DEBUG: Created local tag $TAG"
254289
fi
255290
256291
# Push tag (skip errors if it already exists on remote)
292+
echo "DEBUG: Pushing tag $TAG"
257293
git push origin "$TAG" || echo "Tag push failed or already exists on remote"
258294
259295
- name: Create Release and Upload Assets

0 commit comments

Comments
 (0)