diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b5e4f7f..119421f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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/github-tag-action@1.61.0 @@ -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: diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 2744c99..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -keys/ \ No newline at end of file diff --git a/app/android/app/build.gradle b/app/android/app/build.gradle index a05e61f..03e76e3 100644 --- a/app/android/app/build.gradle +++ b/app/android/app/build.gradle @@ -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 @@ -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 } } } diff --git a/app/fastlane/.gitignore b/app/fastlane/.gitignore new file mode 100644 index 0000000..4dfd54d --- /dev/null +++ b/app/fastlane/.gitignore @@ -0,0 +1 @@ +report.xml \ No newline at end of file diff --git a/app/fastlane/Fastfile b/app/fastlane/Fastfile new file mode 100644 index 0000000..9416bfa --- /dev/null +++ b/app/fastlane/Fastfile @@ -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 diff --git a/app/fastlane/README.md b/app/fastlane/README.md new file mode 100644 index 0000000..7b566b8 --- /dev/null +++ b/app/fastlane/README.md @@ -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). diff --git a/keys/.gitignore b/keys/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/keys/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file