From 2f8351efba997ab08ec52665d4ddac5e3966a3b9 Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 19:32:22 +0100 Subject: [PATCH 01/10] fix: add correct permissions to create github release --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95eb046..b54e361 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,9 @@ jobs: # We need to run on Windows as we're supporting .NET Framework runs-on: windows-latest + permissions: + contents: write + steps: - uses: actions/checkout@v5 - name: Setup .NET ${{ env.NET_VERSION }} From d151bd1d99ffa8b1fbecb344a76f92a4a38a699d Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 19:35:20 +0100 Subject: [PATCH 02/10] refactor: remove unecessary var expose --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b54e361..3f79aaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Setup .NET ${{ env.NET_VERSION }} + - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 10.0.x From 408284f921b8e374ded85ec2725bb063545ee66f Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 19:58:54 +0100 Subject: [PATCH 03/10] test: we need to test variables on pull_request events --- .github/workflows/ci.yml | 5 +++-- Build.ps1 | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f79aaf..b5bc38d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v5 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: dotnet-version: 10.0.x - name: Compute and set build number @@ -32,7 +32,8 @@ jobs: - name: Build & Push env: DOTNET_CLI_TELEMTRY_OPTOUT: true - NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + DUMMY: ${{ secrets.DUMMY }} + # NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: pwsh run: | diff --git a/Build.ps1 b/Build.ps1 index dcdafc0..7030e85 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -57,22 +57,24 @@ try { Pop-Location } - if ($env:NUGET_API_KEY) { + if ($env:DUMMY) { # GitHub Actions will only supply this to branch builds and not PRs. We publish # builds from any branch this action targets (i.e. master and dev). - Write-Output "build: Publishing NuGet package" + Write-Output "DUMMY value: $env:DUMMY" - foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { - & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" - if($LASTEXITCODE -ne 0) { throw "Publishing failed" } - } + # Write-Output "build: Publishing NuGet package" - if (!($suffix)) { - Write-Output "build: Creating release for version $versionPrefix" + # foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { + # & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" + # if($LASTEXITCODE -ne 0) { throw "Publishing failed" } + # } - iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)" - } + # if (!($suffix)) { + # Write-Output "build: Creating release for version $versionPrefix" + + # iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)" + # } } } finally { Pop-Location From c7006d9606463651c74105dc2ae7963fe5250e7a Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 20:34:41 +0100 Subject: [PATCH 04/10] test --- .github/workflows/ci.yml | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5bc38d..48ce39c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ on: env: CI_BUILD_NUMBER_BASE: ${{ github.run_number }} CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} + PR_RUN: ${{ github.event_name == 'pull_request' }} jobs: build: @@ -21,20 +22,24 @@ jobs: steps: - uses: actions/checkout@v5 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: 10.0.x - - name: Compute and set build number + # - name: Setup .NET + # uses: actions/setup-dotnet@v5 + # with: + # dotnet-version: 10.0.x + # - name: Compute and set build number + # shell: bash + # run: | + # echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+1000))" >> $GITHUB_ENV + - name: TEST PR RUN CHECK shell: bash run: | - echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+1000))" >> $GITHUB_ENV - - name: Build & Push - env: - DOTNET_CLI_TELEMTRY_OPTOUT: true - DUMMY: ${{ secrets.DUMMY }} - # NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: pwsh - run: | - ./Build.ps1 \ No newline at end of file + echo "$(($PR_RUN))" + # - name: Build & Push + # env: + # DOTNET_CLI_TELEMTRY_OPTOUT: true + # DUMMY: ${{ secrets.DUMMY }} + # NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # shell: pwsh + # run: | + # ./Build.ps1 \ No newline at end of file From 9faaad921004b733357a418c03cfdf00c1f377ea Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 20:35:45 +0100 Subject: [PATCH 05/10] test --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48ce39c..18e5597 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: env: CI_BUILD_NUMBER_BASE: ${{ github.run_number }} CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} - PR_RUN: ${{ github.event_name == 'pull_request' }} + TRIGGER: ${{ github.event_name }} jobs: build: @@ -33,7 +33,7 @@ jobs: - name: TEST PR RUN CHECK shell: bash run: | - echo "$(($PR_RUN))" + echo "$(($TRIGGER))" # - name: Build & Push # env: # DOTNET_CLI_TELEMTRY_OPTOUT: true From 79c8d14f7e108868e743d4ee17414beead860dc1 Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 20:36:49 +0100 Subject: [PATCH 06/10] test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18e5597..118088a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - name: TEST PR RUN CHECK shell: bash run: | - echo "$(($TRIGGER))" + echo "$TRIGGER" # - name: Build & Push # env: # DOTNET_CLI_TELEMTRY_OPTOUT: true From ba30686a7863f865ef0aa374e864122cbf8b0960 Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 20:37:36 +0100 Subject: [PATCH 07/10] test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 118088a..301da21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: env: CI_BUILD_NUMBER_BASE: ${{ github.run_number }} CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} - TRIGGER: ${{ github.event_name }} + TRIGGER: ${{ github.event_name == 'pull_request' }} jobs: build: From 4bf9ab0656a7e91739c4c745d3237b445db3bb59 Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 20:39:23 +0100 Subject: [PATCH 08/10] test --- .github/workflows/ci.yml | 22 ++++---- Build.ps1 | 109 ++++++++++++++++++++------------------- 2 files changed, 67 insertions(+), 64 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 301da21..b401632 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: env: CI_BUILD_NUMBER_BASE: ${{ github.run_number }} CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} - TRIGGER: ${{ github.event_name == 'pull_request' }} + PR_TRIGGER: ${{ github.event_name == 'pull_request' }} jobs: build: @@ -33,13 +33,13 @@ jobs: - name: TEST PR RUN CHECK shell: bash run: | - echo "$TRIGGER" - # - name: Build & Push - # env: - # DOTNET_CLI_TELEMTRY_OPTOUT: true - # DUMMY: ${{ secrets.DUMMY }} - # NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # shell: pwsh - # run: | - # ./Build.ps1 \ No newline at end of file + echo "$PR_TRIGGER" + - name: Build & Push + env: + DOTNET_CLI_TELEMTRY_OPTOUT: true + PR_TRIGGER: ${{ env.PR_TRIGGER }} + #NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + #GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: pwsh + run: | + ./Build.ps1 \ No newline at end of file diff --git a/Build.ps1 b/Build.ps1 index 7030e85..a952184 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -6,76 +6,79 @@ dotnet --list-sdks Write-Output "build: Build started" Push-Location $PSScriptRoot -try { - if(Test-Path .\artifacts) { - Write-Output "build: Cleaning ./artifacts" - Remove-Item ./artifacts -Force -Recurse - } - & dotnet restore --no-cache +Write-Output "build: PR_TRIGGER value: $env:PR_TRIGGER" - $dvp = [Xml] (Get-Content .\Directory.Version.props) - $versionPrefix = $dvp.Project.PropertyGroup.VersionPrefix +# try { +# if(Test-Path .\artifacts) { +# Write-Output "build: Cleaning ./artifacts" +# Remove-Item ./artifacts -Force -Recurse +# } - Write-Output "build: Package base version is $versionPrefix" +# & dotnet restore --no-cache - $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("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER]; - $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "master" -and $revision -ne "local"] - $commitHash = $(git rev-parse --short HEAD) - $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] +# $dvp = [Xml] (Get-Content .\Directory.Version.props) +# $versionPrefix = $dvp.Project.PropertyGroup.VersionPrefix - Write-Output "build: Package version suffix is $suffix" - Write-Output "build: Build version suffix is $buildSuffix" +# Write-Output "build: Package base version is $versionPrefix" - & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true - if($LASTEXITCODE -ne 0) { throw "Build failed" } +# $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("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER]; +# $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "master" -and $revision -ne "local"] +# $commitHash = $(git rev-parse --short HEAD) +# $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] - foreach ($src in Get-ChildItem src/*) { - Push-Location $src +# Write-Output "build: Package version suffix is $suffix" +# Write-Output "build: Build version suffix is $buildSuffix" - Write-Output "build: Packaging project in $src" +# & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true +# if($LASTEXITCODE -ne 0) { throw "Build failed" } - if ($suffix) { - & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix - } else { - & dotnet pack -c Release --no-build --no-restore -o ../../artifacts - } - if($LASTEXITCODE -ne 0) { throw "Packaging failed" } +# foreach ($src in Get-ChildItem src/*) { +# Push-Location $src - Pop-Location - } +# Write-Output "build: Packaging project in $src" - foreach ($test in Get-ChildItem tests/) { - Push-Location $test +# if ($suffix) { +# & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix +# } else { +# & dotnet pack -c Release --no-build --no-restore -o ../../artifacts +# } +# if($LASTEXITCODE -ne 0) { throw "Packaging failed" } - Write-Output "build: Testing project in $test" +# Pop-Location +# } - & dotnet test -c Release --no-build --no-restore - if($LASTEXITCODE -ne 0) { throw "Testing failed" } +# foreach ($test in Get-ChildItem tests/) { +# Push-Location $test - Pop-Location - } +# Write-Output "build: Testing project in $test" - if ($env:DUMMY) { - # GitHub Actions will only supply this to branch builds and not PRs. We publish - # builds from any branch this action targets (i.e. master and dev). +# & dotnet test -c Release --no-build --no-restore +# if($LASTEXITCODE -ne 0) { throw "Testing failed" } - Write-Output "DUMMY value: $env:DUMMY" +# Pop-Location +# } - # Write-Output "build: Publishing NuGet package" +# if ($env:DUMMY) { +# # GitHub Actions will only supply this to branch builds and not PRs. We publish +# # builds from any branch this action targets (i.e. master and dev). - # foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { - # & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" - # if($LASTEXITCODE -ne 0) { throw "Publishing failed" } - # } +# Write-Output "DUMMY value: $env:DUMMY" - # if (!($suffix)) { - # Write-Output "build: Creating release for version $versionPrefix" +# # Write-Output "build: Publishing NuGet package" - # iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)" - # } - } -} finally { - Pop-Location -} \ No newline at end of file +# # foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { +# # & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" +# # if($LASTEXITCODE -ne 0) { throw "Publishing failed" } +# # } + +# # if (!($suffix)) { +# # Write-Output "build: Creating release for version $versionPrefix" + +# # iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)" +# # } +# } +# } finally { +# Pop-Location +# } \ No newline at end of file From 3395ce7952e525fa38849c41ca28240671eb3600 Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 20:40:41 +0100 Subject: [PATCH 09/10] test --- Build.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Build.ps1 b/Build.ps1 index a952184..581e7ca 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -9,6 +9,13 @@ Push-Location $PSScriptRoot Write-Output "build: PR_TRIGGER value: $env:PR_TRIGGER" +if($env:PR_TRIGGER -eq "true") { + Write-Output "build: This is a PR build - skipping packaging and publishing steps" + $skipPackaging = $true +} else { + $skipPackaging = $false +} + # try { # if(Test-Path .\artifacts) { # Write-Output "build: Cleaning ./artifacts" From 9f652e77596291d6b9ff86fda62d3cabc8e9d3df Mon Sep 17 00:00:00 2001 From: ChristianHaase Date: Fri, 21 Nov 2025 20:43:50 +0100 Subject: [PATCH 10/10] test --- .github/workflows/ci.yml | 20 +++---- Build.ps1 | 110 ++++++++++++++++++--------------------- 2 files changed, 60 insertions(+), 70 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b401632..b35c20e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,24 +22,20 @@ jobs: steps: - uses: actions/checkout@v5 - # - name: Setup .NET - # uses: actions/setup-dotnet@v5 - # with: - # dotnet-version: 10.0.x - # - name: Compute and set build number - # shell: bash - # run: | - # echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+1000))" >> $GITHUB_ENV - - name: TEST PR RUN CHECK + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: 10.0.x + - name: Compute and set build number shell: bash run: | - echo "$PR_TRIGGER" + echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+1000))" >> $GITHUB_ENV - name: Build & Push env: DOTNET_CLI_TELEMTRY_OPTOUT: true PR_TRIGGER: ${{ env.PR_TRIGGER }} - #NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} - #GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: pwsh run: | ./Build.ps1 \ No newline at end of file diff --git a/Build.ps1 b/Build.ps1 index 581e7ca..dd08ce7 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -7,85 +7,79 @@ Write-Output "build: Build started" Push-Location $PSScriptRoot -Write-Output "build: PR_TRIGGER value: $env:PR_TRIGGER" - if($env:PR_TRIGGER -eq "true") { - Write-Output "build: This is a PR build - skipping packaging and publishing steps" $skipPackaging = $true } else { $skipPackaging = $false } -# try { -# if(Test-Path .\artifacts) { -# Write-Output "build: Cleaning ./artifacts" -# Remove-Item ./artifacts -Force -Recurse -# } - -# & dotnet restore --no-cache - -# $dvp = [Xml] (Get-Content .\Directory.Version.props) -# $versionPrefix = $dvp.Project.PropertyGroup.VersionPrefix +try { + if(Test-Path .\artifacts) { + Write-Output "build: Cleaning ./artifacts" + Remove-Item ./artifacts -Force -Recurse + } -# Write-Output "build: Package base version is $versionPrefix" + & dotnet restore --no-cache -# $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("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER]; -# $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "master" -and $revision -ne "local"] -# $commitHash = $(git rev-parse --short HEAD) -# $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] + $dvp = [Xml] (Get-Content .\Directory.Version.props) + $versionPrefix = $dvp.Project.PropertyGroup.VersionPrefix -# Write-Output "build: Package version suffix is $suffix" -# Write-Output "build: Build version suffix is $buildSuffix" + Write-Output "build: Package base version is $versionPrefix" -# & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true -# if($LASTEXITCODE -ne 0) { throw "Build failed" } + $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("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER]; + $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "master" -and $revision -ne "local"] + $commitHash = $(git rev-parse --short HEAD) + $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] -# foreach ($src in Get-ChildItem src/*) { -# Push-Location $src + Write-Output "build: Package version suffix is $suffix" + Write-Output "build: Build version suffix is $buildSuffix" -# Write-Output "build: Packaging project in $src" + & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true + if($LASTEXITCODE -ne 0) { throw "Build failed" } -# if ($suffix) { -# & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix -# } else { -# & dotnet pack -c Release --no-build --no-restore -o ../../artifacts -# } -# if($LASTEXITCODE -ne 0) { throw "Packaging failed" } + foreach ($src in Get-ChildItem src/*) { + Push-Location $src -# Pop-Location -# } + Write-Output "build: Packaging project in $src" -# foreach ($test in Get-ChildItem tests/) { -# Push-Location $test + if ($suffix) { + & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix + } else { + & dotnet pack -c Release --no-build --no-restore -o ../../artifacts + } + if($LASTEXITCODE -ne 0) { throw "Packaging failed" } -# Write-Output "build: Testing project in $test" + Pop-Location + } -# & dotnet test -c Release --no-build --no-restore -# if($LASTEXITCODE -ne 0) { throw "Testing failed" } + foreach ($test in Get-ChildItem tests/) { + Push-Location $test -# Pop-Location -# } + Write-Output "build: Testing project in $test" -# if ($env:DUMMY) { -# # GitHub Actions will only supply this to branch builds and not PRs. We publish -# # builds from any branch this action targets (i.e. master and dev). + & dotnet test -c Release --no-build --no-restore + if($LASTEXITCODE -ne 0) { throw "Testing failed" } -# Write-Output "DUMMY value: $env:DUMMY" + Pop-Location + } -# # Write-Output "build: Publishing NuGet package" + if ($skipPackaging -eq $false) { + Write-Output "build: Publishing NuGet package" -# # foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { -# # & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" -# # if($LASTEXITCODE -ne 0) { throw "Publishing failed" } -# # } + foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { + & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" + if($LASTEXITCODE -ne 0) { throw "Publishing failed" } + } -# # if (!($suffix)) { -# # Write-Output "build: Creating release for version $versionPrefix" + if (!($suffix)) { + Write-Output "build: Creating release for version $versionPrefix" -# # iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)" -# # } -# } -# } finally { -# Pop-Location -# } \ No newline at end of file + iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)" + } + } else { + Write-Output "build: Skipping publishing steps for PR build" + } +} finally { + Pop-Location +} \ No newline at end of file