Skip to content

Commit 687b71e

Browse files
authored
Merge pull request #392 from KodrAus/ci/version-numbers
Fix up version computing
2 parents 62bb43a + e13e41a commit 687b71e

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
env:
1212
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
1313
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
14-
CI_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
14+
CI_PUBLISH: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
1515

1616
jobs:
1717
build-windows:

build/Build.Common.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ function Get-SemVer()
33
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
44
$revision = @{ $true = "{0:00000}" -f $([convert]::ToInt32($env:CI_BUILD_NUMBER_BASE, 10) + 2300); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER_BASE]
55
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
6-
$commitHash = $(git rev-parse --short HEAD)
7-
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
86

97
$base = $(Get-Content ./baseversion).Trim()
108

119
if ($suffix) {
1210
$base + "." + $revision + "-" + $suffix
1311
} else {
14-
$revision
12+
$base + "." + $revision
1513
}
1614
}

build/Build.Linux.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ Push-Location $PSScriptRoot/../
22

33
. ./build/Build.Common.ps1
44

5+
Write-Host "Run Number: $env:CI_BUILD_NUMBER_BASE"
6+
Write-Host "Target Branch: $env:CI_TARGET_BRANCH"
7+
Write-Host "Published: $env:CI_PUBLISH"
8+
59
$version = Get-SemVer
610

11+
Write-Output "Building version $version"
12+
713
$framework = "net9.0"
814
$image = "datalust/seqcli"
915
$archs = @(

build/Build.Windows.ps1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ Push-Location $PSScriptRoot/../
44

55
$ErrorActionPreference = 'Stop'
66

7+
Write-Host "Run Number: $env:CI_BUILD_NUMBER_BASE"
8+
Write-Host "Target Branch: $env:CI_TARGET_BRANCH"
9+
Write-Host "Published: $env:CI_PUBLISH"
10+
711
$version = Get-SemVer
812

13+
Write-Output "Building version $version"
14+
915
$framework = 'net9.0'
1016
$windowsTfmSuffix = '-windows'
1117

@@ -65,7 +71,9 @@ function Publish-Archives($version)
6571
}
6672

6773
function Publish-DotNetTool($version)
68-
{
74+
{
75+
Write-Output "Building dotnet tool"
76+
6977
# Tool packages have to target a single non-platform-specific TFM; doing this here is cleaner than attempting it in the CSPROJ directly
7078
dotnet pack ./src/SeqCli/SeqCli.csproj -c Release --output ./artifacts /p:VersionPrefix=$version /p:TargetFrameworks=$framework
7179
if($LASTEXITCODE -ne 0) { throw "Build failed" }
@@ -84,7 +92,7 @@ function Upload-NugetPackages
8492
# GitHub Actions will only supply this to branch builds and not PRs. We publish
8593
# builds from any branch this action targets (i.e. main and dev).
8694

87-
Write-Output "build: Publishing NuGet packages"
95+
Write-Output "Publishing NuGet packages"
8896

8997
foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
9098
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
@@ -94,7 +102,7 @@ function Upload-NugetPackages
94102

95103
function Upload-GitHubRelease($version)
96104
{
97-
Write-Output "build: Creating release for version $version"
105+
Write-Output "Creating release for version $version"
98106

99107
iex "gh release create v$version --title v$version --generate-notes $(get-item ./artifacts/*)"
100108
}
@@ -113,8 +121,6 @@ function Create-GlobalJson
113121
cp ./ci.global.json global.json
114122
}
115123

116-
Write-Output "Building version $version"
117-
118124
$env:Path = "$pwd/.dotnetcli;$env:Path"
119125

120126
Clean-Output

0 commit comments

Comments
 (0)