Skip to content

Commit

Permalink
fastlane build system
Browse files Browse the repository at this point in the history
  • Loading branch information
kilimnik committed Feb 20, 2023
1 parent a9a1593 commit bd1da62
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 26 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,21 @@ permissions:
jobs:
build:
name: Build and Release
environment: Deploy
runs-on: ubuntu-latest
steps:
- uses: subosito/flutter-action@v2
with:
channel: "stable"

- uses: actions/checkout@v3
with:
fetch-depth: "0"

- uses: actions/setup-java@v3
with:
java-version: "11.x"
distribution: temurin

- run: flutter pub get
working-directory: ./app

# Currenly no tests :(
# - run: flutter test
# working-directory: ./app

- run: flutter build apk --release
working-directory: ./app

- run: flutter build appbundle --release
working-directory: ./app
- uses: actions/checkout@v3
with:
fetch-depth: "0"

- name: Bump version and push tag
uses: anothrNick/[email protected]
Expand All @@ -47,6 +35,14 @@ jobs:
WITH_V: true
DEFAULT_BUMP: patch

- run: echo $KEY_JKS | base64 --decode > ../keys/key.jks && sha256sum ../keys/key.jks && echo $KEY_JKS | sha256sum && echo $KEY_JKS | wc -c && flutter build apk && flutter build appbundle
working-directory: ./app
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
KEY_PASSWORD: ${{ secrets.ALIAS_PASSWORD }}
ALIAS_PASSWORD: ${{ secrets.KEY_PASSWORD }}
VERSION: ${{ steps.tagger.outputs.new_tag }}

- name: Push Release
uses: softprops/action-gh-release@v1
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

39 changes: 30 additions & 9 deletions app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@ if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
def flutterVersionName = System.getenv('VERSION')
def flutterVersionCode = '1'
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
else
{
if (flutterVersionName[0] == "v") {
flutterVersionName = flutterVersionName.substring(1);
}

String[] versionSplit = flutterVersionName.split(/\./);

flutterVersionCode = versionSplit.collect { element ->
Integer.parseInt(element);
}.withIndex().collect { element, index ->
if (element >> 10 != 0) {
throw new Exception('unsupported version format')
}

element << (10 * index);
}.sum();
}

apply plugin: 'com.android.application'
// START: FlutterFire Configuration
Expand Down Expand Up @@ -59,11 +73,18 @@ android {
multiDexEnabled true
}

signingConfigs {
release {
storeFile file("../../../keys/key.jks")
keyAlias = "vepiot_release"
storePassword = System.getenv('KEY_PASSWORD')
keyPassword = System.getenv('ALIAS_PASSWORD')
}
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/fastlane/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
report.xml
37 changes: 37 additions & 0 deletions app/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:android)

platform :android do
lane :build do
desc "Build apk and aab"

sh(command: "flutter build appbundle")
sh(command: "flutter build apk")
end

lane :deploy do
desc "Deploy a build app bundle to Google Play"

upload_to_play_store(
package_name: "com.vepiot.app",
json_key_data: ENV['GOOGLE_JSON_KEY'],
aab: "build/app/outputs/bundle/release/app-release.aab",
rollout: "1",
version_name: ENV['VERSION']
)
end
end
40 changes: 40 additions & 0 deletions app/fastlane/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
fastlane documentation
----

# Installation

Make sure you have the latest version of the Xcode command line tools installed:

```sh
xcode-select --install
```

For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)

# Available Actions

## Android

### android build

```sh
[bundle exec] fastlane android build
```



### android deploy

```sh
[bundle exec] fastlane android deploy
```



----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.

More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).

The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).
2 changes: 2 additions & 0 deletions keys/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit bd1da62

Please sign in to comment.