Skip to content

Instantly share code, notes, and snippets.

@davamix
Created June 9, 2020 01:04
Show Gist options
  • Save davamix/238fde379870c1d4f11d7a632493c0ea to your computer and use it in GitHub Desktop.
Save davamix/238fde379870c1d4f11d7a632493c0ea to your computer and use it in GitHub Desktop.
GitHub Actions: Build a Xamarin.Forms project and create the APK
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
# Build App
build:
runs-on: windows-latest
env:
SERVICE_APP_KEY: ${{ secrets.SERVICE_APP_KEY }}
steps:
- uses: actions/checkout@v2
- name: Setup MSBuild
uses: microsoft/[email protected]
- name: Build Solution
run: msbuild ./MyApplication.sln /restore /p:Configuration=Release
- name: Create and Sign the APK
run: msbuild MyApplication\MyApplication.Android\MyApplication.Android.csproj /t:SignAndroidPackage /p:Configuration=Release /p:OutputPath=bin\Release\
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: MyApplication.apk
path: MyApplication\MyApplication.Android\bin\Release\com.companyname.myapplication-Signed.apk
@Rami-Majdoub
Copy link

That was helpful, here is an update

name: Build android app

on:
  push:
    branches: [ master ]

jobs:
  # Build App
  build:
    runs-on: windows-latest
    
    env:
      SERVICE_APP_KEY: ${{ secrets.SERVICE_APP_KEY }}
      APPLICATION_NAME: MyApplication
      PACKAGE_NAME: com.companyname.myapplication
      
    steps:
      - uses: actions/checkout@v2

      - name: Setup MSBuild
        uses: microsoft/[email protected]

      - name: Build Solution
        run: msbuild ./${{ env.APPLICATION_NAME }}.sln /restore /p:Configuration=Release

      - name: Create and Sign the APK
        run: msbuild ${{ env.APPLICATION_NAME }}.Android\${{ env.APPLICATION_NAME }}.Android.csproj /t:SignAndroidPackage /p:Configuration=Release /p:OutputPath=bin\Release\

      - name: List folder content
        run: dir ${{ env.APPLICATION_NAME }}.Android\bin\Release

      - name: Upload artifact
        uses: actions/upload-artifact@v2
        with:
          name: MyApplication.apk
          path: ${{ env.APPLICATION_NAME }}.Android\bin\Release\${{ PACKAGE_NAME }}-Signed.apk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment