create secret script & configurations added for Actions

This commit is contained in:
Kingkor Roy Tirtho 2022-03-17 09:38:05 +06:00
parent c4c9fd7ac2
commit b090816bfd
5 changed files with 37 additions and 1 deletions

View File

@ -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

6
.gitignore vendored
View File

@ -64,3 +64,9 @@ app.*.map.json
installer.exe
/choco-struct/tools/*.exe
# secrets
*.env
lib/models/generated_secrets.dart
help.txt
secrets.json

19
bin/create-secrets.dart Normal file
View File

@ -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<Map<String, dynamic>> secrets = ${env["SECRET"]};");
}

View File

@ -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:

View File

@ -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