-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
azure-pipelines.yml
187 lines (163 loc) · 5.44 KB
/
azure-pipelines.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
batch: true
branches:
include:
- main
paths:
exclude:
- docs/*
pr: none
pool:
vmImage: windows-latest
variables:
- group: Github-Packages
- group: 'c3d-devops'
- name: solution
value: 'MSBuild.SDK.SystemWeb.sln'
- name: buildPlatform
value: 'Any CPU'
- name: buildConfiguration
value: 'Release'
- name: buildMachine
value: '$(Agent.MachineName)'
- name: buildUser
value: '$(Build.QueuedBy)'
- name: 'timestamper'
value: 'http://timestamp.comodoca.com'
steps:
- checkout: self
clean: true
submodules: true
persistCredentials: true
- powershell: 'Write-Host ("##vso[task.setvariable variable=MSBuildEmitSolution;]0")'
displayName: 'Ensure MSBuildEmitSolution is not set'
- task: DownloadSecureFile@1
displayName: 'Download secure file SNK'
name: snk
inputs:
secureFile: '61ad38e7-05ff-4421-aea8-e3241b75c7a1'
- task: PowerShell@2
displayName: 'Install Certificate'
inputs:
targetType: 'filePath'
filePath: 'build/ImportCert.ps1'
env:
password: $(pfx-password)
pfx: $(c3d-codesign)
- task: NuGetToolInstaller@0
inputs:
versionSpec: 5.8.1
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'config'
includeNugetOrg: 'true'
externalFeedCredentials: 'github-czemacleod-packages'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
clean: true
msbuildArgs: '/p:PackageOutputPath="$(Build.ArtifactStagingDirectory)" /p:BuildUser="$(buildUser)" /p:BuildMachine="$(buildMachine)" /p:AssemblyOriginatorKeyFile="$(snk.secureFilePath)"'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
- task: PowerShell@2
displayName: 'Detect packages'
inputs:
targetType: inline
script: |
$dir = $env:BUILD_ARTIFACTSTAGINGDIRECTORY + "\*.nupkg"
Write-Host "Package Directory: $dir"
$packages = Get-ChildItem -Path $dir -Recurse
$ids = $packages | Select-Object -ExpandProperty name
Write-Host "Packages: $ids"
Write-Host "Package Count: $($packages.Count)"
Write-Host ("##vso[task.setvariable variable=package_count;]$($packages.Count)")
- task: NuGetCommand@2
condition: and(succeeded(), ne(variables['package_count'],0))
displayName: 'NuGet Sign'
inputs:
command: custom
arguments: 'sign $(Build.ArtifactStagingDirectory)\*.nupkg -Timestamper $(timestamper) -CertificateFingerprint $(app_pfx_thumbprint)'
- task: CopyFiles@2
displayName: Create nuget publish config
inputs:
sourceFolder: $(Build.SourcesDirectory)
contents: 'nuget.publish.config'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PowerShell@2
displayName: Build Nuget Source URL
inputs:
targetType: 'inline'
script: |
$owner = "$env:GITHUB_OWNER"
$source = "https://nuget.pkg.github.com/" + $owner.ToLower() + "/index.json"
Write-Host ("Nuget Source URL = $source")
Write-Host ("##vso[task.setvariable variable=NUGET_SOURCE]$source")
env:
GITHUB_OWNER: $(GITHUB_OWNER)
- script: nuget.exe sources Add -NonInteractive -Name GitHub -Source "%NUGET_SOURCE%" -Username "%GITHUB_USERNAME%" -Password "%GITHUB_TOKEN%" -ConfigFile %NUGET_CONFIG%
displayName: Add github package source
env:
GITHUB_OWNER: $(GITHUB_OWNER)
GITHUB_USERNAME: $(GITHUB_USERNAME)
GITHUB_TOKEN: $(GITHUB_TOKEN)
NUGET_SOURCE: $(NUGET_SOURCE)
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
- script: nuget push -Source GitHub -ConfigFile %NUGET_CONFIG% -SkipDuplicate "%PACKAGES_DIR%\*.nupkg"
displayName: Push Nuget Packages to $(GITHUB_PACKAGES)
env:
PACKAGES_DIR: $(Build.ArtifactStagingDirectory)
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
#- task: NuGetCommand@2
# displayName: Push Nuget Packages to $(GITHUB_PACKAGES)
# inputs:
# command: 'push'
# feedsToUse: 'config'
# publishFeedCredentials: 'github-czemacleod-packages'
# externalFeedCredentials: 'github-czemacleod-packages'
# packagesToPush: $(Build.ArtifactStagingDirectory)\*.nupkg
# verbosityPush: 'Detailed'
# nuGetFeedType: 'external'
- task: NuGetCommand@2
displayName: Push Nuget Packages to nuget.org
inputs:
command: 'push'
feedsToUse: 'config'
includeNugetOrg: 'true'
publishFeedCredentials: 'NuGet.org'
externalFeedCredentials: 'NuGet.org'
packagesToPush: $(Build.ArtifactStagingDirectory)\*.nupkg
verbosityPush: 'Detailed'
nuGetFeedType: 'external'
allowPackageConflicts: true
- powershell: |
Write-Host "Tagging Build: $env:BuildNumber"
$tag = "v" + $env:BuildNumber
git tag $tag
git push origin $tag
displayName: Tag build
env:
BuildNumber: $(Build.BuildNumber)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: GithubRelease@0
displayName: 'Create GitHub Release'
inputs:
gitHubConnection: github-czemacleod
repositoryName: CZEMacLeod/MSBuild.SDK.SystemWeb
assets: $(Build.ArtifactStagingDirectory)/*.nupkg
addChangeLog: true
- task: PowerShell@2
displayName: 'Remove Cert'
inputs:
targetType: filePath
filePath: 'build/RemoveCert.ps1'
arguments: '-thumb $(app_pfx_thumbprint)'
condition: always()