Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nivisi committed Dec 7, 2021
2 parents b5298c7 + bc17eb9 commit 4b44874
Show file tree
Hide file tree
Showing 84 changed files with 4,773 additions and 65 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/leafy_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Leafy CI 🌱
on:
push:
branches: [ develop ]
paths: [ src/** ]

pull_request:

Expand All @@ -29,9 +30,6 @@ jobs:
if: (!github.event.pull_request)
run: echo "APP_VERSION=dev" >> $GITHUB_ENV

- name: Echo Artifact Version
run: echo ${{ env.APP_VERSION }}

- name: Setup Java
uses: actions/setup-java@v1
with:
Expand All @@ -42,6 +40,12 @@ jobs:
with:
channel: 'stable'

- name: Setup Key Store
run: (echo ${{ secrets.KEY_STORE }} | openssl base64 -d -A) > ./android/app/leafy.keystore

- name: Setup Key Properties
run: (echo ${{ secrets.KEY_PROPERTIES }} | openssl base64 -d -A) > ./android/key.properties

- name: Get packages
run: flutter pub get

Expand All @@ -51,10 +55,10 @@ jobs:
- name: Analyze
run: flutter analyze .

- name: Build 🌱
- name: Build APK 🌱
run: flutter build apk --release --build-number "${{ github.run_number }}"

- name: Upload Artifacts
- name: Upload APK
uses: actions/upload-artifact@v1
with:
name: leafy_launcher_${{ env.APP_VERSION }}_build${{ github.run_number }}.apk
Expand Down
48 changes: 33 additions & 15 deletions .github/workflows/leafy_release_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Leafy Release CI 🌳
on:
release:
types: [published]

workflow_dispatch:

jobs:
ReleaseLeafy:
Expand All @@ -22,8 +20,10 @@ jobs:
run: |
echo "APP_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
echo "APK_NAME=leafy${{ github.ref_name }}.apk" >> $GITHUB_ENV
echo "APP_BUNDLE_NAME=leafy${{ github.ref_name }}.aab" >> $GITHUB_ENV
echo "APK_PATH=/home/runner/work/LeafyLauncher/LeafyLauncher/src/build/app/outputs/flutter-apk/" >> $GITHUB_ENV
echo "APP_BUNDLE_PATH=/home/runner/work/LeafyLauncher/LeafyLauncher/src/build/app/outputs/bundle/release/" >> $GITHUB_ENV
- name: Get Release Data
id: get_release_data
uses: actions/[email protected]
Expand Down Expand Up @@ -60,11 +60,12 @@ jobs:
console.log(error);
core.setFailed("Couldnt find the release");
}
- name: Put Release Data to env
run: |
echo "RELEASE_URL=${{ steps.get_release_data.outputs.release_url }}" >> $GITHUB_ENV
echo "RELEASE_ID=${{ steps.get_release_data.outputs.release_id }}" >> $GITHUB_ENV
# echo "RELEASE_NOTES=${{ steps.get_release_data.outputs.release_notes }}" >> $GITHUB_ENV

- name: Setup Java
Expand All @@ -80,37 +81,54 @@ jobs:
- name: Get Flutter packages
run: flutter pub get

- name: Build 🌳
run: flutter build apk --release --build-name "${{ env.APP_VERSION }}"

- name: Rename and Upload Release Asset
- name: Setup Key Store
run: (echo ${{ secrets.KEY_STORE }} | openssl base64 -d -A) > ./android/app/leafy.keystore

- name: Setup Key Properties
run: (echo ${{ secrets.KEY_PROPERTIES }} | openssl base64 -d -A) > ./android/key.properties

- name: Build APK 🌳
run: flutter build apk --release --build-name "${{ env.APP_VERSION }}" --build-number "${{ github.run_number }}"

- name: Build App Bundle 🌳
run: flutter build appbundle --release --build-name "${{ env.APP_VERSION }}" --build-number "${{ github.run_number }}"

- name: Rename and Upload Release Assets
id: upload_release
uses: actions/[email protected]
env:
APK_NAME: ${{ env.APK_NAME }}
APP_BUNDLE_NAME: ${{ env.APP_BUNDLE_NAME }}
RELEASE_ID: ${{ env.RELEASE_ID }}
BUILT_APK_PATH: ${{ env.APK_PATH }}app-release.apk
RENAMED_APK_PATH: ${{ env.APK_PATH }}${{ env.APK_NAME }}
BUILT_APP_BUNDLE_PATH: ${{ env.APP_BUNDLE_PATH }}app-release.aab
RENAMED_APP_BUNDLE_PATH: ${{ env.APP_BUNDLE_PATH }}${{ env.APP_BUNDLE_NAME }}

with:
script: |
const { APK_NAME, RELEASE_ID, BUILT_APK_PATH, RENAMED_APK_PATH } = process.env;
const { APK_NAME, APP_BUNDLE_NAME, RELEASE_ID, BUILT_APK_PATH, RENAMED_APK_PATH, BUILT_APP_BUNDLE_PATH, RENAMED_APP_BUNDLE_PATH } = process.env;
const fs = require('fs');
await fs.promises.rename(BUILT_APK_PATH, RENAMED_APK_PATH)
const assetContentType = "application/octet-stream";
const contentLength = filePath => fs.statSync(filePath).size;
const headers = { 'content-type': assetContentType, 'content-length': contentLength(RENAMED_APK_PATH) };
await fs.promises.rename(BUILT_APP_BUNDLE_PATH, RENAMED_APP_BUNDLE_PATH)
const uploadAssetResponse = await github.repos.uploadReleaseAsset({
const uploadApkResponse = await github.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: RELEASE_ID,
name: APK_NAME,
data: await fs.readFileSync(RENAMED_APK_PATH)
});
const uploadAppBundleResponse = await github.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: RELEASE_ID,
name: APP_BUNDLE_NAME,
data: await fs.readFileSync(RENAMED_APP_BUNDLE_PATH)
});
- name: Notify Telegram Chat
uses: appleboy/telegram-action@master
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A new Android Launcher built with Flutter.
<!-- References -->
[code-factor--badge-url]: https://www.codefactor.io/repository/github/nivisi/leafylauncher/badge?s=12760533a8fde6261b394c1023a0e4e8e3ca6a7a
[code-factor-app-url]: https://www.codefactor.io/repository/github/nivisi/leafylauncher
[app-version-img]: https://img.shields.io/badge/version-1.1.4_beta-green
[app-version-img]: https://img.shields.io/badge/version-1.2.0_beta-green

[ci-badge-url]: https://github.com/nivisi/LeafyLauncher/actions/workflows/leafy_ci.yml/badge.svg?branch=develop
[ci-url]: https://github.com/nivisi/LeafyLauncher/actions/workflows/leafy_ci.yml
Expand Down
4 changes: 3 additions & 1 deletion src/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ analyzer:
todo: ignore
no_logic_in_create_state: ignore
invariant_booleans: ignore
avoid_classes_with_only_static_members: ignore
avoid_classes_with_only_static_members: ignore
exclude:
[lib/*.g.dart]
20 changes: 17 additions & 3 deletions src/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keyProperties = new Properties()
def keyPropertiesFile = rootProject.file('key.properties')
if (keyPropertiesFile.exists()) {
keyPropertiesFile.withReader('UTF-8') { reader ->
keyProperties.load(reader)
}
}

android {
compileSdkVersion 30

Expand All @@ -33,20 +41,26 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.nivisi.leafy_launcher"
minSdkVersion 24
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

signingConfigs {
release {
keyAlias keyProperties['keyAlias']
keyPassword keyProperties['keyPassword']
storeFile keyProperties['storeFile'] ? file(keyProperties['storeFile']) : null
storePassword keyProperties['storePassword']
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
}
}
Expand Down
49 changes: 49 additions & 0 deletions src/leafy_notes_db/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
include: package:lint/analysis_options.yaml

linter:
rules:
avoid_classes_with_only_static_methods: false
await_only_futures: true

# Temporary
public_member_api_docs: false

type_annotate_public_apis: false

# This looks more organized.
sort_constructors_first: true

# This looks more organized.
sort_pub_dependencies: true

# Single qoutes looks prettier and more compact.
prefer_single_quotes: true

# Sometimes it just doesn't make sense.
lines_longer_than_80_chars: true

# Make variables "var" only when really needed.
prefer_final_locals: true

# This doesn't make the code more readable.
# It forces us not to use
# final variable = 5;
# But to use
# final int variable = 5;
always_specify_types: false

analyzer:
errors:
prefer_const_constructors: error
missing_return: error
missing_required_param: error
directives_ordering: error
unnecessary_new: error
unnecessary_this: error
unnecessary_const: error
todo: ignore
no_logic_in_create_state: ignore
invariant_booleans: ignore
avoid_classes_with_only_static_members: ignore
exclude:
[lib/**.g.dart]
17 changes: 17 additions & 0 deletions src/leafy_notes_db/lib/extensions/iterable_extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
extension IterableExtensions<T> on Iterable<T> {
T? firstOrNull() {
if (length > 0) {
return first;
}

return null;
}

T? firstWhereOrNull(bool Function(T item) condition) {
if (length > 0) {
return firstWhere(condition);
}

return null;
}
}
17 changes: 17 additions & 0 deletions src/leafy_notes_db/lib/extensions/map_extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ignore_for_file: avoid_catching_errors

extension MapExtensions<TKey, TValue> on Map<TKey, TValue> {
TValue? firstWhereKeyOrNull(bool Function(TKey item) condition) {
if (keys.isNotEmpty) {
try {
final key = keys.firstWhere(condition);

return this[key];
} on Error {
return null;
}
}

return null;
}
}
41 changes: 41 additions & 0 deletions src/leafy_notes_db/lib/leafy_notes_database.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
library leafy_notes_database;

import 'dart:async';

// ignore: depend_on_referenced_packages
import 'package:get/get.dart';
import 'package:leafy_notes_database/src/leafy_notes_db.dart';
import 'package:leafy_notes_database/src/models/folder/model/folder_converter.dart';

import 'src/models.dart';
import 'src/models/folder/repository/folder_repository_impl.dart';
import 'src/models/note/repository/note_repository_impl.dart';
import 'src/repositories/repositories.dart';

export 'src/models.dart';
export 'src/one_to_manys.dart';
export 'src/repositories/repositories.dart';

class LeafyNotesLibrary {
static final Completer _completer = Completer();

static Future get ensureInitialized => _completer.future;

static late final FolderModel defaultFolder;

static Future _prepareDatabase(FolderRepositoryImpl folderRepository) async {
final defaultFolderDb =
await LeafyNotesDb.folderDao.createDefaultFolderIfNeeded();

folderRepository.defaultFolder = folderModelFromDb(defaultFolderDb);
}

static void initialize(GetInterface get) {
get.put<NoteRepository>(NoteRepositoryImpl());
final foldersRepository = get.put<FolderRepository>(FolderRepositoryImpl())
as FolderRepositoryImpl;

_prepareDatabase(foldersRepository)
.whenComplete(() => _completer.complete());
}
}
4 changes: 4 additions & 0 deletions src/leafy_notes_db/lib/src/daos.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library daos;

export 'models/folder/dao/folder_dao.dart';
export 'models/note/dao/note_dao.dart';
26 changes: 26 additions & 0 deletions src/leafy_notes_db/lib/src/leafy_notes_db.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:moor_flutter/moor_flutter.dart';

import 'daos.dart';
import 'tables.dart';

part 'leafy_notes_db.g.dart';

// ignore: non_constant_identifier_names
final LeafyNotesDb = LeafyNotesDatabase();

@UseMoor(
tables: [Notes, Folders],
daos: [NoteDao, FolderDao],
)
class LeafyNotesDatabase extends _$LeafyNotesDatabase {
LeafyNotesDatabase()
: super(
FlutterQueryExecutor.inDatabaseFolder(
path: 'leafy_notes.sqlite',
logStatements: true,
),
);

@override
int get schemaVersion => 1;
}
Loading

0 comments on commit 4b44874

Please sign in to comment.