diff --git a/.github/workflows/spotube-nightly.yml b/.github/workflows/spotube-nightly.yml index a73b4be7..bed8dacb 100644 --- a/.github/workflows/spotube-nightly.yml +++ b/.github/workflows/spotube-nightly.yml @@ -28,7 +28,7 @@ jobs: curl -sS https://webi.sh/yq | sh yq -i '.version |= sub("\+\d+", "-nightly-")' pubspec.yaml yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - echo '${{ secrets.DOT_ENV }}' > .env + echo '${{ secrets.DOTENV_NIGHTLY }}' > .env flutter config --enable-linux-desktop flutter pub get dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' @@ -64,7 +64,7 @@ jobs: curl -sS https://webi.sh/yq | sh yq -i '.version |= sub("\+\d+", "-nightly-")' pubspec.yaml yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - echo '${{ secrets.DOT_ENV }}' > .env + echo '${{ secrets.DOTENV_NIGHTLY }}' > .env flutter pub get dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' echo '${{ secrets.KEYSTORE }}' | base64 --decode > android/app/upload-keystore.jks @@ -95,7 +95,7 @@ jobs: yq -i '.version |= sub("\+\d+", "-nightly-")' pubspec.yaml yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.GITHUB_RUN_NUMBER }}/" windows/runner/Runner.rc - echo '${{ secrets.DOT_ENV }}' > .env + echo '${{ secrets.DOTENV_NIGHTLY }}' > .env flutter config --enable-windows-desktop flutter pub get dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' @@ -123,7 +123,7 @@ jobs: - run: brew install yq - run: yq -i '.version |= sub("\+\d+", "-nightly-")' pubspec.yaml - run: yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - - run: echo '${{ secrets.DOT_ENV }}' > .env + - run: echo '${{ secrets.DOTENV_NIGHTLY }}' > .env - run: flutter config --enable-macos-desktop - run: flutter pub get - run: dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' diff --git a/.github/workflows/spotube-release.yml b/.github/workflows/spotube-release.yml index 11045c7d..4d78d2b5 100644 --- a/.github/workflows/spotube-release.yml +++ b/.github/workflows/spotube-release.yml @@ -31,7 +31,7 @@ jobs: with: cache: true - run: | - echo '${{ secrets.DOT_ENV }}' > .env + echo '${{ secrets.DOTENV_RELEASE }}' > .env flutter config --enable-windows-desktop flutter pub get dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' @@ -73,7 +73,7 @@ jobs: - uses: subosito/flutter-action@v2.8.0 with: cache: true - - run: echo '${{ secrets.DOT_ENV }}' > .env + - run: echo '${{ secrets.DOTENV_RELEASE }}' > .env - run: flutter config --enable-macos-desktop - run: flutter pub get - run: dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' @@ -114,7 +114,7 @@ jobs: # replacing & adding new release version with older version - run: | sed -i 's|%{{APPDATA_RELEASE}}%||' linux/com.github.KRTirtho.Spotube.appdata.xml - echo '${{ secrets.DOT_ENV }}' > .env + echo '${{ secrets.DOTENV_RELEASE }}' > .env - run: | flutter config --enable-linux-desktop @@ -149,7 +149,7 @@ jobs: sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse - run: | - echo '${{ secrets.DOT_ENV }}' > .env + echo '${{ secrets.DOTENV_RELEASE }}' > .env flutter pub get dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' echo '${{ secrets.KEYSTORE }}' | base64 --decode > android/app/upload-keystore.jks diff --git a/lib/collections/env.dart b/lib/collections/env.dart index 0361a7bc..2d3965f4 100644 --- a/lib/collections/env.dart +++ b/lib/collections/env.dart @@ -1,11 +1,15 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; abstract class Env { - static final String pocketbaseUrl = dotenv.get('POCKETBASE_URL'); - static final String username = dotenv.get('USERNAME'); - static final String password = dotenv.get('PASSWORD'); + static final String pocketbaseUrl = + dotenv.get('POCKETBASE_URL', fallback: 'http://localhost:8090'); + static final String username = dotenv.get('USERNAME', fallback: 'root'); + static final String password = dotenv.get('PASSWORD', fallback: '12345678'); static configure() async { - await dotenv.load(fileName: ".env"); + if (kReleaseMode) { + await dotenv.load(fileName: ".env"); + } } }