adapted scripts and workflows for bundled flutter

This commit is contained in:
Thibault Deckers 2022-11-26 12:18:57 +01:00
parent a437d1cfad
commit 1614b600ac
18 changed files with 175 additions and 69 deletions

1
.flutter Submodule

@ -0,0 +1 @@
Subproject commit b8f7f1f9869bb2d116aa6a70dbeac61000b52849

View file

@ -5,34 +5,22 @@ on:
branches:
- develop
# TODO TLAD run `flutter format -l 1000 .` and fail if any
jobs:
build:
name: Check code quality.
runs-on: ubuntu-latest
steps:
# Flutter SDK is pulled from https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json
# or, as displayed at https://docs.flutter.dev/development/tools/sdk/releases?tab=linux
# Available versions may lag behind https://github.com/flutter/flutter.git
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.9'
channel: 'stable'
- name: Clone the repository.
uses: actions/checkout@v2
- name: Get packages for the Flutter project.
working-directory: ${{ github.workspace }}/scripts
run: ./pub_get_all.sh
run: scripts/pub_get_all.sh
- name: Update the flutter version file.
working-directory: ${{ github.workspace }}/scripts
run: ./update_flutter_version.sh
run: scripts/update_flutter_version.sh
- name: Static analysis.
run: flutter analyze
run: ./flutterw analyze
- name: Unit tests.
run: flutter test
run: ./flutterw test

View file

