From b090816bfd0ee6d6182c11a41d4e0058d6fb414e Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Thu, 17 Mar 2022 09:38:05 +0600 Subject: [PATCH] create secret script & configurations added for Actions --- .github/workflows/flutter-build.yml | 3 +++ .gitignore | 8 +++++++- bin/create-secrets.dart | 19 +++++++++++++++++++ pubspec.lock | 7 +++++++ pubspec.yaml | 1 + 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 bin/create-secrets.dart diff --git a/.github/workflows/flutter-build.yml b/.github/workflows/flutter-build.yml index f4eff8ba..84e985e2 100644 --- a/.github/workflows/flutter-build.yml +++ b/.github/workflows/flutter-build.yml @@ -16,6 +16,7 @@ jobs: - run: | sudo apt-get update -y sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make libwebkit2gtk-4.0-dev keybinder-3.0 python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse + - run: dart bin/create-secrets.dart - run: flutter config --enable-linux-desktop - run: flutter pub get - run: flutter clean @@ -40,6 +41,7 @@ jobs: - uses: subosito/flutter-action@v2.2.0 with: cache: true + - run: dart bin/create-secrets.dart - run: flutter config --enable-windows-desktop - run: flutter build windows - run: choco install make -y @@ -59,6 +61,7 @@ jobs: - uses: subosito/flutter-action@v2 with: cache: true + - run: dart bin/create-secrets.dart - run: flutter config --enable-macos-desktop - run: flutter build macos - run: du -sh build/macos/Build/Products/Release/spotube.app diff --git a/.gitignore b/.gitignore index 064a8f08..19b426ef 100644 --- a/.gitignore +++ b/.gitignore @@ -63,4 +63,10 @@ app.*.map.json /iscc installer.exe -/choco-struct/tools/*.exe \ No newline at end of file +/choco-struct/tools/*.exe + +# secrets +*.env +lib/models/generated_secrets.dart +help.txt +secrets.json \ No newline at end of file diff --git a/bin/create-secrets.dart b/bin/create-secrets.dart new file mode 100644 index 00000000..634c0bf8 --- /dev/null +++ b/bin/create-secrets.dart @@ -0,0 +1,19 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:path/path.dart' as path; +import 'package:dotenv/dotenv.dart'; + +void main() async { + load(); + final bool hasKey = env.containsKey("SECRET"); + final val = hasKey ? jsonDecode(env["SECRET"]!) : null; + if (!hasKey || (hasKey && val is! Map && val is! List)) { + return; + } + + await File(path.join( + Directory.current.path, "lib/models/generated_secrets.dart")) + .writeAsString( + "final List> secrets = ${env["SECRET"]};"); +} diff --git a/pubspec.lock b/pubspec.lock index 5a3d5be2..25e60ce2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -148,6 +148,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.4" + dotenv: + dependency: "direct dev" + description: + name: dotenv + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" fake_async: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 87dc4d5f..4a4c6510 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,6 +67,7 @@ dev_dependencies: # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^1.0.0 + dotenv: ^3.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec