File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111env :
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
1516jobs :
1617 build-windows :
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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+
82102function Remove-GlobalJson
83103{
84104 if (Test-Path ./ global.json) { rm ./ global.json }
@@ -105,6 +125,16 @@ Publish-Archives($version)
105125Publish-DotNetTool ($version )
106126Execute- Tests($version )
107127Publish-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+
108138Remove-GlobalJson
109139
110140Pop-Location
You can’t perform that action at this time.
0 commit comments