create-secrets is now argv based

This commit is contained in:
Kingkor Roy Tirtho 2022-03-18 13:05:55 +06:00
parent 195f965e24
commit a4b2f06737
2 changed files with 11 additions and 12 deletions

View File

@ -13,14 +13,12 @@ jobs:
- uses: subosito/flutter-action@v2.2.0
with:
cache: true
env:
SECRET: ${{ secrets.SECRET }}
- 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: flutter config --enable-linux-desktop
- run: flutter pub get
- run: dart bin/create-secrets.dart
- run: dart bin/create-secrets.dart ${{ secrets.SECRET }}
- run: flutter clean
- run: flutter build linux
- run: make deb
@ -50,7 +48,7 @@ jobs:
SECRET: ${{ secrets.SECRET }}
- run: flutter config --enable-windows-desktop
- run: flutter pub get
- run: dart bin/create-secrets.dart
- run: dart bin/create-secrets.dart ${{ secrets.SECRET }}
- run: flutter build windows
- run: choco install make -y
- run: make innoinstall
@ -73,7 +71,7 @@ jobs:
SECRET: ${{ secrets.SECRET }}
- run: flutter config --enable-macos-desktop
- run: flutter pub get
- run: dart bin/create-secrets.dart
- run: dart bin/create-secrets.dart ${{ secrets.SECRET }}
- run: flutter build macos
- run: du -sh build/macos/Build/Products/Release/spotube.app
- run: npm install -g appdmg

View File

@ -3,17 +3,18 @@ import 'dart:io';
import 'package:path/path.dart' as path;
void main() async {
final env = Platform.environment;
final bool hasKey = env.containsKey("SECRET");
final val = hasKey ? jsonDecode(env["SECRET"]!) : null;
print("SECRET VALUE: ${env["SECRET"]}");
if (!hasKey || (hasKey && val is! List)) {
void main(List<String> args) async {
if (args.isEmpty) {
throw ArgumentError("Expected an argument but none was passed");
}
final val = jsonDecode(args.first);
if (val is! List) {
throw Exception(
"'SECRET' Environmental Variable isn't configured properly");
}
await File(path.join(
Directory.current.path, "lib/models/generated_secrets.dart"))
.writeAsString("final List<String> secrets = ${env["SECRET"]};");
.writeAsString("final List<String> secrets = ${args.first};");
}