Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Build Android Agent

on:
push:
branches: [master]
paths:
- 'Desktop.Android/**'
- 'Desktop.Shared/**'
- 'Desktop.Native/**'
- 'Shared/**'
pull_request:
branches: [master]
paths:
- 'Desktop.Android/**'
- 'Desktop.Shared/**'
- 'Desktop.Native/**'
- 'Shared/**'
workflow_dispatch:

permissions:
contents: read

jobs:
build-android:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Install Android workload
run: dotnet workload install android

- name: Set version
run: |
VERSION_STRING=$(git show -s --format=%ci)
CURRENT_VERSION=$(date -d "$VERSION_STRING" +"%Y.%m.%d.%H%M" 2>/dev/null || \
date -j -f "%Y-%m-%d %H:%M:%S %z" "$VERSION_STRING" +"%Y.%m.%d.%H%M" 2>/dev/null || \
echo "1.0.0.0")
echo "CurrentVersion=$CURRENT_VERSION" >> $GITHUB_ENV
echo "Setting version to $CURRENT_VERSION"

- name: Restore dependencies
run: dotnet restore Desktop.Android/Desktop.Android.csproj

- name: Build (Debug)
run: >
dotnet build Desktop.Android/Desktop.Android.csproj
--configuration Debug
--no-restore
/p:Version=${{ env.CurrentVersion }}

- name: Build Release APK (unsigned)
if: ${{ !secrets.ANDROID_KEY_ALIAS }}
run: >
dotnet publish Desktop.Android/Desktop.Android.csproj
--configuration Release
--no-restore
/p:Version=${{ env.CurrentVersion }}
/p:ApplicationVersion=${{ github.run_number }}
/p:AndroidCreatePackage=true
--output ./android-out/

- name: Build Release APK (signed)
if: ${{ secrets.ANDROID_KEY_ALIAS }}
run: >
dotnet publish Desktop.Android/Desktop.Android.csproj
--configuration Release
--no-restore
/p:Version=${{ env.CurrentVersion }}
/p:ApplicationVersion=${{ github.run_number }}
/p:AndroidSigningKeyAlias=${{ secrets.ANDROID_KEY_ALIAS }}
/p:AndroidSigningKeyPass=${{ secrets.ANDROID_KEY_PASS }}
/p:AndroidSigningStorePass=${{ secrets.ANDROID_STORE_PASS }}
/p:AndroidKeyStore=true
--output ./android-out/

- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: Remotely-Android-APK
path: ./android-out/*.apk
if-no-files-found: warn
Loading