-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (74 loc) · 3.35 KB
/
android.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
name: Build Android app
on:
workflow_dispatch:
inputs:
input_app_version:
description: 'Application version'
required: true
type: string
default: '1.0.0'
jobs:
build:
runs-on: windows-latest
env:
Solution_Name: RacingCarsController.sln
Project_Path: RacingCarsControllerAndroid/RacingCarsControllerAndroid.csproj
Publish_Directory: RacingCarsControllerAndroid/bin/Release/net8.0-android/publish
Project_Directory: RacingCarsControllerAndroid
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
# Update the appxmanifest before build by setting the per-channel values set in the matrix.
- name: Change Version
run: |
# Get current version code and increment
$manifestPath = "$env:Project_Directory/AndroidManifest.xml"
$csprojPath = $env:Project_Path
$newVersionCode = git rev-list HEAD --count
$newVersionName = ${{ inputs.input_app_version }}
# 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
- name: Setup .NET 8
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Install MAUI Android Workload
run: dotnet workload install maui-android --ignore-failed-sources
- name: Restore Dependencies
run: dotnet restore $env:Project_Path
- name: Build Android
run: dotnet publish $env:Project_Path -c Release -f net8.0-android /p:AndroidSigningKeyPass=${{ secrets.SIGNING_KEY_PASS }} /p:AndroidSigningStorePass=${{ secrets.SIGNING_KEY_PASS }}
# Move package
- name: Move package
run: |
$appName = 'RacingCarsController'
$package = 'com.tmk907.RacingCarsControllerAndroid'
$architectures = @('arm64-v8a','armeabi-v7a','x86_64')
foreach($arch in $architectures){
$apkName = "$package-$arch-Signed.apk"
$publishedApkName = "$appName-v${{ inputs.input_app_version }}-$arch.apk"
Move-Item -Path "$env:Publish_Directory\$apkName" -Destination ./
Write-Host "$publishedApkName moved"
}
# Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact
- name: Upload MSIX package
uses: actions/upload-artifact@v3
with:
name: RacingCarsControllerAndroid
path: |
./*.apk
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: android-v${{ inputs.input_app_version }}
name: Release Android ${{ inputs.input_app_version }}
artifacts: "./*.apk"
generateReleaseNotes: true
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}