-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
84 changed files
with
4,773 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ name: Leafy Release CI 🌳 | |
on: | ||
release: | ||
types: [published] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
ReleaseLeafy: | ||
|
@@ -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] | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
17
src/leafy_notes_db/lib/extensions/iterable_extensions.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.