This commit is contained in:
@@ -89,15 +89,15 @@ jobs:
|
||||
|
||||
git commit -m 'Update version to ${{ github.ref_name }}'
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host 'No changes to commit.'
|
||||
# Version files already match the tag -> nothing to push, succeed quietly.
|
||||
Write-Host 'No version changes to commit; skipping push.'
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Get current branch; if detached, resolve to a remote branch that contains this commit
|
||||
$branch = (git rev-parse --abbrev-ref HEAD).Trim()
|
||||
if ($branch -eq 'HEAD' -or [string]::IsNullOrEmpty($branch)) {
|
||||
# If target_commitish is a branch, use it; if it's a SHA, find a branch that contains it
|
||||
$candidate = '${{ github.event.release.target_commitish }}'
|
||||
if ($candidate -match '^[0-9a-f]{40}$') {
|
||||
# The release build runs in detached HEAD on the tag. Resolve the branch
|
||||
# that should receive the version bump.
|
||||
$branch = '${{ github.event.release.target_commitish }}'
|
||||
if ([string]::IsNullOrEmpty($branch) -or $branch -match '^[0-9a-f]{40}$') {
|
||||
$branch = (
|
||||
git branch -r --contains $env:GITHUB_SHA |
|
||||
ForEach-Object { $_.Trim() } |
|
||||
@@ -105,9 +105,6 @@ jobs:
|
||||
ForEach-Object { $_ -replace '^(?:remotes/)?[^/]+/', '' } |
|
||||
Select-Object -First 1
|
||||
)
|
||||
} else {
|
||||
$branch = $candidate
|
||||
}
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrEmpty($branch)) {
|
||||
@@ -116,6 +113,16 @@ jobs:
|
||||
exit 1
|
||||
}
|
||||
|
||||
# The tag may be behind the branch tip. Replay the bump commit on top of
|
||||
# the current remote branch so the push is a clean fast-forward.
|
||||
git fetch origin $branch
|
||||
git rebase "origin/$branch"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
git rebase --abort
|
||||
Write-Host "Rebase onto origin/$branch failed."
|
||||
exit 1
|
||||
}
|
||||
|
||||
git push origin "HEAD:refs/heads/$branch"
|
||||
|
||||
- name: Build Tauri App
|
||||
|
||||
Reference in New Issue
Block a user