Skip to content

Commit ecfd3a7

Browse files
committed
append branch name as a suffix when build is not main
1 parent 90ec963 commit ecfd3a7

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

Build.Common.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function Get-SemVer($shortver)
2+
{
3+
# This script originally (c) 2016 Serilog Contributors - license Apache 2.0
4+
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
5+
$suffix = @{ $true = ""; $false = ($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '[\/\+]','-').Trim("-")}[$branch -eq "main"]
6+
7+
if ($suffix) {
8+
$shortver + "-" + $suffix
9+
} else {
10+
$shortver
11+
}
12+
}

Build.Docker.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
Push-Location $PSScriptRoot
2+
13
$IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
24
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "main" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
35

4-
$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
6+
$version = Get-SemVer(@{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL])
57
$framework = "net7.0"
68
$image = "datalust/seqcli"
79
$archs = @(
@@ -65,8 +67,6 @@ function Publish-DockerManifest($archs)
6567
if ($LASTEXITCODE) { exit 4 }
6668
}
6769

68-
Push-Location $PSScriptRoot
69-
7070
Execute-Tests
7171

7272
foreach ($arch in $archs) {

Build.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
Push-Location $PSScriptRoot
2+
3+
. ./Build.Common.ps1
4+
15
$ErrorActionPreference = 'Stop'
26

7+
$version = Get-SemVer(@{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL])
38
$framework = 'net7.0'
49
$windowsTfmSuffix = '-windows'
510

@@ -73,9 +78,6 @@ function Publish-Docs($version)
7378
if($LASTEXITCODE -ne 0) { throw "Build failed" }
7479
}
7580

76-
Push-Location $PSScriptRoot
77-
78-
$version = @{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL];
7981
Write-Output "Building version $version"
8082

8183
$env:Path = "$pwd/.dotnetcli;$env:Path"

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ for:
2525
- pwsh: ./Setup.ps1
2626

2727
build_script:
28-
- pwsh: ./Build.ps1 -shortver "$($env:APPVEYOR_BUILD_VERSION)"
28+
- pwsh: ./Build.ps1
2929

3030
deploy:
3131

@@ -53,4 +53,4 @@ for:
5353
- pwsh: ./setup.sh
5454

5555
build_script:
56-
- pwsh: $env:PATH = "$env:HOME/.dotnetcli:$env:PATH"; ./Build.Docker.ps1 -shortver "$($env:APPVEYOR_BUILD_VERSION)"
56+
- pwsh: $env:PATH = "$env:HOME/.dotnetcli:$env:PATH"; ./Build.Docker.ps1

0 commit comments

Comments
 (0)