Build signed apk on tag creation (#35)

* Create cd.yml

* added artifact upload

* fixed jobs sequence

* moved upload to build job

* jobs rename

* keystore

* Update cd.yml

* macos runner

* cd_dev

* Update build.gradle
This commit is contained in:
Vadim 2023-02-16 00:16:39 +03:00 committed by GitHub
parent 59e440dfd7
commit 8d1640447f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 48 deletions

View file

@ -1,42 +0,0 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Build app-dev-release.apk
on:
push:
branches: [ "cd" ]
tags:
- "v*.*.*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Check flutter version
run: flutter --version
- name: Install dependencies
run: flutter pub get
- name: Generate intl
run: flutter pub run intl_utils:generate
- name: Analyze project source
run: flutter analyze
- name: Build Apk
run: flutter build apk --flavor dev --dart-define cameraPreviewAspectRatio=2/3 -t lib/main_dev.dart
- uses: actions/upload-artifact@v3
with:
name: m3_lightmeter.apk
path: build/app/outputs/flutter-apk/app-dev-release.apk

56
.github/workflows/cd_dev.yml vendored Normal file
View file

@ -0,0 +1,56 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Build app-dev-release.apk
on:
push:
branches: ["cd"]
tags:
- "v*.*.*"
workflow_dispatch:
jobs:
build:
runs-on: macos-11
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "11"
- name: Restore Android keystore .jsk and .properties files
env:
KEYSTORE: ${{ secrets.KEYSTORE }}
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}
run: |
KEYSTORE_PATH=$RUNNER_TEMP/keystore.jks
echo -n "$KEYSTORE" | base64 --decode --output $KEYSTORE_PATH
cp $KEYSTORE_PATH ./android/app
KEYSTORE_PROPERTIES_PATH=$RUNNER_TEMP/key.properties
echo -n "$KEYSTORE_PROPERTIES" | base64 --decode --output $KEYSTORE_PROPERTIES_PATH
cp $KEYSTORE_PROPERTIES_PATH ./android
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
- name: Prepare flutter project
run: |
flutter --version
flutter pub get
flutter pub run intl_utils:generate
- name: Build Apk
run: flutter build apk --release --flavor dev --dart-define cameraPreviewAspectRatio=2/3 -t lib/main_dev.dart
- uses: actions/upload-artifact@v3
with:
name: m3_lightmeter.apk
path: build/app/outputs/flutter-apk/app-dev-release.apk

View file

@ -21,6 +21,12 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
@ -50,15 +56,12 @@ android {
}
signingConfigs {
debug {}
/*
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
*/
}
flavorDimensions "app"
@ -66,12 +69,12 @@ android {
dev {
applicationId "com.vodemn.lightmeter.dev"
dimension "app"
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
prod {
applicationId "com.vodemn.lightmeter"
dimension "app"
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
}
@ -80,7 +83,7 @@ android {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
}