Skip to content

Commit 4989e77

Browse files
committed
Use self-hosted pool for main pipeline
1 parent 1661689 commit 4989e77

1 file changed

Lines changed: 54 additions & 37 deletions

File tree

azure-pipelines.yml

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ stages:
2929
- job: build
3030
displayName: Restore, build, test, and pack
3131
pool:
32-
vmImage: ubuntu-latest
32+
name: Default
3333
steps:
3434
- checkout: self
3535
fetchDepth: 0
@@ -49,12 +49,16 @@ stages:
4949
- script: dotnet tool restore
5050
displayName: Restore local tools
5151

52-
- script: |
53-
set -euo pipefail
54-
semVer=$(dotnet tool run dotnet-gitversion /output json /showvariable SemVer /nonormalize)
55-
echo "Calculated SemVer: $semVer"
56-
echo "##vso[task.setvariable variable=SemVer]$semVer"
57-
echo "##vso[build.updatebuildnumber]$semVer"
52+
- pwsh: |
53+
$semVer = dotnet tool run dotnet-gitversion /output json /showvariable SemVer /nonormalize
54+
if ([string]::IsNullOrWhiteSpace($semVer))
55+
{
56+
throw "GitVersion did not return a semantic version."
57+
}
58+
59+
Write-Host "Calculated SemVer: $semVer"
60+
Write-Host "##vso[task.setvariable variable=SemVer]$semVer"
61+
Write-Host "##vso[build.updatebuildnumber]$semVer"
5862
displayName: Calculate semantic version
5963
6064
- script: dotnet restore "$(SolutionFile)"
@@ -66,14 +70,16 @@ stages:
6670
- script: dotnet test "$(SolutionFile)" --configuration "$(BuildConfiguration)" --no-build --no-restore --filter "Category!=SlowLane"
6771
displayName: Test
6872

69-
- script: |
70-
mkdir -p "$(Build.ArtifactStagingDirectory)/packages/core"
71-
dotnet pack "$(CoreProject)" --configuration "$(BuildConfiguration)" --no-build --no-restore -p:PackageVersion="$(SemVer)" --output "$(Build.ArtifactStagingDirectory)/packages/core"
73+
- pwsh: |
74+
$outputDirectory = "$(Build.ArtifactStagingDirectory)/packages/core"
75+
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
76+
dotnet pack "$(CoreProject)" --configuration "$(BuildConfiguration)" --no-build --no-restore -p:PackageVersion="$(SemVer)" --output $outputDirectory
7277
displayName: Pack BitNetSharp.Core
7378
74-
- script: |
75-
mkdir -p "$(Build.ArtifactStagingDirectory)/packages/tool"
76-
dotnet pack "$(AppProject)" --configuration "$(BuildConfiguration)" --no-build --no-restore -p:PackageVersion="$(SemVer)" --output "$(Build.ArtifactStagingDirectory)/packages/tool"
79+
- pwsh: |
80+
$outputDirectory = "$(Build.ArtifactStagingDirectory)/packages/tool"
81+
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
82+
dotnet pack "$(AppProject)" --configuration "$(BuildConfiguration)" --no-build --no-restore -p:PackageVersion="$(SemVer)" --output $outputDirectory
7783
displayName: Pack BitNetSharp.App dotnet tool
7884
7985
- task: PublishPipelineArtifact@1
@@ -96,7 +102,7 @@ stages:
96102
- job: publish
97103
displayName: Push tagged packages to NuGet feed
98104
pool:
99-
vmImage: ubuntu-latest
105+
name: Default
100106
steps:
101107
- checkout: self
102108

@@ -121,32 +127,43 @@ stages:
121127
- task: NuGetAuthenticate@1
122128
displayName: Authenticate package publishing
123129

124-
- script: |
125-
set -euo pipefail
126-
127-
if [ -z "${NUGET_SOURCE:-}" ]; then
128-
echo "NuGetFeedUrl is not configured; skipping package publication."
129-
exit 0
130-
fi
130+
- pwsh: |
131+
if ([string]::IsNullOrWhiteSpace($env:NUGET_SOURCE))
132+
{
133+
Write-Host "NuGetFeedUrl is not configured; skipping package publication."
134+
exit 0
135+
}
131136
132-
shopt -s nullglob
133-
packages=(
134-
"$(Pipeline.Workspace)/packages/core"/*.nupkg
135-
"$(Pipeline.Workspace)/packages/tool"/*.nupkg
137+
$packageDirectories = @(
138+
"$(Pipeline.Workspace)/packages/core",
139+
"$(Pipeline.Workspace)/packages/tool"
136140
)
137141
138-
if [ ${#packages[@]} -eq 0 ]; then
139-
echo "No packages were downloaded for publication."
140-
exit 1
141-
fi
142-
143-
for package in "${packages[@]}"; do
144-
if [ -n "${NUGET_API_KEY:-}" ]; then
145-
dotnet nuget push "$package" --source "$NUGET_SOURCE" --api-key "$NUGET_API_KEY" --skip-duplicate
146-
else
147-
dotnet nuget push "$package" --source "$NUGET_SOURCE" --api-key AzureArtifacts --skip-duplicate
148-
fi
149-
done
142+
$packages = foreach ($directory in $packageDirectories)
143+
{
144+
if (Test-Path $directory)
145+
{
146+
Get-ChildItem -Path $directory -Filter *.nupkg -File
147+
}
148+
}
149+
150+
if (-not $packages)
151+
{
152+
Write-Error "No packages were downloaded for publication."
153+
exit 1
154+
}
155+
156+
foreach ($package in $packages)
157+
{
158+
if ([string]::IsNullOrWhiteSpace($env:NUGET_API_KEY))
159+
{
160+
dotnet nuget push $package.FullName --source $env:NUGET_SOURCE --api-key AzureArtifacts --skip-duplicate
161+
}
162+
else
163+
{
164+
dotnet nuget push $package.FullName --source $env:NUGET_SOURCE --api-key $env:NUGET_API_KEY --skip-duplicate
165+
}
166+
}
150167
displayName: Publish packages to NuGet feed
151168
env:
152169
NUGET_SOURCE: $(NuGetFeedUrl)

0 commit comments

Comments
 (0)