-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateApk.ps1
72 lines (56 loc) · 2.47 KB
/
CreateApk.ps1
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
Param(
[Parameter(Mandatory=$true)]
[string]
$newVersionName,
[Parameter(Mandatory=$true)]
[string]
$signingKeyPass
)
Function ChangeVersion {
Param(
[Parameter(Mandatory=$true)]
[string]
$newVersionName
)
# Get current version code and increment
$manifestPath = Resolve-Path '.\AndroidYouTubeDownloader\AndroidManifest.xml'
[xml]$manifest = Get-Content -Path $manifestPath
$newVersionCode = ([int]$manifest.manifest.versionCode + 1).ToString()
$csprojPath = Resolve-Path '.\AndroidYouTubeDownloader\AndroidYouTubeDownloader.csproj'
# Update manifest
(Get-Content $manifestPath) -Replace 'android:versionCode="\d+"', "android:versionCode=`"${newVersionCode}`"" | Set-Content $manifestPath
(Get-Content $manifestPath) -Replace 'android:versionName="[\w\d.-]+"', "android:versionName=`"$newVersionName`"" | Set-Content $manifestPath
# Update project
(Get-Content $csprojPath) -Replace '<ApplicationVersion>\d+</ApplicationVersion>', "<ApplicationVersion>$newVersionCode</ApplicationVersion>" | Set-Content $csprojPath
(Get-Content $csprojPath) -Replace '<ApplicationDisplayVersion>[\w\d.-]+</ApplicationDisplayVersion>', "<ApplicationDisplayVersion>$newVersionName</ApplicationDisplayVersion>" | Set-Content $csprojPath
Write-Host "New versionName: $newVersionName, new versionCode: $newVersionCode"
}
Function Build {
Param(
[Parameter(Mandatory=$true)]
[string]
$signingKeyPass
)
dotnet publish -f:net9.0-android -c:Release /p:AndroidSigningKeyPass=$signingKeyPass /p:AndroidSigningStorePass=$signingKeyPass
}
Function CopyToLocalAppStore {
Param(
[Parameter(Mandatory=$true)]
[string]
$versionName
)
$publishDirectory = '.\AndroidYouTubeDownloader\bin\Release\net9.0-android\publish'
$appStoreDirectory = 'C:\Source\AppStore'
$appName = 'AndroidYouTubeDownloader'
$package = 'com.tmk907.androidyoutubedownloader'
$architectures = @('arm64-v8a','x86_64')
foreach($arch in $architectures){
$apkName = "$package-$arch-Signed.apk"
$publishedApkName = "$appName-v$versionName-$arch.apk"
Copy-Item -Path "$publishDirectory\$apkName" -Destination "$appStoreDirectory\$publishedApkName"
Write-Host "$publishedApkName copied to $appStoreDirectory"
}
}
ChangeVersion -newVersionName $newVersionName
Build -signingKeyPass $signingKeyPass
CopyToLocalAppStore -versionName $newVersionName