-
Notifications
You must be signed in to change notification settings - Fork 136
/
azure-pipelines.yml
163 lines (143 loc) · 5.56 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
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: 'WzComparerR2.sln'
buildPlatform_anycpu: 'Any CPU'
buildPlatform_x86: 'x86'
buildConfiguration: 'Release'
outputDir_netfx_anycpu: 'WzComparerR2/bin/release/net462'
outputDir_netfx_x86: 'WzComparerR2/bin/x86/release/net462'
outputDir_net6_anycpu: 'WzComparerR2/bin/release/net6.0-windows'
outputFileName_netfx: 'WcR2_With_Plugins_$(Build.BuildNumber)'
outputFileName_net6: 'WcR2_With_Plugins_net6_$(Build.BuildNumber)'
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
accountName: 'wcr2publish'
containerName: 'ci-build'
steps:
- checkout: self
submodules: true
fetchDepth: 1
path: s/WzComparerR2
persistCredentials: true
- task: CmdLine@2
displayName: Generate version file
inputs:
script: |
echo [assembly: global::System.Reflection.AssemblyInformationalVersion("2.2.$(Build.BuildNumber)")] >> Build\CommonAssemblyInfo.cs
- task: NuGetCommand@2
displayName: Restore NuGet packages
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
- task: VSBuild@1
displayName: Build anycpu
inputs:
solution: '$(solution)'
platform: '$(buildPlatform_anycpu)'
configuration: '$(buildConfiguration)'
- task: VSBuild@1
displayName: Build x86
inputs:
solution: '$(solution)'
platform: '$(buildPlatform_x86)'
configuration: '$(buildConfiguration)'
- task: CmdLine@2
displayName: Prepare output files
inputs:
script: |
move "$(outputDir_netfx_anycpu)\*.dll" "$(outputDir_netfx_anycpu)\Lib"
del "$(outputDir_netfx_anycpu)\*.pdb"
rename "$(outputDir_netfx_anycpu)\WzComparerR2.exe" "WzComparerR2.anycpu.exe"
rename "$(outputDir_netfx_anycpu)\WzComparerR2.exe.config" "WzComparerR2.anycpu.exe.config"
copy /y "$(outputDir_netfx_x86)\WzComparerR2.exe" "$(outputDir_netfx_anycpu)"
copy /y "$(outputDir_netfx_x86)\WzComparerR2.exe.config" "$(outputDir_netfx_anycpu)"
move "$(outputDir_net6_anycpu)\*.dll" "$(outputDir_net6_anycpu)\Lib"
del "$(outputDir_net6_anycpu)\*.pdb"
move "$(outputDir_net6_anycpu)\Lib\WzComparerR2.dll" "$(outputDir_net6_anycpu)"
failOnStderr: true
- task: ArchiveFiles@2
displayName: Compress netfx release
inputs:
rootFolderOrFile: '$(outputDir_netfx_anycpu)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(outputFileName_netfx).zip'
replaceExistingArchive: true
- task: ArchiveFiles@2
displayName: Compress net6 release
inputs:
rootFolderOrFile: '$(outputDir_net6_anycpu)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(outputFileName_net6).zip'
replaceExistingArchive: true
- task: AzureCLI@2
displayName: Upload to blob
inputs:
azureSubscription: 'Visual Studio Enterprise(66312bd9-1264-4b34-872d-2e557fc1bc0d)'
scriptType: 'ps'
scriptLocation: 'inlineScript'
inlineScript: |
$files = @(
@{
"srcFile"="$(outputFileName_netfx).zip"
"outputVariableName"="sasurl_netfx"
}
@{
"srcFile"="$(outputFileName_net6).zip"
"outputVariableName"="sasurl_net6"
}
)
$expireDate = (Get-Date).ToUniversalTime().AddYears(1).ToString("yyyy-MM-dd'T'HH:mm:ss'Z'")
$keys = ConvertFrom-Json ((az storage account keys list --account-name $(accountName)) -join "")
$accountKey = $keys[0].value
foreach ($f in $files) {
$srcFile = "$(Build.ArtifactStagingDirectory)/{0}" -f $f.srcFile
$dstFile = $f.srcFile
$varName = $f.outputVariableName
Write-Host "Uploading ${srcFile} ..."
az storage blob upload --auth-mode login --account-name $(accountName) --container-name $(containerName) --name $dstFile --file $srcFile
Write-Host "Generate sas url..."
$url = ConvertFrom-Json (az storage blob url --auth-mode login --account-name $(accountName) --container-name $(containerName) --name $dstFile)
$sas = ConvertFrom-Json (az storage blob generate-sas --account-name $(accountName) --account-key "$accountKey" --container-name $(containerName) --name $dstFile --expiry "$expireDate" --permissions "r")
$sasurl = "${url}?${sas}"
Write-Host "${sasurl}"
Write-Host "##vso[task.setvariable variable=${varName}]${sasurl}"
}
- task: GitHubRelease@1
condition: and(succeeded(), eq(variables.isMain, true))
continueOnError: true
displayName: Delete last build
inputs:
gitHubConnection: 'Kagamia'
repositoryName: '$(Build.Repository.Name)'
action: 'delete'
tag: 'ci-build'
- task: CmdLine@2
condition: and(succeeded(), eq(variables.isMain, true))
continueOnError: true
displayName: Delete ci-build tag
inputs:
script: 'git push --delete origin ci-build'
failOnStderr: false
- task: GitHubRelease@1
condition: and(succeeded(), eq(variables.isMain, true))
inputs:
gitHubConnection: 'Kagamia'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
target: '$(Build.SourceVersion)'
tag: 'ci-build'
title: 'CI-Build-$(Build.BuildNumber)'
releaseNotesSource: 'inline'
releaseNotesInline: |
Automation build from azure-pipeline.
Mirror: [[WcR2.netfx.zip]($(sasurl_netfx))] | [[WcR2.net6.zip]($(sasurl_net6))]
isPreRelease: false
addChangeLog: false