-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
395 lines (357 loc) · 13.7 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
trigger:
- main
parameters:
- name: PublishStore
displayName: Publicar nas lojas
type: boolean
default: true
- name: dotnetVersion
displayName: Versão do .Net
type: string
default: 8.0.402
name: $(Major).$(Minor).$(Rev).$(Build.BuildId)
stages:
- stage: build_android_ios
displayName: "Build Android e iOS"
jobs:
- job: Job_Android
displayName: Build Android
pool:
vmimage: 'windows-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: ${{ parameters.dotnetVersion }}
- task: DownloadSecureFile@1
name: keystore
displayName: Download keystore
inputs:
secureFile: '$(keystore-filename)'
- script: |
echo Downloaded $(keystore.secureFilePath)
echo Working Directory $(Build.Repository.LocalPath)\Maui.AzurePipelines\$(keystore-filename)
mv $(keystore.secureFilePath) $(Build.Repository.LocalPath)\Maui.AzurePipelines
displayName: Movendo Keystore para diretorio de trabalho
- task: Bash@3
displayName: Instalando MAUI
inputs:
targetType: 'inline'
script: |
dotnet nuget locals all --clear
cd "Maui.AzurePipelines/"
dotnet workload restore
- task: JavaToolInstaller@0
displayName: Instalando JDK
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: CmdLine@2
displayName: 'Compilando Android App'
inputs:
script: |
cd "Maui.AzurePipelines/"
dotnet publish Maui.AzurePipelines.csproj -f net8.0-android -c Release /p:ApplicationDisplayVersion=$(Major).$(Minor).$(Rev) /p:ApplicationVersion=$(Build.BuildId) /p:AndroidSigningKeyPass=$(keystore-password) /p:AndroidSigningStorePass=$(keystore-password) /p:AndroidSigningKeyAlias=$(keystore-alias)
- task: CopyFiles@2
displayName: Copiando para o diretorio de artifacts
inputs:
Contents: |
**/*.aab
**/*.apk
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
- task: PublishBuildArtifacts@1
displayName: Liberando nos artifacts
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop_android'
publishLocation: 'Container'
- task: ado-discord-webhook@2
displayName: 'Notificação no discord para falha de build'
condition: failed()
continueOnError: true
inputs:
webhookId: '$(discord_webhookId)'
webhookKey: '$(discord_webhookKey)'
content: '<@&$(discord_mentionRoleId)>'
embeds: |
[
{
"type": "rich",
"title": "$(Build.DefinitionName) ($(Build.BuildNumber))",
"description": "Build android failed!",
"color": 0xff0000,
"fields": [
{
"name": "Build.RequestedFor",
"value": "$(Build.RequestedFor)",
"inline": true
},
{
"name": "Build.Reason",
"value": "$(Build.Reason)",
"inline": true
}
],
"url": "$(System.CollectionUri)/$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=logs"
}
]
- job: Job_iOS
displayName: Build iOS
dependsOn: []
pool:
#vmimage: 'macOS-latest'
vmImage: macOS-14
demands:
- MSBuild
steps:
- task: Bash@3
displayName: Select XCode 16
inputs:
targetType: 'inline'
script: |
sudo xcode-select -switch /Applications/Xcode_16.app/Contents/Developer
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: ${{ parameters.dotnetVersion }}
- task: InstallAppleCertificate@2
inputs:
certSecureFile: 'Certificados.p12'
certPwd: $(apple_cert_pass)
keychain: 'temp'
- task: InstallAppleProvisioningProfile@1
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: 'Apple_Distribution_Devops_Approval.mobileprovision'
- task: Bash@3
displayName: Install MAUI
inputs:
targetType: 'inline'
script: |
dotnet nuget locals all --clear
cd "Maui.AzurePipelines/"
dotnet workload restore
- task: Bash@3
displayName: Build IOS App
inputs:
targetType: 'inline'
script: |
cd "Maui.AzurePipelines/"
dotnet publish Maui.AzurePipelines.csproj -f net8.0-ios -c Release /p:ApplicationDisplayVersion=$(Major).$(Minor).$(Rev) /p:ApplicationVersion=$(Build.BuildId)
- task: CopyFiles@2
inputs:
Contents: |
**/*.app
**/*.ipa
TargetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop_ios'
publishLocation: 'Container'
- task: ado-discord-webhook@2
displayName: 'Notificação no discord para falha de build'
condition: failed()
continueOnError: true
inputs:
webhookId: '$(discord_webhookId)'
webhookKey: '$(discord_webhookKey)'
content: '<@&$(discord_mentionRoleId)>'
embeds: |
[
{
"type": "rich",
"title": "$(Build.DefinitionName) ($(Build.BuildNumber))",
"description": "Build ios failed!",
"color": 0xff0000,
"fields": [
{
"name": "Build.RequestedFor",
"value": "$(Build.RequestedFor)",
"inline": true
},
{
"name": "Build.Reason",
"value": "$(Build.Reason)",
"inline": true
}
],
"url": "$(System.CollectionUri)/$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=logs"
}
]
- stage: unit_test
displayName: "Testes de unidade"
dependsOn: []
jobs:
- job: tags
displayName: Tag build
pool:
vmimage: 'windows-latest'
steps:
- checkout: none
- task: Bash@3
displayName: Preparing tags
inputs:
targetType: 'inline'
script: |
Repo=$(echo 'repo-$(Build.Repository.Name)' | tr '[:upper:]' '[:lower:]' | sed -r 's/[ :_.]+/-/g')
echo "##vso[task.setvariable variable=repo]${Repo}"
Pipe=$(echo 'pipe-$(Build.DefinitionName)' | tr '[:upper:]' '[:lower:]' | sed -r 's/[ :_.]+/-/g')
echo "##vso[task.setvariable variable=pipe]${Pipe}"
echo "##vso[build.addbuildtag]${Pipe}"
echo "##vso[build.addbuildtag]${Repo}"
- task: ado-discord-webhook@2
displayName: 'Notificação no discord para falha de build'
condition: failed()
continueOnError: true
inputs:
webhookId: '$(discord_webhookId)'
webhookKey: '$(discord_webhookKey)'
content: '<@&$(discord_mentionRoleId)>'
embeds: |
[
{
"type": "rich",
"title": "$(Build.DefinitionName) ($(Build.BuildNumber))",
"description": "Unit tests failed!",
"color": 0xff0000,
"fields": [
{
"name": "Build.RequestedFor",
"value": "$(Build.RequestedFor)",
"inline": true
},
{
"name": "Build.Reason",
"value": "$(Build.Reason)",
"inline": true
}
],
"url": "$(System.CollectionUri)/$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=logs"
}
]
- ${{ if contains(parameters.PublishStore, 'true') }}:
- stage: deployStage
condition: not(eq(variables['Build.Reason'], 'PullRequest'))
dependsOn:
- build_android_ios
- unit_test
displayName: Deploy Stage
jobs:
- deployment: ios
dependsOn: []
environment: AzureDevops Mobile - Staging
displayName: "Publish IOS - TestFlight"
pool:
vmImage: "macos-latest"
strategy:
runOnce:
deploy:
steps:
- checkout: none
- task: DownloadBuildArtifacts@1
displayName: "Download IPA"
inputs:
buildType: "current"
downloadType: "single"
artifactName: "drop_ios"
downloadPath: "$(System.ArtifactsDirectory)"
- task: AppStoreRelease@1
displayName: "Publish to the App Store TestFlight track"
inputs:
serviceEndpoint: 'FiveHighAppleStore'
releaseTrack: 'TestFlight'
appIdentifier: 'com.maui.azurepipeline.approval'
appType: 'iOS'
ipaPath: '$(System.ArtifactsDirectory)/**/*.ipa'
shouldSkipWaitingForProcessing: true
shouldSkipSubmission: true
- task: ado-discord-webhook@2
displayName: 'Notificação no discord para deploy com sucesso'
condition: succeeded()
continueOnError: true
inputs:
content: '<@&$(discord_mentionRoleId)>'
webhookId: '$(discord_webhookId)'
webhookKey: '$(discord_webhookKey)'
embeds: |
[
{
"type": "rich",
"title": "$(Build.DefinitionName) ($(Build.BuildNumber))",
"description": "Versão $(Major).$(Minor).$(Rev).$(Build.BuildId) IOS disponível no TestFlight!",
"color": 0x008000,
"fields": [
{
"name": "Build.RequestedFor",
"value": "$(Build.RequestedFor)",
"inline": true
},
{
"name": "Build.Reason",
"value": "$(Build.Reason)",
"inline": true
}
],
"url": "$(System.CollectionUri)/$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=logs"
}
]
- task: ado-discord-webhook@2
displayName: 'Notificação no discord para falha de deploy'
condition: failed()
continueOnError: true
inputs:
webhookId: '$(discord_webhookId)'
webhookKey: '$(discord_webhookKey)'
content: '<@&$(discord_mentionRoleId)>'
embeds: |
[
{
"type": "rich",
"title": "$(Build.DefinitionName) ($(Build.BuildNumber))",
"description": "Deploy IOS failed!",
"color": 0xff0000,
"fields": [
{
"name": "Build.RequestedFor",
"value": "$(Build.RequestedFor)",
"inline": true
},
{
"name": "Build.Reason",
"value": "$(Build.Reason)",
"inline": true
}
],
"url": "$(System.CollectionUri)/$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=logs"
}
]
- deployment: android
dependsOn: []
environment: AzureDevops Mobile - Staging
displayName: "Publish Android - teste interno"
pool:
vmimage: 'windows-latest'
strategy:
runOnce:
deploy:
steps:
- checkout: none
- task: DownloadBuildArtifacts@1
displayName: "Download "
inputs:
buildType: "current"
downloadType: "single"
artifactName: "drop_android"
downloadPath: "$(System.ArtifactsDirectory)"
- task: GooglePlayRelease@4
displayName: Publicando no teste interno
inputs:
serviceConnection: 'FiveHighGooglePlay'
applicationId: 'com.maui.azurepipeline.approval'
action: 'SingleBundle'
bundleFile: '$(System.ArtifactsDirectory)/**/*.aab'
track: 'internal'