mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-22 15:30:59 +00:00
Compare commits
No commits in common. "f307676ca5671a430cd97b336ccf5a12cf91e9b6" and "9d1f87c156b83280ea201fc6868b590e1358ac54" have entirely different histories.
f307676ca5
...
9d1f87c156
5 changed files with 69 additions and 77 deletions
101
.github/workflows/build_apk.yml
vendored
101
.github/workflows/build_apk.yml
vendored
|
@ -3,29 +3,19 @@
|
||||||
# separate terms of service, privacy policy, and support
|
# separate terms of service, privacy policy, and support
|
||||||
# documentation.
|
# documentation.
|
||||||
|
|
||||||
name: Build .apk
|
name: Build Prod .ipa
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
|
||||||
flavor:
|
env:
|
||||||
description: 'Flavor'
|
FLAVOR: "prod"
|
||||||
type: choice
|
|
||||||
required: true
|
|
||||||
options:
|
|
||||||
- dev
|
|
||||||
- prod
|
|
||||||
default: 'dev'
|
|
||||||
include-iap:
|
|
||||||
type: boolean
|
|
||||||
description: Include IAP package
|
|
||||||
default: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build .apk
|
name: Build .ipa
|
||||||
runs-on: macos-11
|
runs-on: macos-11
|
||||||
timeout-minutes: 15
|
timeout-minutes: 20
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
@ -33,52 +23,54 @@ jobs:
|
||||||
|
|
||||||
- name: Connect private iap package
|
- name: Connect private iap package
|
||||||
uses: webfactory/ssh-agent@v0.8.0
|
uses: webfactory/ssh-agent@v0.8.0
|
||||||
if: ${{ inputs.include-iap }}
|
|
||||||
with:
|
with:
|
||||||
ssh-private-key: ${{ secrets.M3_LIGHTMETER_IAP_KEY }}
|
ssh-private-key: ${{ secrets.M3_LIGHTMETER_IAP_KEY }}
|
||||||
|
|
||||||
- name: Override iap package with stub
|
|
||||||
if: ${{ !inputs.include-iap }}
|
|
||||||
run: bash ./.github/scripts/stub_iap.sh
|
|
||||||
|
|
||||||
- uses: actions/setup-java@v2
|
- uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
distribution: "zulu"
|
distribution: "zulu"
|
||||||
java-version: "11"
|
java-version: "11"
|
||||||
|
|
||||||
- name: Restore Android keystore .jsk and .properties files
|
- name: Install the Apple certificate and provisioning profile
|
||||||
env:
|
env:
|
||||||
KEYSTORE: ${{ secrets.KEYSTORE }}
|
APP_STORE_P12: ${{ secrets.APP_STORE_P12 }}
|
||||||
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}
|
APP_STORE_P12_PASSWORD: ${{ secrets.APP_STORE_P12_PASSWORD }}
|
||||||
|
APP_STORE_PROVISION_PROD: ${{ secrets.APP_STORE_PROVISION_PROD }}
|
||||||
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
KEYSTORE_PATH=$RUNNER_TEMP/keystore.jks
|
# create variables
|
||||||
echo -n "$KEYSTORE" | base64 --decode --output $KEYSTORE_PATH
|
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
|
||||||
cp $KEYSTORE_PATH ./android/app
|
PROVISION_PATH=$RUNNER_TEMP/build_provision.mobileprovision
|
||||||
KEYSTORE_PROPERTIES_PATH=$RUNNER_TEMP/key.properties
|
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
|
||||||
echo -n "$KEYSTORE_PROPERTIES" | base64 --decode --output $KEYSTORE_PROPERTIES_PATH
|
|
||||||
cp $KEYSTORE_PROPERTIES_PATH ./android
|
|
||||||
|
|
||||||
- name: Restore android/app/google-services.json
|
# import certificate and provisioning profile from secrets
|
||||||
env:
|
echo -n "$APP_STORE_P12" | base64 --decode -o $CERTIFICATE_PATH
|
||||||
GOOGLE_SERVICES_JSON_ANDROID: ${{ secrets.GOOGLE_SERVICES_JSON_ANDROID }}
|
echo -n "$APP_STORE_PROVISION_PROD" | base64 --decode -o $PROVISION_PATH
|
||||||
run: |
|
|
||||||
GOOGLE_SERVICES_JSON_ANDROID_PATH=$RUNNER_TEMP/google-services.json
|
# create temporary keychain
|
||||||
echo -n "$GOOGLE_SERVICES_JSON_ANDROID" | base64 --decode --output $GOOGLE_SERVICES_JSON_ANDROID_PATH
|
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
||||||
cp $GOOGLE_SERVICES_JSON_ANDROID_PATH ./android/app
|
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
|
||||||
|
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
|
||||||
|
|
||||||
|
# import certificate to keychain
|
||||||
|
security import $CERTIFICATE_PATH -P "$APP_STORE_P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
|
||||||
|
security list-keychain -d user -s $KEYCHAIN_PATH
|
||||||
|
|
||||||
|
# apply provisioning profile
|
||||||
|
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
|
||||||
|
cp $PROVISION_PATH ~/Library/MobileDevice/Provisioning\ Profiles
|
||||||
|
|
||||||
|
- name: Restore ios/Runner/ExportOptions.plist
|
||||||
|
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.APP_STORE_EXPORT_OPTIONS }}" "ios/Runner/ExportOptions.plist"
|
||||||
|
|
||||||
- name: Restore firebase_options.dart
|
- name: Restore firebase_options.dart
|
||||||
env:
|
run: bash .github/scripts/restore_from_base64.sh "${{ secrets.FIREBASE_OPTIONS }}" "lib/firebase_options.dart"
|
||||||
FIREBASE_OPTIONS: ${{ secrets.FIREBASE_OPTIONS }}
|
|
||||||
run: |
|
|
||||||
FIREBASE_OPTIONS_PATH=$RUNNER_TEMP/firebase_options.dart
|
|
||||||
echo -n "$FIREBASE_OPTIONS" | base64 --decode --output $FIREBASE_OPTIONS_PATH
|
|
||||||
cp $FIREBASE_OPTIONS_PATH ./lib
|
|
||||||
|
|
||||||
- name: Install Flutter
|
- name: Install Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
channel: "stable"
|
channel: "stable"
|
||||||
flutter-version: '3.10.0'
|
flutter-version: "3.10.0"
|
||||||
|
|
||||||
- name: Prepare flutter project
|
- name: Prepare flutter project
|
||||||
run: |
|
run: |
|
||||||
|
@ -86,13 +78,22 @@ jobs:
|
||||||
flutter pub get
|
flutter pub get
|
||||||
flutter pub run intl_utils:generate
|
flutter pub run intl_utils:generate
|
||||||
|
|
||||||
- name: Build .apk
|
- name: Build .ipa
|
||||||
env:
|
run: |
|
||||||
FLAVOR: ${{ github.event.inputs.flavor }}
|
flutter build ipa \
|
||||||
run: flutter build apk --release --flavor $FLAVOR -t lib/main_$FLAVOR.dart
|
--release \
|
||||||
|
--flavor $FLAVOR \
|
||||||
|
--target lib/main_$FLAVOR.dart \
|
||||||
|
--export-options-plist=ios/Runner/ExportOptions.plist
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: m3_lightmeter_${{ github.event.inputs.flavor }}_apk
|
name: m3_lightmeter_$FLAVOR_ipa
|
||||||
path: build/app/outputs/flutter-apk/app-${{ github.event.inputs.flavor }}-release.apk
|
path: build/ios/ipa/lightmeter.ipa
|
||||||
|
|
||||||
|
- name: Clean up keychain and provisioning profile
|
||||||
|
if: ${{ always() }}
|
||||||
|
run: |
|
||||||
|
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
|
||||||
|
rm ~/Library/MobileDevice/Provisioning\ Profiles/build_provision.mobileprovision
|
||||||
|
|
2
.github/workflows/build_ipa.yml
vendored
2
.github/workflows/build_ipa.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
||||||
build:
|
build:
|
||||||
name: Build .ipa
|
name: Build .ipa
|
||||||
runs-on: macos-11
|
runs-on: macos-11
|
||||||
timeout-minutes: 60
|
timeout-minutes: 20
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
|
13
README.md
13
README.md
|
@ -75,8 +75,17 @@ Out of the box Firebase Crashlytics won't work. If you want to add Crashlytics t
|
||||||
|
|
||||||
### 4. Build
|
### 4. Build
|
||||||
|
|
||||||
- Checkout [Build .apk](.github/workflows/build_apk.yml) workflow for Android
|
#### Android
|
||||||
- Checkout [Build .ipa](.github/workflows/build_ipa.yml) workflow for iOS
|
|
||||||
|
You can build an apk by running the following command from the root of the repository:
|
||||||
|
|
||||||
|
```console
|
||||||
|
flutter build apk --release --flavor dev --dart-define cameraPreviewAspectRatio=240/320 -t lib/main_dev.dart
|
||||||
|
```
|
||||||
|
|
||||||
|
### iOS
|
||||||
|
|
||||||
|
TBD
|
||||||
|
|
||||||
# Support
|
# Support
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import 'dart:io';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:camera/camera.dart';
|
import 'package:camera/camera.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
@ -254,29 +253,12 @@ class _WidgetsBindingObserver with WidgetsBindingObserver {
|
||||||
|
|
||||||
_WidgetsBindingObserver(this.onLifecycleStateChanged);
|
_WidgetsBindingObserver(this.onLifecycleStateChanged);
|
||||||
|
|
||||||
/// Revoking camera permissions results in app being killed both on Android and iOS
|
|
||||||
@override
|
@override
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
switch (defaultTargetPlatform) {
|
|
||||||
/// On Android opening a dialog results in [AppLifecycleState.inactive]
|
|
||||||
case TargetPlatform.android:
|
|
||||||
if (_prevState == AppLifecycleState.inactive && state == AppLifecycleState.resumed) {
|
if (_prevState == AppLifecycleState.inactive && state == AppLifecycleState.resumed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_prevState = state;
|
_prevState = state;
|
||||||
onLifecycleStateChanged(state);
|
onLifecycleStateChanged(state);
|
||||||
|
|
||||||
/// When coming from the app's settings iOS fires paused -> inactive -> resumed state which falls into this condition.
|
|
||||||
/// So the inactive state is skipped.
|
|
||||||
case TargetPlatform.iOS:
|
|
||||||
if (state == AppLifecycleState.inactive) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_prevState != state) {
|
|
||||||
_prevState = state;
|
|
||||||
onLifecycleStateChanged(state);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ for i in "${devices_array[@]}"; do # https://www.baeldung.com/linux/shell-script
|
||||||
xcrun simctl boot "$i"
|
xcrun simctl boot "$i"
|
||||||
#uid=$(echo "$(fvm flutter devices)" | sed -n -r "s/$i \(mobile\) • (.*) • .* • .*\(simulator\)/\1/p")
|
#uid=$(echo "$(fvm flutter devices)" | sed -n -r "s/$i \(mobile\) • (.*) • .* • .*\(simulator\)/\1/p")
|
||||||
#echo $uid
|
#echo $uid
|
||||||
sh screenshots/scripts/generate_screenshots.sh "$i"
|
sh screenshots/generate_screenshots.sh "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
killall 'Simulator'
|
killall 'Simulator'
|
||||||
|
|
Loading…
Reference in a new issue