Skip to content

Commit

Permalink
Add a Github Actions workflow file for android
Browse files Browse the repository at this point in the history
  • Loading branch information
solsticedhiver committed Feb 4, 2023
1 parent 89dfd86 commit bb45a1e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/android-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: App Android Release

on:
push:
branches: [ main ]

jobs:
version:
name: Create version number
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.version.outputs.version }}
output2: ${{ steps.vars.outputs.sha_short }}
steps:
- uses: actions/checkout@v3
- name: Fetch all history for all tags and branches
run: |
git fetch --prune --depth=1000
- name: Create version
id: version
run: echo "version=v$(grep ^version pubspec.yaml |cut -f 2 -d ' '|cut -f 1 -d '+')" >> $GITHUB_OUTPUT
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
build:
name: Build APK and Create release
needs: [ version ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '18'
#cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/setup-android@v2
- uses: subosito/flutter-action@v2
with:
channel : 'stable'
- run: flutter pub get
#- run: flutter test
- run: flutter build apk --release --split-per-abi
- run: flutter build appbundle
- name: Create a Release in GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/app-release.aab"
token: "${{ secrets.GH_TOKEN }}"
tag: "${{ needs.version.outputs.output1 }}"
commit: "${{ github.sha }}"
19 changes: 19 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
Expand All @@ -9,3 +10,21 @@ localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
*/
// this new file is needed to build via Github Actions
// https://github.com/flutter/flutter/issues/55827#issuecomment-623779910
include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}

0 comments on commit bb45a1e

Please sign in to comment.