1+ Param (
2+ [Parameter (Mandatory = $true )]
3+ [string ]
4+ $newVersionName ,
5+ [Parameter (Mandatory = $true )]
6+ [string ]
7+ $signingKeyPass
8+ )
9+
10+ Function ChangeVersion {
11+ Param (
12+ [Parameter (Mandatory = $true )]
13+ [string ]
14+ $newVersionName
15+ )
16+
17+ # Get current version code and increment
18+ $manifestPath = Resolve-Path ' .\AndroidYouTubeDownloader\AndroidManifest.xml'
19+ [xml ]$manifest = Get-Content - Path $manifestPath
20+ $newVersionCode = ([int ]$manifest.manifest.versionCode + 1 ).ToString()
21+
22+ $csprojPath = Resolve-Path ' .\AndroidYouTubeDownloader\AndroidYouTubeDownloader.csproj'
23+
24+ # Update manifest
25+ (Get-Content $manifestPath ) -Replace ' android:versionCode="\d+"' , " android:versionCode=`" ${newVersionCode} `" " | Set-Content $manifestPath
26+ (Get-Content $manifestPath ) -Replace ' android:versionName="[\w\d.-]+"' , " android:versionName=`" $newVersionName `" " | Set-Content $manifestPath
27+
28+ # Update project
29+ (Get-Content $csprojPath ) -Replace ' <ApplicationVersion>\d+</ApplicationVersion>' , " <ApplicationVersion>$newVersionCode </ApplicationVersion>" | Set-Content $csprojPath
30+ (Get-Content $csprojPath ) -Replace ' <ApplicationDisplayVersion>[\w\d.-]+</ApplicationDisplayVersion>' , " <ApplicationDisplayVersion>$newVersionName </ApplicationDisplayVersion>" | Set-Content $csprojPath
31+
32+ Write-Host " New versionName: $newVersionName , new versionCode: $newVersionCode "
33+ }
34+
35+ Function Build {
36+ Param (
37+ [Parameter (Mandatory = $true )]
38+ [string ]
39+ $signingKeyPass
40+ )
41+
42+ dotnet publish -f :net6.0 - android - c:Release / p:AndroidSigningKeyPass= $signingKeyPass / p:AndroidSigningStorePass= $signingKeyPass
43+ }
44+
45+ Function CopyToLocalAppStore {
46+ Param (
47+ [Parameter (Mandatory = $true )]
48+ [string ]
49+ $versionName
50+ )
51+
52+ $publishDirectory = ' .\AndroidYouTubeDownloader\bin\Release\net6.0-android\publish'
53+ $appStoreDirectory = ' C:\Source\AppStore'
54+ $appName = ' AndroidYouTubeDownloader'
55+
56+ $package = ' com.tmk907.androidyoutubedownloader'
57+ $architectures = @ (' arm64-v8a' , ' armeabi-v7a' , ' x86_64' )
58+
59+ foreach ($arch in $architectures ){
60+ $apkName = " $package -$arch -Signed.apk"
61+ $publishedApkName = " $appName -v$versionName -$arch .apk"
62+
63+ Copy-Item - Path " $publishDirectory \$apkName " - Destination " $appStoreDirectory \$publishedApkName "
64+ Write-Host " $publishedApkName copied to $publishDirectory "
65+ }
66+ }
67+
68+ ChangeVersion - newVersionName $newVersionName
69+
70+ Build - signingKeyPass $signingKeyPass
71+
72+ CopyToLocalAppStore - versionName $newVersionName
0 commit comments