Skip to content

Commit c212524

Browse files
committed
Uses special formatting for PR builds
1 parent 720c0b7 commit c212524

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,31 @@ jobs:
3232
Write-Host "Short hash: $(git rev-parse --short HEAD)"
3333
Write-Host "Git describe: $(git describe --tags)"
3434
Write-Host "Branch: ${{ github.ref_name }}"
35+
Write-Host "Event: ${{ github.event_name }}"
36+
Write-Host "Head ref: ${{ github.head_ref }}"
37+
shell: pwsh
38+
- name: Set version override
39+
run: |
40+
# For PR builds, use the source branch name and ignore height
41+
if ("${{ github.event_name }}" -eq "pull_request" -and "${{ github.head_ref }}" -ne "") {
42+
$branchName = "${{ github.head_ref }}"
43+
Write-Host "PR build from branch: $branchName"
44+
45+
# Sanitize branch name for version (replace invalid chars with dash)
46+
$branchName = $branchName -replace '[/\\]', '-'
47+
$branchName = $branchName -replace '[^a-zA-Z0-9\-]', ''
48+
49+
# Set the pre-release identifier
50+
$preRelease = "octopus-$branchName.${{ github.run_number }}"
51+
Write-Host "Setting MinVerDefaultPreReleaseIdentifiers to: $preRelease"
52+
"MINVERDEFAULTPRERELEASEIDENTIFIERS=$preRelease" >> $env:GITHUB_ENV
53+
54+
# Ignore height - use run number instead
55+
Write-Host "Ignoring git height"
56+
"MINVERIGNOHEIGHT=true" >> $env:GITHUB_ENV
57+
} else {
58+
Write-Host "Not a PR build - using standard MinVer behavior"
59+
}
3560
shell: pwsh
3661
- name: Install .NET SDK
3762
uses: actions/setup-dotnet@v4.0.0

0 commit comments

Comments
 (0)