@ -14,30 +14,20 @@ jobs:
with:
java-version: '11.x'
# Flutter SDK is pulled from https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json
# or, as displayed at https://docs.flutter.dev/development/tools/sdk/releases?tab=linux
# Available versions may lag behind https://github.com/flutter/flutter.git
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.9'
channel: 'stable'
- name: Clone the repository.
uses: actions/checkout@v2
- name: Get packages for the Flutter project.
working-directory: ${{ github.workspace }}/scripts
run: ./pub_get_all.sh
run: scripts/pub_get_all.sh
- name: Update the flutter version file.
working-directory: ${{ github.workspace }}/scripts
run: ./update_flutter_version.sh
run: scripts/update_flutter_version.sh
- name: Static analysis.
run: flutter analyze
run: ./flutterw analyze
- name: Unit tests.
run: flutter test
run: ./flutterw test
- name: Build signed artifacts.
# `KEY_JKS` should contain the result of:
@ -53,19 +43,19 @@ jobs:
gpg -d --passphrase "${{ secrets.KEY_JKS_PASSPHRASE }}" --batch release.keystore.asc > $AVES_STORE_FILE
rm release.keystore.asc
mkdir outputs
(cd scripts/; ./apply_flavor_play.sh)
flutter build appbundle -t lib/main_play.dart --flavor play --bundle-sksl-path shaders.sksl.json
scripts/apply_flavor_play.sh
./flutterw build appbundle -t lib/main_play.dart --flavor play --bundle-sksl-path shaders.sksl.json
cp build/app/outputs/bundle/playRelease/*.aab outputs
flutter build apk -t lib/main_play.dart --flavor play --bundle-sksl-path shaders.sksl.json
./flutterw build apk -t lib/main_play.dart --flavor play --bundle-sksl-path shaders.sksl.json
cp build/app/outputs/apk/play/release/*.apk outputs
(cd scripts/; ./apply_flavor_huawei.sh)
flutter build apk -t lib/main_huawei.dart --flavor huawei --bundle-sksl-path shaders.sksl.json
scripts/apply_flavor_huawei.sh
./flutterw build apk -t lib/main_huawei.dart --flavor huawei --bundle-sksl-path shaders.sksl.json
cp build/app/outputs/apk/huawei/release/*.apk outputs
(cd scripts/; ./apply_flavor_izzy.sh)
flutter build apk -t lib/main_izzy.dart --flavor izzy --split-per-abi
scripts/apply_flavor_izzy.sh
./flutterw build apk -t lib/main_izzy.dart --flavor izzy --split-per-abi
cp build/app/outputs/apk/izzy/release/*.apk outputs
(cd scripts/; ./apply_flavor_libre.sh)
flutter build apk -t lib/main_libre.dart --flavor libre
scripts/apply_flavor_libre.sh
./flutterw build apk -t lib/main_libre.dart --flavor libre --split-per-abi
cp build/app/outputs/apk/libre/release/*.apk outputs
rm $AVES_STORE_FILE
env:

4
.gitmodules vendored Normal file
View file

@ -0,0 +1,4 @@
[submodule ".flutter"]
path = .flutter
url = https://github.com/flutter/flutter.git
branch = stable

View file

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
## <a id="unreleased"></a>[Unreleased]
### Changed
- build: use `flutter-wrapper`, bundle Flutter as submodule
- build: use split APKs for `libre` flavor
## <a id="v1.7.5"></a>[v1.7.5] - 2022-11-23
### Added

View file

@ -118,14 +118,14 @@ Some users have expressed the wish to financially support the project. Thanks!
Before running or building the app, update the dependencies for the desired flavor:
```
# ./scripts/apply_flavor_play.sh
# scripts/apply_flavor_play.sh
```
To build the project, create a file named `<app dir>/android/key.properties`. It should contain a reference to a keystore for app signing, and other necessary credentials. See [key_template.properties](https://github.com/deckerst/aves/blob/develop/android/key_template.properties) for the expected keys.
To run the app:
```
# flutter run -t lib/main_play.dart --flavor play
# ./flutterw run -t lib/main_play.dart --flavor play
```
[Version badge]: https://img.shields.io/github/v/release/deckerst/aves?include_prereleases&sort=semver

View file

@ -33,12 +33,12 @@ if (keystorePropertiesFile.exists()) {
// for release using credentials in environment variables set up by GitHub Actions
// warning: in property file, single quotes should be escaped with a backslash
// but they should not be escaped when stored in env variables
keystoreProperties['storeFile'] = System.getenv('AVES_STORE_FILE')
keystoreProperties['storePassword'] = System.getenv('AVES_STORE_PASSWORD')
keystoreProperties['keyAlias'] = System.getenv('AVES_KEY_ALIAS')
keystoreProperties['keyPassword'] = System.getenv('AVES_KEY_PASSWORD')
keystoreProperties['googleApiKey'] = System.getenv('AVES_GOOGLE_API_KEY')
keystoreProperties['huaweiApiKey'] = System.getenv('AVES_HUAWEI_API_KEY')
keystoreProperties['storeFile'] = System.getenv('AVES_STORE_FILE') ?: '<NONE>'
keystoreProperties['storePassword'] = System.getenv('AVES_STORE_PASSWORD') ?: '<NONE>'
keystoreProperties['keyAlias'] = System.getenv('AVES_KEY_ALIAS') ?: '<NONE>'
keystoreProperties['keyPassword'] = System.getenv('AVES_KEY_PASSWORD') ?: '<NONE>'
keystoreProperties['googleApiKey'] = System.getenv('AVES_GOOGLE_API_KEY') ?: '<NONE>'
keystoreProperties['huaweiApiKey'] = System.getenv('AVES_HUAWEI_API_KEY') ?: '<NONE>'
}
android {
@ -60,8 +60,8 @@ android {
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
manifestPlaceholders = [googleApiKey: keystoreProperties['googleApiKey'],
huaweiApiKey: keystoreProperties['huaweiApiKey']]
manifestPlaceholders = [googleApiKey: keystoreProperties['googleApiKey'] ?: '<NONE>',
huaweiApiKey: keystoreProperties['huaweiApiKey'] ?: '<NONE>']
multiDexEnabled true
}
@ -105,8 +105,8 @@ android {
// check offending libraries with `fdroidserver`
// cf https://f-droid.org/en/docs/Submitting_to_F-Droid_Quick_Start_Guide/
dimension "store"
// generate a universal APK without x86 native libs
ext.useNdkAbiFilters = true
// generate APK by ABI, but NDK ABI filters are incompatible with split APK generation
ext.useNdkAbiFilters = false
applicationIdSuffix ".libre"
}
}

113
flutterw Executable file
View file

@ -0,0 +1,113 @@
#!/usr/bin/env sh
##############################################################################
##
## Flutter start up script for UN*X
## Version: v1.3.1
## Date: 2022-11-26 11:30:13
##
## Use this flutter wrapper to bundle Flutter within your project to make
## sure everybody builds with the same version.
##
## Read about the install and uninstall process in the README on GitHub
## https://github.com/passsy/flutter_wrapper
##
## Inspired by gradle-wrapper.
##
##############################################################################
echoerr() { echo "$@" 1>&2; }
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ]; do
ls=$(ls -ld "$PRG")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '/.*' >/dev/null; then
PRG="$link"
else
PRG=$(dirname "$PRG")"/$link"
fi
done
SAVED="$(pwd)"
cd "$(dirname "$PRG")/" >/dev/null
APP_HOME="$(pwd -P)"
cd "$SAVED" >/dev/null
FLUTTER_SUBMODULE_NAME='.flutter'
GIT_HOME=$(git -C "${APP_HOME}" rev-parse --show-toplevel)
FLUTTER_DIR="${GIT_HOME}/${FLUTTER_SUBMODULE_NAME}"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
# Fix not initialized flutter submodule
if [ ! -f "${FLUTTER_DIR}/bin/flutter" ]; then
echoerr "$FLUTTER_SUBMODULE_NAME submodule not initialized. Initializing..."
git submodule update --init "${FLUTTER_DIR}"
fi
# Detect detach HEAD and fix it. commands like upgrade expect a valid branch, not a detached HEAD
FLUTTER_SYMBOLIC_REF=$(git -C "${FLUTTER_DIR}" symbolic-ref -q HEAD)
if [ -z "${FLUTTER_SYMBOLIC_REF}" ]; then
FLUTTER_REV=$(git -C "${FLUTTER_DIR}" rev-parse HEAD)
FLUTTER_CHANNEL=$(git -C "${GIT_HOME}" config -f .gitmodules submodule.${FLUTTER_SUBMODULE_NAME}.branch)
if [ -z "${FLUTTER_CHANNEL}" ]; then
echoerr "Warning: Submodule '$FLUTTER_SUBMODULE_NAME' doesn't point to an official Flutter channel \
(one of stable|beta|dev|master). './flutterw upgrade' will fail without a channel."
echoerr "Fix this by adding a specific channel with:"
echoerr " - './flutterw channel <channel>' or"
echoerr " - Add 'branch = <channel>' to '$FLUTTER_SUBMODULE_NAME' submodule in .gitmodules"
else
echoerr "Fixing detached HEAD: '$FLUTTER_SUBMODULE_NAME' submodule points to a specific commit $FLUTTER_REV, not channel '$FLUTTER_CHANNEL' (as defined in .gitmodules)."
# Make sure channel is fetched
# Remove old channel branch because it might be moved to an unrelated commit where fast-forward pull isn't possible
git -C "${FLUTTER_DIR}" branch -q -D "${FLUTTER_CHANNEL}" 2> /dev/null || true
git -C "${FLUTTER_DIR}" fetch -q origin
# bind current HEAD to channel defined in .gitmodules
git -C "${FLUTTER_DIR}" checkout -q -b "${FLUTTER_CHANNEL}" "${FLUTTER_REV}"
git -C "${FLUTTER_DIR}" branch -q -u "origin/${FLUTTER_CHANNEL}" "${FLUTTER_CHANNEL}"
echoerr "Fixed! Migrated to channel '$FLUTTER_CHANNEL' while staying at commit $FLUTTER_REV. './flutterw upgrade' now works without problems!"
git -C "${FLUTTER_DIR}" status -bs
fi
fi
# Wrapper tasks done, call flutter binary with all args
set -e
"$FLUTTER_DIR/bin/flutter" "$@"
set +e
# Post flutterw tasks. exit code from /bin/flutterw will be used as final exit
FLUTTER_EXIT_STATUS=$?
if [ ${FLUTTER_EXIT_STATUS} -eq 0 ]; then
# ./flutterw channel CHANNEL
if echo "$@" | grep -q "channel"; then
if [ -n "$2" ]; then
# make sure .gitmodules is updated as well
CHANNEL=${2} # second arg
git config -f "${GIT_HOME}/.gitmodules" "submodule.${FLUTTER_SUBMODULE_NAME}.branch" "${CHANNEL}"
# makes sure nobody forgets to do commit all changed files
git add "${GIT_HOME}/.gitmodules"
git add "${FLUTTER_DIR}"
fi
fi
# ./flutterw upgrade
if echo "$@" | grep -q "upgrade"; then
# makes sure nobody forgets to do commit the changed submodule
git add "${FLUTTER_DIR}"
# flutter packages get runs automatically. Stage those changes as well
if [ -f pubspec.lock ]; then
git add pubspec.lock
fi
fi
fi
exit ${FLUTTER_EXIT_STATUS}

View file

@ -344,7 +344,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.1"
version: "3.1.2"
wkt_parser:
dependency: transitive
description:

View file

@ -326,7 +326,7 @@ packages:
name: flex_color_picker
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.1"
version: "3.0.0"
flex_seed_scheme:
dependency: transitive
description:
@ -1242,7 +1242,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.1"
version: "3.1.2"
wkt_parser:
dependency: transitive
description:

View file

@ -10,7 +10,8 @@ version: 1.7.5+85
publish_to: none
environment:
# keep in sync with GitHub workflows
# this project bundles Flutter SDK via `flutter_wrapper`
# cf https://github.com/passsy/flutter_wrapper
flutter: 3.3.9
sdk: ">=2.18.0 <3.0.0"

View file

@ -5,9 +5,9 @@ fi
PUBSPEC_PATH="pubspec.yaml"
flutter clean
./flutterw clean
sed -i 's|plugins/aves_services_.*|plugins/aves_services_huawei|g' "$PUBSPEC_PATH"
sed -i 's|plugins/aves_report_.*|plugins/aves_report_console|g' "$PUBSPEC_PATH"
flutter pub get
./flutterw pub get

View file

@ -5,9 +5,9 @@ fi
PUBSPEC_PATH="pubspec.yaml"
flutter clean
./flutterw clean
sed -i 's|plugins/aves_services_.*|plugins/aves_services_google|g' "$PUBSPEC_PATH"
sed -i 's|plugins/aves_report_.*|plugins/aves_report_console|g' "$PUBSPEC_PATH"
flutter pub get
./flutterw pub get

View file

@ -5,9 +5,9 @@ fi
PUBSPEC_PATH="pubspec.yaml"
flutter clean
./flutterw clean
sed -i 's|plugins/aves_services_.*|plugins/aves_services_none|g' "$PUBSPEC_PATH"
sed -i 's|plugins/aves_report_.*|plugins/aves_report_console|g' "$PUBSPEC_PATH"
flutter pub get
./flutterw pub get

View file

@ -5,9 +5,9 @@ fi
PUBSPEC_PATH="pubspec.yaml"
flutter clean
./flutterw clean
sed -i 's|plugins/aves_services_.*|plugins/aves_services_google|g' "$PUBSPEC_PATH"
sed -i 's|plugins/aves_report_.*|plugins/aves_report_crashlytics|g' "$PUBSPEC_PATH"
flutter pub get
./flutterw pub get

View file

@ -3,12 +3,12 @@ if [ ! -d "scripts" ]; then
cd ..
fi
flutter pub get
./flutterw pub get
cd plugins || exit
for plugin in $(ls -d *); do
cd $plugin
flutter pub get
../../flutterw pub get
cd ..
done
cd ..

View file

@ -3,12 +3,12 @@ if [ ! -d "scripts" ]; then
cd ..
fi
flutter pub upgrade
./flutterw pub upgrade
cd plugins || exit
for plugin in $(ls -d *); do
cd $plugin
flutter pub upgrade
../../flutterw pub upgrade
cd ..
done
cd ..

View file

@ -1,10 +1,15 @@
#!/bin/bash
FILE_PATH="../lib/flutter_version.dart"
if [ ! -d "scripts" ]; then
cd ..
fi
FILE_PATH="lib/flutter_version.dart"
rm "$FILE_PATH"
echo "Updating flutter_version.dart:"
{
echo "const Map<String, String> version = "
flutter --version --machine
./flutterw --version --machine
echo ";"
} >> "$FILE_PATH"
cat "$FILE_PATH"