generated from Kentico/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-and-release.yaml
172 lines (142 loc) · 6.09 KB
/
build-and-release.yaml
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
name: '$(Build.DefinitionName) #$(Build.BuildId)'
trigger:
- master
parameters:
- name: AgentPoolName
displayName: Agent pool name
type: string
default: ADO Windows Server 2022
- name: AgentName
displayName: Agent name - single char for any
type: string
default: ' '
resources:
repositories:
- repository: self
type: git
containers:
- container: Windows
image: base/mcr-dotnet-sdk-8.0-servercore-ltsc2022:release
endpoint: xperienceagentshub.azurecr.io
stages:
- stage: Build
jobs:
- job: Build
displayName: Build, Sign, Test & Pack
pool:
name: ${{ parameters.AgentPoolName }}
${{ if ne(length(parameters.AgentName), 1) }}:
demands:
- Agent.Name -equals ${{ parameters.AgentName }}
container: Windows
workspace:
clean: resources
variables:
- group: Code Sign KV Auth
- name: Configuration
value: Release
- name: DotNetSdkVersion
value: 5.0.x
steps:
- task: DotNetCoreCLI@2
displayName: Restore dotnet tools
inputs:
command: custom
custom: tool
arguments: restore
workingDirectory: $(System.DefaultWorkingDirectory)
- task: DotNetCoreCLI@2
displayName: Restore dependencies
inputs:
command: restore
projects: '**/*.csproj'
feedsToUse: select
- pwsh: |
$DirectoryBuildTargetsContent = @"
<Project>
<Target Name="SignAssemblyWithAuthenticodeSignature" AfterTargets="AfterBuild" Condition="'`$(MSBuildProjectFullPath.Contains("node_modules"))' == 'false'">
<PropertyGroup>
<XmlSerializersTargetPath>`$(TargetDir)`$(TargetName).XmlSerializers.dll</XmlSerializersTargetPath>
<RazorViewsTargetPath>`$(TargetDir)`$(TargetName).Views.dll</RazorViewsTargetPath>
</PropertyGroup>
<ItemGroup>
<AssemblyToSign Include="`$(TargetPath)" />
<AssemblyToSign Include="`$(XmlSerializersTargetPath)" Condition="Exists('`$(XmlSerializersTargetPath)')" />
<AssemblyToSign Include="`$(RazorViewsTargetPath)" Condition="Exists('`$(RazorViewsTargetPath)')" />
</ItemGroup>
<Exec Command="dotnet AzureSignTool sign --azure-key-vault-url $(AuthenticodeKeyVaultUrl) --azure-key-vault-tenant-id $(AuthenticodeTenantId) --azure-key-vault-client-id $(AuthenticodeClientId) --azure-key-vault-client-secret $(AuthenticodeClientSecret) --azure-key-vault-certificate $(AuthenticodeCertificateName) --timestamp-rfc3161 http://timestamp.digicert.com --skip-signed %(AssemblyToSign.Identity)" />
</Target>
</Project>
"@
Set-Content -Value $DirectoryBuildTargetsContent -Path "$(System.DefaultWorkingDirectory)/Directory.Build.targets"
displayName: Create Directory.Build.targets to sign DLLs
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: '**/*.csproj'
arguments: --no-restore --configuration ${{ variables.Configuration }}
env:
AuthenticodeClientSecret: $(AuthenticodeClientSecret)
# Roll-forward behavior set for AzureSignTool dotnet tool (see .config\dotnet-tools.json) which requires .Net 6.0 runtime
DOTNET_ROLL_FORWARD: Major
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: '**/*.Tests.csproj'
arguments: --no-build --configuration ${{ variables.Configuration }}
- task: DotNetCoreCLI@2
displayName: Create NuGet package
inputs:
command: pack
packagesToPack: '**/*.csproj'
configuration: ${{ variables.Configuration }}
nobuild: true
versioningScheme: 'off'
- task: PublishPipelineArtifact@1
displayName: Publish NuGet package as artifact
inputs:
targetPath: $(Build.ArtifactStagingDirectory)
artifact: artifact
publishLocation: pipeline
- ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
- stage: PublishNuGetPackages
displayName: Publish NuGet packages
dependsOn: Build
jobs:
- deployment: PublishNuGetPackages
displayName: Publish NuGet packages
pool:
name: ${{ parameters.AgentPoolName }}
${{ if ne(length(parameters.AgentName), 1) }}:
demands:
- Agent.Name -equals ${{ parameters.AgentName }}
container: Windows
workspace:
clean: resources
environment: integrations-release-nuget
strategy:
runOnce:
deploy:
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
displayName: Download NuGetPackages
inputs:
artifact: artifact
path: $(Build.ArtifactStagingDirectory)
- task: NuGetToolInstaller@1
displayName: Install nuget.exe
inputs:
versionSpec: '>=5.6'
checkLatest: true
- task: NuGetAuthenticate@0
displayName: NuGet Authenticate
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: push
packagesToPush: $(Build.ArtifactStagingDirectory)/*.nupkg
nuGetFeedType: external
publishFeedCredentials: nuget.org