diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6f569a2..a52a1c06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: env: CI_BUILD_NUMBER_BASE: ${{ github.run_number }} CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} - CI_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + CI_PUBLISH: ${{ github.event_name == 'push' && github.ref_name == 'main' }} jobs: build-windows: diff --git a/build/Build.Common.ps1 b/build/Build.Common.ps1 index 711462c1..7d9e97a1 100644 --- a/build/Build.Common.ps1 +++ b/build/Build.Common.ps1 @@ -3,14 +3,12 @@ function Get-SemVer() $branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH]; $revision = @{ $true = "{0:00000}" -f $([convert]::ToInt32($env:CI_BUILD_NUMBER_BASE, 10) + 2300); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER_BASE] $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"] - $commitHash = $(git rev-parse --short HEAD) - $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] $base = $(Get-Content ./baseversion).Trim() if ($suffix) { $base + "." + $revision + "-" + $suffix } else { - $revision + $base + "." + $revision } } diff --git a/build/Build.Linux.ps1 b/build/Build.Linux.ps1 index aa2c188a..21fca84a 100644 --- a/build/Build.Linux.ps1 +++ b/build/Build.Linux.ps1 @@ -2,8 +2,14 @@ Push-Location $PSScriptRoot/../ . ./build/Build.Common.ps1 +Write-Host "Run Number: $env:CI_BUILD_NUMBER_BASE" +Write-Host "Target Branch: $env:CI_TARGET_BRANCH" +Write-Host "Published: $env:CI_PUBLISH" + $version = Get-SemVer +Write-Output "Building version $version" + $framework = "net9.0" $image = "datalust/seqcli" $archs = @( diff --git a/build/Build.Windows.ps1 b/build/Build.Windows.ps1 index c36fe1f6..bc118297 100644 --- a/build/Build.Windows.ps1 +++ b/build/Build.Windows.ps1 @@ -4,8 +4,14 @@ Push-Location $PSScriptRoot/../ $ErrorActionPreference = 'Stop' +Write-Host "Run Number: $env:CI_BUILD_NUMBER_BASE" +Write-Host "Target Branch: $env:CI_TARGET_BRANCH" +Write-Host "Published: $env:CI_PUBLISH" + $version = Get-SemVer +Write-Output "Building version $version" + $framework = 'net9.0' $windowsTfmSuffix = '-windows' @@ -65,7 +71,9 @@ function Publish-Archives($version) } function Publish-DotNetTool($version) -{ +{ + Write-Output "Building dotnet tool" + # Tool packages have to target a single non-platform-specific TFM; doing this here is cleaner than attempting it in the CSPROJ directly dotnet pack ./src/SeqCli/SeqCli.csproj -c Release --output ./artifacts /p:VersionPrefix=$version /p:TargetFrameworks=$framework if($LASTEXITCODE -ne 0) { throw "Build failed" } @@ -84,7 +92,7 @@ function Upload-NugetPackages # GitHub Actions will only supply this to branch builds and not PRs. We publish # builds from any branch this action targets (i.e. main and dev). - Write-Output "build: Publishing NuGet packages" + Write-Output "Publishing NuGet packages" foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" @@ -94,7 +102,7 @@ function Upload-NugetPackages function Upload-GitHubRelease($version) { - Write-Output "build: Creating release for version $version" + Write-Output "Creating release for version $version" iex "gh release create v$version --title v$version --generate-notes $(get-item ./artifacts/*)" } @@ -113,8 +121,6 @@ function Create-GlobalJson cp ./ci.global.json global.json } -Write-Output "Building version $version" - $env:Path = "$pwd/.dotnetcli;$env:Path" Clean-Output