Skip to content

Build Android app

Build Android app #16

name: Build Android app
on:
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
workflow_dispatch:
env:
DOTNETVERSION: 8.0.303
MAUIFRAMEWORK: net8.0-android
PROJECTNAME: Skolplattformen.ElevApp
APPLICATIONID: se.kolplattformen.elevapp
jobs:
build-Android:
runs-on: ubuntu-22.04
env:
BUILDNUMBER: $(expr ${{ github.run_number }} + 16)
steps:
- uses: actions/checkout@v4
- name: Setup .NET SDK ${{env.DOTNETVERSION}}
uses: actions/setup-dotnet@v4
with:
dotnet-version: '${{env.DOTNETVERSION}}'
- name: List installed .NET info
shell: pwsh
run: dotnet --info
- name: Remove unused frameworks from project
run: |
sed -E -i "s:<TargetFrameworks>[^<]+</TargetFrameworks>:<TargetFrameworks>${{env.MAUIFRAMEWORK}}</TargetFrameworks>:g" src/${{env.PROJECTNAME}}/${{env.PROJECTNAME}}.csproj
- name: Set build number
run: |
sed -E -i "s:<ApplicationVersion>[^<]+</ApplicationVersion>:<ApplicationVersion>${{env.BUILDNUMBER}}</ApplicationVersion>:g" src/${{env.PROJECTNAME}}/${{env.PROJECTNAME}}.csproj
- name: Install .NET MAUI
shell: bash
run: |
dotnet nuget locals all --clear
dotnet workload install maui-android
dotnet workload install android
- name: Restore nuget packages
shell: bash
run: |
cd src
dotnet workload restore ${{env.PROJECTNAME}}.sln
dotnet restore ${{env.PROJECTNAME}}.sln
- name: Set Up Android tools
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
"platform-tools"
# https://docs.microsoft.com/en-us/dotnet/maui/android/deployment/overview
- name : Build Android App
shell: bash
run: |
cd src/${{env.PROJECTNAME}}
dotnet publish ${{env.PROJECTNAME}}.csproj -f:${{env.MAUIFRAMEWORK}} -c:Release -p:AndroidKeyStore=True -p:AndroidSigningKeyAlias=key -p:AndroidSigningKeyStore=elevapp.release.keystore -p:AndroidSigningKeyPass=${{secrets.ANDROID_RELEASE_KEYSTORE_PASSWORD }} -p:AndroidSigningStorePass=${{secrets.ANDROID_RELEASE_KEYSTORE_PASSWORD }} "/p:ApplicationId=${{env.APPLICATIONID}}"
- uses: actions/upload-artifact@v2
with:
name: artifacts-android
path: |
# src/${{env.PROJECTNAME}}/bin/Release/${{env.MAUIFRAMEWORK}}/publish/${{env.APPLICATIONID}}-Signed.aab
src/${{env.PROJECTNAME}}/bin/Release/${{env.MAUIFRAMEWORK}}/publish/*.*