-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathpipeline-template-build-test-sign.yml
173 lines (156 loc) · 6.72 KB
/
pipeline-template-build-test-sign.yml
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
# The following variables are used.
# BuildConfiguration - Debug | Release
# NUGET_PACKAGE_VERSION - (Optional) Override the Nuget version tag that normally gets inferred from releasenotes.md file
#
# The following template parameters are consumed:
# SignBuild - Set to 'true' if code signing is required
# PublishRelease - Set to 'true' to publish a new release to Github and Nuget
parameters:
SignBuild: 'false'
PublishRelease: 'false'
steps:
- task: UseDotNet@2
displayName: Use .NET Core SDK
inputs:
packageType: sdk
version: 6.0.x
- powershell: |
$version = & ./Get-Version.ps1
Write-Host "##vso[task.setvariable variable=NUGET_PACKAGE_VERSION]$version"
workingDirectory: $(build.sourcesDirectory)/Scripts
displayName: Infer version from release notes
errorActionPreference: stop
- task: DotNetCoreCLI@2
displayName: dotnet build for testing
inputs:
arguments: '--no-incremental /t:rebuild /p:Configuration="$(BuildConfiguration)"'
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
arguments: --no-build --collect:"Code Coverage" --configuration $(BuildConfiguration) --test-adapter-path $(System.DefaultWorkingDirectory)\FSharpLu.Tests\bin\$(BuildConfiguration)\net60
projects: |-
**\\*test*.fsproj
**\\*test*.csproj
#-------------------------------------------------------------------------------------------------------------------#
# Signed build #
#-------------------------------------------------------------------------------------------------------------------#
- ${{ if eq(parameters.SignBuild, 'true') }}:
- task: DotNetCoreCLI@2
displayName: dotnet build with delaysigning
inputs:
arguments: '--no-incremental /t:rebuild /p:Configuration="$(BuildConfiguration)" /p:DELAYSIGNING=True'
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: ESRP CodeSign .Net assemblies
inputs:
ConnectedServiceName: 'MSR Springfield Code Signing'
FolderPath: '$(System.DefaultWorkingDirectory)'
Pattern: 'microsoft.fsharplu.windows.dll,microsoft.fsharplu.dll,microsoft.fsharplu.json.dll'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-235845-SN",
"operationSetCode": "StrongNameSign",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
},
{
"keyCode": "CP-235845-SN",
"operationSetCode": "StrongNameVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
}
]
#-------------------------------------------------------------------------------------------------------------------#
- task: DotNetCoreCLI@2
displayName: dotnet pack nuget
inputs:
command: pack
searchPatternPack: '**/*.fsproj'
outputDir: '$(Build.ArtifactStagingDirectory)\nuget'
versioningScheme: byEnvVar
versionEnvVar: 'NUGET_PACKAGE_VERSION'
#-------------------------------------------------------------------------------------------------------------------#
# Signed build #
#-------------------------------------------------------------------------------------------------------------------#
- ${{ if eq(parameters.SignBuild, 'true') }}:
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: ESRP CodeSign Nuget Package
inputs:
ConnectedServiceName: 'MSR Springfield Code Signing'
FolderPath: '$(Build.ArtifactStagingDirectory)\nuget'
Pattern: '*.nupkg'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetSign",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
},
{
"keyCode": "CP-401405",
"operationSetCode": "NuGetVerify",
"parameters": [ ],
"toolName": "sign",
"toolVersion": "1.0"
}
]
#-------------------------------------------------------------------------------------------------------------------#
- task: DotNetCoreCLI@2
displayName: dotnet push nuget
inputs:
command: push
searchPatternPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
feedPublish: '6b4e3a7d-b009-4842-b76e-fb9a587cdc50'
enabled: false
- task: PublishSymbols@2
displayName: Publish symbols
inputs:
SearchPattern: '**\bin\**\*.pdb'
SymbolServerType: TeamServices
SymbolsProduct: Microsoft.FSharpLu
SymbolsVersion: '$(NUGET_PACKAGE_VERSION)'
continueOnError: true
- task: CopyFiles@2
displayName: Binplace built assemblies
enabled: false
inputs:
Contents: '**\bin\**'
TargetFolder: '$(Build.ArtifactStagingDirectory)\build'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
#-------------------------------------------------------------------------------------------------------------------#
# Signed build #
#-------------------------------------------------------------------------------------------------------------------#
- ${{ if and(eq(parameters.SignBuild, 'true'), eq(parameters.PublishRelease, 'true')) }}:
- task: GitHubRelease@0
inputs:
gitHubConnection: 'FSharpLu-Github'
repositoryName: '$(Build.Repository.Name)'
action: 'create'
target: '$(Build.SourceVersion)'
tag: 'release-$(NUGET_PACKAGE_VERSION)'
tagSource: 'manual'
title: 'FSharpLu Release $(NUGET_PACKAGE_VERSION)'
releaseNotesSource: 'input'
releaseNotes: 'Signed release $(NUGET_PACKAGE_VERSION)
https://www.nuget.org/packages/Microsoft.FSharpLu/
https://www.nuget.org/packages/Microsoft.FSharpLu.Json/
https://www.nuget.org/packages/Microsoft.FSharpLu.Windows/'
isDraft: true
addChangeLog: true
compareWith: lastRelease
- task: NuGetCommand@2
displayName: Publish release to nuget
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/Microsoft.*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'FSharpLu-nuget'
#-------------------------------------------------------------------------------------------------------------------#