-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathazure-pipelines.yml
145 lines (129 loc) · 4.22 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
# Xamarin.Android
# Build a Xamarin.Android project.
# Add steps that test, sign, and distribute an app, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/xamarin
trigger:
- none
# branches:
# include:
# - main
# - releases/*
# paths:
# include:
# - docs
# exclude:
# - azure-pipelines-changelog.yml
# - azure-pipelines.yml
pool:
vmImage: 'windows-latest'
variables:
- group: xamarin-android-aab
- name: buildConfiguration
value: 'Release'
- name: outputDirectory
value: '$(build.binariesDirectory)/$(buildConfiguration)'
- name: BuildID
value: '$(Build.BuildID)'
- name: packageFormat
value: aab
steps:
- checkout: self
submodules: true
# set version variables because the predefined like $(Year:yy) can't be used in tasks
- task: PowerShell@2
name: setvariable
displayName: 'setting variables MajorVersion, MinorVersion, DayOfMonth'
inputs:
targetType: 'inline'
script: |
$year=$(Get-Date -Format 'yy')
Write-Host $year
Write-Host "##vso[task.setvariable variable=MajorVersion]$year"
$month=[datetime]::Today.Month.ToString('0')
Write-Host $month
Write-Host "##vso[task.setvariable variable=MinorVersion]$month"
$day=$(Get-Date -Format 'dd')
Write-Host $day
Write-Host "##vso[task.setvariable variable=DayOfMonth]$day"
$version="$year.$month.$(BuildID).0"
Write-Host $version
Write-Host "##vso[task.setvariable variable=version]$version"
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '**/*.sln'
- task: PowerShell@2
displayName: 'pump AndroidManifest,AssemblyInfo version to $version'
inputs:
workingDirectory: '$(Build.SourcesDirectory)'
targetType: 'inline'
script: |
Write-Host "Set version: $(version)"
$version = "$(version)"
$outputversion = "$(version)"
$build="$(BuildID)"
$packageManifest = "AndroidManifest.xml"
# Apply the version to the assembly property files
$VersionRegex = "\d+\.\d+\.\d+\.\d+"
$assemblyInfoFiles = gci . -recurse -include "*Properties*","My Project" |
?{ $_.PSIsContainer } |
foreach { gci -Path $_.FullName -Recurse -include AssemblyInfo.*, $packageManifest }
if($assemblyInfoFiles)
{
Write-Host "Will apply $AssemblyVersion to $($assemblyInfoFiles.count) Assembly Info Files."
foreach ($file in $assemblyInfoFiles) {
$filecontent = Get-Content($file)
if($file.Name -eq $packageManifest)
{
$xml = [xml](Get-Content($file))
$xml.manifest.versionName = $version
$xml.manifest.versionCode = $build
$xml.Save($file)
}
else
{
attrib $file -r
$filecontent -replace $VersionRegex, $version | Out-File $file utf8
}
Write-Host "$file.FullName - $version version applied"
}
}
else
{
Write-Warning "No Assembly Info Files found."
}
- task: DownloadSecureFile@1
name: signingCert
displayName: 'Download certificate'
inputs:
secureFile: '$(signingCert.secureFilePath)'
- task: XamarinAndroid@1
inputs:
projectFile: '**/*droid*.csproj'
outputDirectory: '$(outputDirectory)'
configuration: '$(buildConfiguration)'
msbuildArguments: '
-t:SignAndroidPackage
-p:AndroidKeyStore=True
-p:AndroidSigningKeyStore=$(signingCert.secureFilePath)
-p:AndroidSigningStorePass=$(keystore.password)
-p:AndroidSigningKeyAlias=$(key.alias)
-p:AndroidSigningKeyPass=$(key.password)
-p:AndroidPackageFormat=$(packageFormat)'
- task: 'CopyFiles@2'
displayName: 'Copy deliverables'
inputs:
SourceFolder: '$(outputDirectory)'
Contents: '*.$(packageFormat)'
TargetFolder: 'drop'
- task: PublishBuildArtifacts@1
displayName: 'Publish release'
inputs:
pathToPublish: 'drop'
artifactName: 'release'
- task: GooglePlayReleaseBundle@3
inputs:
serviceConnection: 'googleplayconsole'
applicationId: 'get.the.solution.AdbApp'
bundleFile: '**/*-Signed.$(packageFormat)'
track: 'production'