-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
178 lines (152 loc) · 6.26 KB
/
azure-pipelines.yml
File metadata and controls
178 lines (152 loc) · 6.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
trigger:
branches:
include:
- main
tags:
include:
- v*
- V*
pr:
branches:
include:
- "*"
variables:
- group: McpServer
- name: BuildConfiguration
value: Release
- name: SolutionFile
value: BitNet-b1.58-Sharp.slnx
- name: CoreProject
value: src/BitNetSharp.Core/BitNetSharp.Core.csproj
- name: AppProject
value: src/BitNetSharp.App/BitNetSharp.App.csproj
- name: CoreArtifactName
value: BitNetSharp.Core-nuget
- name: ToolArtifactName
value: BitNetSharp.App-dotnet-tool
- name: NuGetFeedUrl
value: "https://nuget.pkg.github.com/sharpninja/index.json"
stages:
- stage: build
displayName: Build, test, and pack
jobs:
- job: build
displayName: Restore, build, test, and pack
pool:
name: Default
timeoutInMinutes: 0
steps:
- checkout: self
fetchDepth: 0
- task: UseDotNet@2
displayName: Setup .NET SDK
inputs:
packageType: sdk
useGlobalJson: true
- task: UseDotNet@2
displayName: Install .NET 9 runtime for multi-target tests
inputs:
packageType: runtime
version: 9.0.x
- script: dotnet tool restore
displayName: Restore local tools
- pwsh: |
$semVer = dotnet tool run dotnet-gitversion /output json /showvariable SemVer /nonormalize
if ([string]::IsNullOrWhiteSpace($semVer))
{
throw "GitVersion did not return a semantic version."
}
Write-Host "Calculated SemVer: $semVer"
Write-Host "##vso[task.setvariable variable=SemVer]$semVer"
Write-Host "##vso[build.updatebuildnumber]$semVer"
displayName: Calculate semantic version
- script: dotnet restore "$(SolutionFile)"
displayName: Restore
- script: dotnet build "$(SolutionFile)" --configuration "$(BuildConfiguration)" --no-restore
displayName: Build
- script: dotnet test "$(SolutionFile)" --configuration "$(BuildConfiguration)" --no-build --no-restore --filter "Category!=SlowLane"
displayName: Test
- pwsh: |
$modelsDirectory = "$(Build.SourcesDirectory)/src/BitNetSharp.Core/Data/Models"
New-Item -ItemType Directory -Force -Path $modelsDirectory | Out-Null
dotnet run --framework net10.0 --project "$(Build.SourcesDirectory)/$(AppProject)" --configuration "$(BuildConfiguration)" --no-build -- export --output="$modelsDirectory/bitnet-b1.58-default.gguf"
displayName: Generate default model weights
- pwsh: |
$outputDirectory = "$(Build.ArtifactStagingDirectory)/packages/core"
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
dotnet pack "$(CoreProject)" --configuration "$(BuildConfiguration)" --no-build --no-restore -p:PackageVersion="$(SemVer)" --output $outputDirectory
displayName: Pack BitNetSharp.Core
- pwsh: |
$outputDirectory = "$(Build.ArtifactStagingDirectory)/packages/tool"
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
dotnet pack "$(AppProject)" --configuration "$(BuildConfiguration)" --no-build --no-restore -p:PackageVersion="$(SemVer)" --output $outputDirectory
displayName: Pack BitNetSharp.App dotnet tool
- task: PublishPipelineArtifact@1
displayName: Publish BitNetSharp.Core package
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)/packages/core"
artifact: "$(CoreArtifactName)"
- task: PublishPipelineArtifact@1
displayName: Publish BitNetSharp.App tool package
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)/packages/tool"
artifact: "$(ToolArtifactName)"
- stage: release
displayName: Publish packages
dependsOn: build
condition: and(succeeded(), or(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'), startsWith(variables['Build.SourceBranch'], 'refs/tags/V')))
jobs:
- job: publish
displayName: Push tagged packages to NuGet feed
pool:
name: Default
timeoutInMinutes: 0
steps:
- checkout: self
- task: DownloadPipelineArtifact@2
displayName: Download BitNetSharp.Core package
inputs:
artifactName: "$(CoreArtifactName)"
targetPath: "$(Pipeline.Workspace)/packages/core"
- task: DownloadPipelineArtifact@2
displayName: Download BitNetSharp.App tool package
inputs:
artifactName: "$(ToolArtifactName)"
targetPath: "$(Pipeline.Workspace)/packages/tool"
- task: UseDotNet@2
displayName: Setup .NET SDK
inputs:
packageType: sdk
useGlobalJson: true
- task: NuGetAuthenticate@1
displayName: Authenticate package publishing
- pwsh: |
if ([string]::IsNullOrWhiteSpace($env:NUGET_SOURCE))
{
Write-Host "NuGetFeedUrl is not configured; skipping package publication."
exit 0
}
$packageDirectories = @(
"$(Pipeline.Workspace)/packages/core",
"$(Pipeline.Workspace)/packages/tool"
)
$packages = foreach ($directory in $packageDirectories)
{
if (Test-Path $directory)
{
Get-ChildItem -Path $directory -Filter *.nupkg -File
}
}
if (-not $packages)
{
Write-Error "No packages were downloaded for publication."
exit 1
}
foreach ($package in $packages)
{
dotnet nuget push $package.FullName --source $env:NUGET_SOURCE --api-key $env:NUGET_API_KEY --skip-duplicate
}
displayName: Publish packages to NuGet feed
env:
NUGET_SOURCE: $(NuGetFeedUrl)
NUGET_API_KEY: $(GH_TOKEN)