forked from landorphan/DotNetCoreBuildTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
267 lines (207 loc) · 10.1 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
jobs:
- job: buildBinaries
displayName: "Build DotNet Core Binaries"
pool:
vmImage: 'ubuntu-latest'
variables:
- group: Landorphan-Build-Secrets
- name: buildConfiguration
value: 'Release'
steps:
- script: |
echo Write your commands here
mkdir "$(Build.BinariesDirectory)/raw-build"
dir "$(Build.BinariesDirectory)/raw-build"
set
echo Use the environment variables input below to pass secret variables to this script
displayName: 'Display Environment Info & Setup'
- script: |
echo Write your commands here
mkdir "$(Build.BinariesDirectory)/d"
echo Use the environment variables input below to pass secret variables to this script
displayName: 'Create Dependency Directory'
- task: DotNetCoreCLI@2
displayName: 'Download AzureSignTool'
inputs:
command: custom
custom: tool
arguments: 'install AzureSignTool --version 2.0.17 --tool-path $(Agent.BuildDirectory)/d'
#Start: This should be in an include
- powershell: |
# Write your powershell commands here.
if (!(Test-Path "$(Agent.BuildDirectory)\d\"))
{
mkdir "$(Agent.BuildDirectory)\d\";
}
Get-Item -Path Env:
# Use the environment variables input below to pass secret variables to this script.
displayName: 'Create Agent.BuildDirectory/d'
#END: This should be in an include
- task: eliostruyf.build-task.custom-build-task.file-creator@2
displayName: 'Create sign.cs File'
inputs:
fileoverwrite: true
filepath: '$(Build.SourcesDirectory)/sign.cs'
filecontent: |
using System.Reflection;
[assembly:AssemblyKeyFileAttribute(@"$(Agent.TempDirectory)/Landorphan-Light.snk")]
- bash: |
# Write your commands here
ls -l
mv Directory.Build.props Local.Build.props
# Use the environment variables input below to pass secret variables to this script
displayName: 'Make Local.Build.Props'
- bash: |
# Write your commands here
VERSION_FILE="$(echo '/$(Build.BinariesDirectory)' | sed 's/\\/\//g' | sed 's/://' | sed -e 's/\(.*\)/\L\1/')/raw-build/version.txt"
echo $VERSION_FILE
find AssemblyVersion.cs -exec sed -i -r "s/\(\"([0-9]+\.[0-9]+)\.[0-9]+\"/(\"\1\."$BUILD_BUILDID"\"/g" {} \;
cat AssemblyVersion.cs | grep -oP '(?<=AssemblyVersion\(\")[0-9]+\.[0-9]+\.[0-9]+' > $VERSION_FILE
cat "$VERSION_FILE"
# Use the environment variables input below to pass secret variables to this script
displayName: 'Update Build Version'
- powershell: |
# Write your powershell commands here.
$Env:BUILD_VERSION = (cat '$(Build.BinariesDirectory)/raw-build/version.txt')
if ($env:BUILD_SOURCEBRANCHNAME -eq 'develop')
{
$Env:BUILD_VERSION = $Env:BUILD_VERSION + "-prerelease";
}
elseif ($env:BUILD_SOURCEBRANCHNAME -eq 'master')
{
}
else
{
$Env:BUILD_VERSION = $Env:BUILD_VERSION + "-develop";
}
echo "$Env:BUILD_VERSION"
Write-Host "##vso[task.setvariable variable=BUILD_VERSION]$($env:BUILD_VERSION)"
Out-File -FilePath '$(Build.BinariesDirectory)/raw-build/version.txt' -InputObject $Env:BUILD_VERSION -Encoding ASCII
cat '$(Build.BinariesDirectory)/raw-build/version.txt'
Get-ChildItem -Recurse *.csproj | % { ((Get-Content -path "$_" -Raw) -replace '\$\(BUILD_VERSION\)',"$Env:BUILD_VERSION") | Set-Content -Path "$_" }
# find . -name '*.csproj' | xargs -I % sed -iE 's/\$(BUILD_VERSION)//g' %
# Use the environment variables input below to pass secret variables to this script.
displayName: 'Add Pre-release qualifer'
- task: eliostruyf.build-task.custom-build-task.file-creator@2
displayName: 'Create Directory.Build.Props File'
inputs:
fileoverwrite: true
filepath: '$(Build.SourcesDirectory)/Directory.Build.props'
filecontent: |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Local.Build.props" />
<ItemGroup>
<Compile Include="$(Build.SourcesDirectory)\sign.cs" />
</ItemGroup>
</Project>
- task: DownloadSecureFile@1
displayName: 'Download Key.Snk'
inputs:
secureFile: 'Landorphan-Light.snk'
- bash: |
ls -l "$(Agent.BuildDirectory)/d"
ls -l "$(Build.BinariesDirectory)/raw-build"
ls -l /home/vsts/work/_temp
cat DotNetCoreBuildTools/DotNetCoreBuildTools.csproj
displayName: 'List Temp Directory Contents'
- script: |
dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- bash: |
ls -l ./DotNetCoreBuildTools/bin/Release
displayName: 'List Build Directory Contents'
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)/DotNetCoreBuildTools/bin/Release/'
contents: '*.nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
displayName: "Copy NuGet Files To Artifact Staging"
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.BinariesDirectory)/raw-build'
contents: 'version.txt'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
displayName: "Copy Version File To Artifact Staging"
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: pre-sign
- job:
displayName: "Sign NuGet"
dependsOn: buildBinaries
pool:
vmImage: 'windows-latest'
variables:
- group: Landorphan-Build-Secrets
- name: buildConfiguration
value: 'Release'
steps:
- task: DownloadPipelineArtifact@2
inputs:
path: '$(System.ArtifactsDirectory)'
artifact: pre-sign
- powershell: |
# Write your powershell commands here.
if (!(Test-Path "$(Agent.BuildDirectory)\d\"))
{
mkdir "$(Agent.BuildDirectory)\d\";
}
Get-Item -Path Env:
# Use the environment variables input below to pass secret variables to this script.
displayName: 'Create Agent.BuildDirectory/d'
- bash: |
# Write your commands here
convert_path() {
echo $(echo "/$1" | sed 's/\\/\//g' | sed 's/://' | sed -e 's/\(.*\)/\L\1/')
}
TOOL_PATH="$(echo $(convert_path '$(Agent.BuildDirectory)/d/NuGetKeyVaultSignTool.zip'))"
echo $TOOL_PATH
curl -o "$TOOL_PATH" "https://lndfbuild.blob.core.windows.net/utils/NuGetKeyVaultSignTool.zip"
ls -l "$(Agent.BuildDirectory)/d"
# Use the environment variables input below to pass secret variables to this script
displayName: 'Download NuGetKeyVaultSignTool.zip'
- powershell: |
# Write your powershell commands here.
Expand-Archive -Path "$(Agent.BuildDirectory)/d/nugetkeyvaultsigntool.zip" -DestinationPath "$(Agent.BuildDirectory)/d/"
# Use the environment variables input below to pass secret variables to this script.
displayName: 'Unzip NuGetKeyVaultSignTool.zip into Agent.BuildDirectory/d'
#END: This should be in an include
- bash: |
ls -l "$(Agent.BuildDirectory)/d"
ls -l "$(System.ArtifactsDirectory)"
displayName: 'List Temp Directory Contents'
- bash: |
echo Write your commands here
ls -l "$(System.ArtifactsDirectory)"
VERSION=$(cat "$(System.ArtifactsDirectory)/version.txt")
echo $VERSION
dotnet "$(Agent.BuildDirectory)/d/NuGetKeyVaultSignTool.dll" sign "$(System.ArtifactsDirectory)/Landorphan.DotNetCoreBuildTools.$VERSION.nupkg" --file-digest sha256 --timestamp-rfc3161 http://timestamp.comodoca.com --timestamp-digest sha256 --azure-key-vault-url "https://landorphan-build.vault.azure.net/" --azure-key-vault-client-id "b32bbbae-55c3-4f5b-bf40-0292d349886f" --azure-key-vault-client-secret "$(LandorphanKeyVaultKey)" --azure-key-vault-certificate "Landorphan-LightWeight-CodeSign"
echo Use the environment variables input below to pass secret variables to this script
displayName: 'Testability: NuGet Code Sign copy'
- task: CopyFiles@2
inputs:
sourceFolder: '$(System.ArtifactsDirectory)'
contents: '*.nupkg'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
displayName: "Copy NuGet Files To Artifact Staging"
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: signed
- task: NuGetCommand@2
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet Public Feed'
# - script: |
# echo Write your commands here
# "$(Agent.BuildDirectory)/d/azuresigntool" sign "$BUILD_SOURCESDIRECTORY/bin/release/DotNetCoreBuildTools/netstandard2.0/DotNetCoreBuildTools.dll" --file-digest sha256 --description-url "https://github.com/landorphan/DotNetCoreBuildTools" --no-page-hashing --timestamp-rfc3161 http://timestamp.comodoca.com --timestamp-digest sha256 --azure-key-vault-url "https://landorphan-build.vault.azure.net/" --azure-key-vault-client-id "b32bbbae-55c3-4f5b-bf40-0292d349886f" --azure-key-vault-client-secret "$(LandorphanKeyVaultKey)" --azure-key-vault-certificate "Landorphan-LightWeight-CodeSign"
# echo Use the environment variables input below to pass secret variables to this script
# displayName: 'Azure Code Sign copy'