Skip to content

Commit 7959658

Browse files
committed
tweak publishing
1 parent c4f2aca commit 7959658

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +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' }}
1415

1516
jobs:
1617
build-windows:

build/Build.Linux.ps1

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

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

5-
$IsPublishedBuild = $null -ne $env:DOCKER_TOKEN
6-
75
$version = Get-SemVer
86

97
$framework = "net9.0"
@@ -80,7 +78,7 @@ foreach ($arch in $archs) {
8078
Build-DockerImage($arch)
8179
}
8280

83-
if ($IsPublishedBuild) {
81+
if ($env:DOCKER_TOKEN -ne $null) {
8482
Login-ToDocker
8583

8684
foreach ($arch in $archs) {

build/Build.Windows.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,26 @@ function Publish-Docs($version)
7979
if($LASTEXITCODE -ne 0) { throw "Build failed" }
8080
}
8181

82+
function Upload-NugetPackages
83+
{
84+
# GitHub Actions will only supply this to branch builds and not PRs. We publish
85+
# builds from any branch this action targets (i.e. main and dev).
86+
87+
Write-Output "build: Publishing NuGet packages"
88+
89+
foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
90+
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
91+
if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
92+
}
93+
}
94+
95+
function Upload-GitHubRelease($version)
96+
{
97+
Write-Output "build: Creating release for version $version"
98+
99+
iex "gh release create v$version --title v$version --generate-notes $(get-item ./artifacts/*)"
100+
}
101+
82102
function Remove-GlobalJson
83103
{
84104
if(Test-Path ./global.json) { rm ./global.json }
@@ -105,6 +125,16 @@ Publish-Archives($version)
105125
Publish-DotNetTool($version)
106126
Execute-Tests($version)
107127
Publish-Docs($version)
128+
129+
if ($env:NUGET_API_KEY -ne $null)
130+
{
131+
Upload-NugetPackages
132+
}
133+
134+
if ($env:CI_PUBLISH -eq "True") {
135+
Upload-GitHubRelease($version)
136+
}
137+
108138
Remove-GlobalJson
109139

110140
Pop-Location

0 commit comments

Comments
 (0)