-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathazure-pipelines-android.yaml
176 lines (153 loc) · 6.22 KB
/
azure-pipelines-android.yaml
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
pool:
name: Azure Pipelines
vmImage: 'macOS-13'
demands:
- msbuild
trigger:
branches:
include:
- develop
- main
- release/*
- hotfix/*
variables:
branchName: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
steps:
- bash: |
dotnet workload install android
displayName: 'Install Android workload'
- bash: |
dotnet workload install maui-android
displayName: 'Install MAUI Android workload'
- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests'
inputs:
command: 'test'
projects: |
BMM.Tests/BMM.Api.Tests/BMM.Api.Tests.csproj
BMM.Tests/BMM.Core.Test/BMM.Core.Test.csproj
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
displayName: 'Replace tokens in **/GlobalConstants.cs **/TestSecrets.cs'
inputs:
targetFiles: |
**/GlobalConstants.cs
**/TestSecrets.cs
actionOnMissing: fail
- bash: |
URL="https://bmm-api.brunstad.org/AppVersion/AndroidVersionCode"
VERSIONCODE=$(curl -k --user $(bmmApiCredentials) $URL)
echo "Receive version: $((VERSIONCODE))"
echo "##vso[task.setvariable variable=VersionCode]$((VERSIONCODE))"
displayName: 'Get VersionCode'
- bash: |
let VERSIONCODE=++VERSIONCODE
echo "New version set to: $((VERSIONCODE))"
echo "##vso[task.setvariable variable=VersionCode]$((VERSIONCODE))"
displayName: 'Increment VersionCode'
- bash: |
url="https://bmm-api.brunstad.org/AppVersion/AndroidVersionInfo"
versionInfo=$(curl -k --user $(bmmApiCredentials) $url)
echo "Receive version info: $versionInfo"
echo "##vso[task.setvariable variable=VersionInfo]$versionInfo"
displayName: 'Get version info'
- task: Bash@3
inputs:
filePath: 'version-info.sh'
displayName: 'Construct new version number'
## We don't update later because that would result in the same version number for parallel builds.
## skipping versions in case of build errors is more acceptable than not being able to run builds in parallel.
- task: CdiscountAlm.rest-call-build-task.custom-build-task.restCallBuildTask@0
displayName: 'Rest call PUT AppVersion/AndroidVersionCode'
inputs:
webserviceEndpoint: 'BMM Api (Basic Auth)'
relativeUrl: AppVersion/AndroidVersionCode
httpVerb: PUT
body: '$(VersionCode)'
headers: |
{
"Content-Length": "6",
"Authorization": "$(bmmApiBasicAuth)"
}
- task: CdiscountAlm.rest-call-build-task.custom-build-task.restCallBuildTask@0
displayName: 'Rest call PUT AppVersion/AndroidVersionInfo'
inputs:
webserviceEndpoint: 'BMM Api (Basic Auth)'
relativeUrl: AppVersion/AndroidVersionInfo
httpVerb: PUT
body: '$(VersionInfo_String)'
headers: |
{
"Content-Length": "$(VersionInfo_Length)",
"Authorization": "$(bmmApiBasicAuth)"
}
- bash: |
pattern="DEV"
replacement=$(VersionNumber)
echo "new version number is $replacement"
sed -i.bak s/$pattern/$replacement/ GlobalConstants.cs
rm -f GlobalConstants.cs.bak
workingDirectory: BMM.Core/Helpers
displayName: 'Update AppVersion in GlobalConstants'
- task: vs-publisher-473885.motz-mobile-buildtasks.android-manifest-version.android-manifest-version@0
displayName: 'Set Version Code in AndroidManifest.xml'
inputs:
sourcePath: BMM.UI.Android/AndroidManifest.xml
versionCode: '$(VersionCode)'
versionName: '$(VersionNumber)'
- task: DeleteFiles@1
displayName: 'Delete files from '
inputs:
Contents: |
**/bin
**/obj
- task: DownloadSecureFile@1
name: keystore
displayName: 'Download keystore'
inputs:
secureFile: 'e86cdf1c-08a3-4012-a9c6-216c01d3d81f'
# Previously we use to add AndroidNdkDirectory as msbuildArguments to XamarinAndroid@1 tasks to have correct handling of AOT when building
# Since Microsoft published Xamarin Android 13.1.0.1 AndroidNdkDirectory parameter cannot be used,
# otherwise the build is generated with an error and it crashes on start.
# If you want to build and archive .aab locally, you also need to remove Android NDK path from IDE settings:
# For JetBranis Rider: Preferences -> Build, Execution, Deployment -> Android -> Android NDK Location
# For Visual Studio for Mac: Preferences -> Build and Debug -> SDK Locations -> Android -> Locations -> Android NDK Location
# If you want to read more, please read https://github.com/xamarin/xamarin-android/issues/7588
- task: DotNetCoreCLI@2
displayName: 'Build .NET for Android solution'
inputs:
command: 'build'
projects: 'BMM.UI.Android/BMM.UI.Droid.csproj'
arguments: '-c Release -o "$(Build.BinariesDirectory)/bin/Release/" /p:SolutionDir="$(Build.SourcesDirectory)" -p:AndroidPackageFormat=aab -t:SignAndroidPackage -p:AndroidKeyStore=True -p:AndroidSigningKeyStore=$(keystore.secureFilePath) -p:AndroidSigningStorePass=$(KeystorePassword) -p:AndroidSigningKeyAlias=$(KeystoreAlias) -p:AndroidSigningKeyPass=$(KeystorePassword)'
- task: AndroidSigning@3
displayName: 'Signing and aligning APK file(s) $(Build.BinariesDirectory)/bin/Release/*.apk'
inputs:
apkFiles: '$(Build.BinariesDirectory)/bin/Release/*.apk'
apksignerKeystoreFile: 'keystore.ks'
apksignerKeystorePassword: '$(KeystoreSigningPassword)'
apksignerKeystoreAlias: 'bmm-brunstad'
apksignerKeyPassword: '$(KeystoreSigningPassword)'
- task: CopyFiles@1
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(Build.BinariesDirectory)/bin/Release'
Contents: |
*.apk
*aab
TargetFolder: '$(build.artifactstagingdirectory)'
CleanTargetFolder: true
flattenFolders: true
- task: CopyFiles@2
displayName: 'Copy Files Release notes'
inputs:
SourceFolder: 'release-notes'
Contents: |
$(ReleaseNotesName)
test.md
generic.md
TargetFolder: '$(build.artifactstagingdirectory)'
flattenFolders: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: BMM.Droid