Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ on:
env:
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
PR_TRIGGER: ${{ github.event_name == 'pull_request' }}

jobs:
build:

# 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 }}
uses: actions/setup-dotnet@v4
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Compute and set build number
Expand All @@ -29,6 +33,7 @@ jobs:
- 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
Expand Down
14 changes: 10 additions & 4 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ dotnet --list-sdks
Write-Output "build: Build started"

Push-Location $PSScriptRoot

if($env:PR_TRIGGER -eq "true") {
$skipPackaging = $true
} else {
$skipPackaging = $false
}

try {
if(Test-Path .\artifacts) {
Write-Output "build: Cleaning ./artifacts"
Expand Down Expand Up @@ -57,10 +64,7 @@ try {
Pop-Location
}

if ($env:NUGET_API_KEY) {
# 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).

if ($skipPackaging -eq $false) {
Write-Output "build: Publishing NuGet package"

foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
Expand All @@ -73,6 +77,8 @@ try {

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
Expand Down