Skip to content

Commit f94a859

Browse files
committed
Create build script
1 parent 39d11bb commit f94a859

File tree

2 files changed

+82
-5
lines changed

2 files changed

+82
-5
lines changed

CreateApk.ps1

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
## Build
44

5-
Update `ApplicationVersion` and `ApplicationDisplayVersion` in csproj file and project properties.
6-
Clear bin and obj folders.
5+
Run build script
76
```
8-
dotnet publish -f:net6.0-android -c:Release /p:AndroidSigningKeyPass=mypassword /p:AndroidSigningStorePass=mypassword
7+
.\CreateApk.ps1 -newVersionName 'x.y' -signingKeyPass 'mypassword'
98
```
10-
Published apk
11-
`\AndroidYouTubeDownloader\AndroidYouTubeDownloader\bin\Release\net6.0-android\publish`
9+
10+
Or:
11+
Update `ApplicationVersion` and `ApplicationDisplayVersion` in csproj file and project properties.
12+
Clear bin and obj folders.
13+
```
14+
dotnet publish -f:net6.0-android -c:Release /p:AndroidSigningKeyPass=mypassword /p:AndroidSigningStorePass=mypassword
15+
```
16+
Published apk folder: `\AndroidYouTubeDownloader\AndroidYouTubeDownloader\bin\Release\net6.0-android\publish`
1217

1318
## Build ffmpeg-kit
1419

0 commit comments

Comments
 (0)