-
Notifications
You must be signed in to change notification settings - Fork 10
/
azure-pipelines.yml
219 lines (194 loc) · 8.46 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
# Build all three versions of ALOT Installer
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
branches:
include:
- ALOT-v4
paths:
include:
- '*'
exclude:
- manifest.xml
- manifest-beta.xml
pool:
vmImage: 'windows-latest'
variables:
solution: '*.sln'
buildPlatform: 'x64'
steps:
- checkout: self
submodules: true
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '3.x'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '5.x'
includePreviewVersions: true
# Change artifact name when the version major/minor changes
- task: PowerShell@2
displayName: 'Setup public variables'
inputs:
targetType: 'inline'
script: |
# Set version of application
$xml = [xml](Get-Content .\SharedAssemblyInfo.proj)
$verstr= $xml.Project.PropertyGroup.Version
$ver = New-Object System.Version($verstr)
$ver = New-Object System.Version($ver.Major, $ver.Minor, $ver.Build, [int]$(Build.BuildId))
$xml.Project.PropertyGroup.Version = $ver.ToString()
$xml.Project.PropertyGroup.AssemblyVersion = $ver.ToString()
$xml.Project.PropertyGroup.FileVersion = $ver.ToString()
$xml.Project.PropertyGroup.Copyright = "2017-$(Get-Date -Format yyyy) ME3Tweaks"
$xml.Save("SharedAssemblyInfo.proj")
Write-Host "Version: $($ver)"
echo "##vso[task.setvariable variable=VER]$($ver)"
# Date--------------------------------------------
$date=$(Get-Date -Format s);
Write-Host "##vso[task.setvariable variable=time]$date"
# Commit Message (Multiliner)-----------------------
$commitMessageFull = git log -1 --pretty=%B
$numlines = $($commitMessageFull | measure).Count
if ($numlines > 0) {
$commitMessageFull=[system.String]::Join(" ", $commitMessageFull)
}
Write-Host "##vso[task.setvariable variable=commitMessageFull]$commitMessageFull"
# Author-------------------------------------------
$author = git log -1 --pretty=format:'%an'
Write-Host "##vso[task.setvariable variable=author]$author"
- task: PowerShell@2
displayName: 'Setup private variables'
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'merge'))
inputs:
targetType: 'inline'
script: |
# API Keys--------------------------
$apikeysprivatefilewpf = "namespace ALOTInstallerWPF.Telemetry`n{`n public static partial class APIKeys`n {`n public static string Private_AppCenter {get;} = `"$(AppCenterKeyAlpha)`";`n }`n}"
Set-Content -Path "$(Build.Repository.LocalPath)\ALOTInstallerWPF\Telemetry\APIKeysPrivate.cs" -Value $apikeysprivatefilewpf
$apikeysprivatefileconsole = "namespace ALOTInstallerConsole.Telemetry`n{`n public static partial class APIKeys`n {`n public static string Private_AppCenter {get;} = `"$(AppCenterKeyAlpha)`";`n }`n}"
Set-Content -Path "$(Build.Repository.LocalPath)\ALOTInstallerConsole\Telemetry\APIKeysPrivate.cs" -Value $apikeysprivatefileconsole
- task: NuGetToolInstaller@1
- task: DotNetCoreCLI@2
displayName: 'Build ALOTInstallerWPF'
inputs:
command: 'publish'
publishWebProjects: false
projects: 'ALOTInstallerWPF/ALOTInstallerWPF.csproj'
arguments: '-c WPFRelease --output "Output/Windows" --runtime win-x64 /p:PublishSingleFile=true /p:PublishReadyToRun=true'
zipAfterPublish: false
# A second build is required cause of some "fun" things in Mahapp's xamlcombiner
# The first build will NOT work for AI WPF
- task: DotNetCoreCLI@2
displayName: 'Build ALOTInstallerWPF (Pass 2)'
inputs:
command: 'publish'
publishWebProjects: false
projects: 'ALOTInstallerWPF/ALOTInstallerWPF.csproj'
arguments: '-c WPFRelease --output "Output/Windows" --runtime win-x64 /p:PublishSingleFile=true /p:PublishReadyToRun=true'
zipAfterPublish: false
- task: PowerShell@2
displayName: 'Rename ALOTInstallerWPF to ALOTInstaller'
inputs:
targetType: 'inline'
script: |
# Change name since .NET Core SDK still has not been fixed to support easily changing targetname via csproj
Write-Host "$(Build.SourcesDirectory)/Output/Windows/ALOTInstallerWPF/ALOTInstallerWPF.exe" "-NewName" "$(Build.SourcesDirectory)/Output/Windows/ALOTInstallerWPF/ALOTInstaller.exe"
Rename-Item "$(Build.SourcesDirectory)/Output/Windows/ALOTInstallerWPF/ALOTInstallerWPF.exe" -NewName "$(Build.SourcesDirectory)/Output/Windows/ALOTInstallerWPF/ALOTInstaller.exe"
- task: DotNetCoreCLI@2
displayName: 'Build ALOTInstallerConsole (Linux)'
inputs:
command: 'publish'
publishWebProjects: false
projects: 'ALOTInstallerConsole/ALOTInstallerConsole.csproj'
arguments: '-c LinuxRelease --output "Output/Linux" --runtime linux-x64 /p:PublishTrimmed=true /p:PublishSingleFile=true'
zipAfterPublish: false
- task: DotNetCoreCLI@2
displayName: 'Build ALOTInstallerConsole (Windows)'
inputs:
command: 'publish'
publishWebProjects: false
projects: 'ALOTInstallerConsole/ALOTInstallerConsole.csproj'
arguments: '-c WinRelease --output "Output/Windows" --runtime win-x64 /p:PublishTrimmed=true /p:PublishSingleFile=true'
zipAfterPublish: false
#WinUI
- task: PublishPipelineArtifact@1
displayName: 'Publish ALOT Installer WPF'
inputs:
targetPath: 'Output/Windows/ALOTInstallerWPF/ALOTInstaller.exe'
artifact: 'ALOT Installer WPF (Windows) $(VER)'
publishLocation: 'pipeline'
#WinConsole
- task: PublishPipelineArtifact@1
displayName: 'Publish ALOTInstallerConsole (Linux)'
inputs:
targetPath: 'Output/Windows/ALOTInstallerConsole/ALOTInstallerConsole.exe'
artifact: 'ALOT Installer Console (Windows) $(VER)'
publishLocation: 'pipeline'
#Linux
- task: PublishPipelineArtifact@1
displayName: 'Publish ALOTInstallerConsole (Windows)'
inputs:
targetPath: 'Output/Linux/ALOTInstallerConsole/ALOTInstallerConsole'
artifact: 'ALOT Installer Console (Linux) $(VER)'
publishLocation: 'pipeline'
# Disabled for now because we don't use this in M3 anymore. Was only for testing V4 at start.
# - task: ArchiveFiles@2
# condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'merge'))
# displayName: 'Compress WPF for Bridge transfer'
# inputs:
# rootFolderOrFile: 'Output/Windows/ALOTInstallerWPF/ALOTInstaller.exe'
# includeRootFolder: false
# archiveType: '7z'
# sevenZipCompression: 'ultra'
# archiveFile: '$(Build.ArtifactStagingDirectory)/ALOT Installer WPF (Windows) $(VER).7z'
# replaceExistingArchive: true
# - task: PowerShell@2
# condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'merge'))
# displayName: 'Transfer WPF to ME3Tweaks via Bridge'
# env:
# BRIDGEENDPOINT: $(ME3TweaksALOTBridgeEndpoint)
# BRIDGEUSERNAME: $(ME3TweaksBridgeUsername)
# BRIDGEPW: $(ME3TweaksBridgePW)
# inputs:
# filePath: 'Azure/ME3TweaksBridge.ps1'
# arguments: "-Endpoint $env:BRIDGEENDPOINT -Username $env:BRIDGEUSERNAME -Password $env:BRIDGEPW -Version $(VER) -AppName ALOTInstallerWPF -InputFile \"$(Build.ArtifactStagingDirectory)/ALOT Installer WPF (Windows) $(VER).7z\""
# errorActionPreference: 'continue'
- task: ado-discord-webhook@1
displayName: 'ALOT Discord notification'
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'merge'))
inputs:
channelId: '$(discord_channel_id)'
webhookKey: '$(discord_webhook_key)'
name: 'Azure DevOps CI'
avatar: 'https://i.imgur.com/mUtPj2S.png'
messageType: 'embeds'
embeds: |
[{
"title": "ALOT Installer Build Complete",
"description": "A new set of nightly builds of ALOT Installer have been built. These builds are built from the very latest code and may be unstable, use at your own risk. Click this link and download the version you wish to use.\n\nALOTInstallerWPF: Main installer app\nALOTInstallerConsole: Terminal-based installer",
"thumbnail": {
"url": "https://i.imgur.com/mUtPj2S.png",
"height": 64,
"width": 64
},
"fields": [{
"name": "Triggering commit",
"value": "$(commitMessageFull)"
},
{
"name": "Author",
"value": "$(author)"
},
{
"name": "Branch",
"value": "$(Build.SourceBranchName)"
},
{
"name": "Version",
"value": "$(VER)"
}],
"url": "https://dev.azure.com/ME3Tweaks/ALOT%20Installer/_build/results?buildId=$(Build.BuildId)&view=artifacts",
"timestamp": "$(time)"
}]