diff --git a/.github/workflows/flutter-build.yml b/.github/workflows/flutter-build.yml index d678a145..15a2ab5a 100644 --- a/.github/workflows/flutter-build.yml +++ b/.github/workflows/flutter-build.yml @@ -57,13 +57,11 @@ jobs: - run: choco install make -y - run: make innoinstall - run: make inno - - run: make choco - uses: actions/upload-artifact@v2 with: name: Spotube-Windows-Bundle path: | build/installer/Spotube-windows-x86_64-setup.exe - build/spotube.*.nupkg build_macos: runs-on: macos-11 steps: diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml new file mode 100644 index 00000000..2e2d95ab --- /dev/null +++ b/.github/workflows/release-build.yml @@ -0,0 +1,73 @@ +name: Spotube Build & Release +on: + release: + types: + - published + +jobs: + publish_chocolatey: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + ref: release-test + - uses: actions/checkout@v3 + with: + repository: KRTirtho/flutter_distributor + ref: deb-implementation + path: build/flutter_distributor + + # bump chocolatey related versions + env: + RELEASE_VERSION: ${{ github.event.release.tag_name }} + + - name: Replace Version in files + run: | + sed -i "s/%{{SPOTUBE_VERSION}}%/$RELEASE_VERSION/" windows/runner/Runner.rc + sed -i "s/%{{SPOTUBE_VERSION}}%/$RELEASE_VERSION/" choco-struct/tools/VERIFICATION.txt + sed -i "s/%{{SPOTUBE_VERSION}}%/$RELEASE_VERSION/" choco-struct/spotube.nuspec + + - name: Build Windows Executable + uses: subosito/flutter-action@v2.2.0 + with: + cache: true + run: | + choco install sed make -y + flutter config --enable-windows-desktop + flutter pub get + dart bin/create-secrets.dart '${{ secrets.LYRICS_SECRET }}' '${{ secrets.SPOTIFY_SECRET }}' + make innoinstall + dart pub global activate --source path build/flutter_distributor/packages/flutter_distributor + flutter_distributor package --platform=windows --target=exe --skip-clean + + - name: Create Chocolatey Package + # setting the sha256 hash for new bundle + run: | + Set-Variable -Name HASH -Value (Get-FileHash dist\$RELEASE_VERSION\spotube-$RELEASE_VERSION-windows.exe).Hash + sed -i "s/%{{WIN_SHA256}}%/$HASH/" choco-struct/tools/VERIFICATION.txt + make VERSION=$RELEASE_VERSION choco + + - name: Rename the artifacts + run: | + Rename-Item -Path dist/$RELEASE_VERSION/spotube.$RELEASE_VERSION.nupkg -NewName Spotube-windows-x86_64.nupkg + Rename-Item -Path dist/$RELEASE_VERSION/spotube-$RELEASE_VERSION-windows.exe Spotube-windows-x86_64-setup.exe + + - name: Upload release binary + uses: meeDamian/github-release@2.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.event.release.tag_name }} + files: dist/$RELEASE_VERSION + + - name: Publish to Chocolatey Repository + run: | + choco apikey -k ${{ secrets.CHOCO_API_KEY }} -s https://push.chocolatey.org/ + echo 'published to community.chocolatey.org' + + # choco push dist/$RELEASE_VERSION/spotube.$RELEASE_VERSION.nupkg + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: Spotube-Windows-Bundle + path: dist/$RELEASE_VERSION diff --git a/Makefile b/Makefile index e317babc..60c01d15 100644 --- a/Makefile +++ b/Makefile @@ -47,8 +47,8 @@ inno: powershell build\iscc\iscc.exe scripts\windows-setup-creator.iss choco: - powershell cp build\installer\Spotube-windows-x86_64-setup.exe choco-struct\tools - powershell choco pack .\choco-struct\spotube.nuspec --outputdirectory build + powershell cp dist\${VERSION}\spotube-${VERSION}-windows.exe choco-struct\tools + powershell choco pack .\choco-struct\spotube.nuspec --outputdirectory dist\${VERSION}\ apk: mv build/app/outputs/apk/release/app-release.apk build/Spotube-android-all-arch.apk diff --git a/choco-struct/spotube.nuspec b/choco-struct/spotube.nuspec index 5247617f..0f09c391 100644 --- a/choco-struct/spotube.nuspec +++ b/choco-struct/spotube.nuspec @@ -4,7 +4,7 @@ spotube - 2.0.0 + %{{SPOTUBE_VERSION}}% https://github.com/KRTirtho/spotube/tree/master/choco-struct Kingkor Roy Tirtho @@ -39,9 +39,9 @@ - Lyrics - Downloadable track (WIP) - https://github.com/KRTirtho/spotube/releases/tag/v2.0.0 + https://github.com/KRTirtho/spotube/releases/tag/v%{{SPOTUBE_VERSION}}% - + \ No newline at end of file diff --git a/choco-struct/tools/VERIFICATION.txt b/choco-struct/tools/VERIFICATION.txt index f2f35d4f..8b4f01af 100644 --- a/choco-struct/tools/VERIFICATION.txt +++ b/choco-struct/tools/VERIFICATION.txt @@ -7,17 +7,17 @@ in verifying that this package's contents are trustworthy. Please go to releases page https://github.com/KRTirtho/spotube/releases -Download same version as this choco package (example for v2.0.0) -https://github.com/KRTirtho/spotube/releases/tag/v2.0.0 +Download same version as this choco package (example for v%{{SPOTUBE_VERSION}}%) +https://github.com/KRTirtho/spotube/releases/tag/v%{{SPOTUBE_VERSION}}% 1. get hashes. Run: powershell -command Get-FileHash tools\Spotube-windows-x86_64-setup.exe 2. The checksums should match the following: --- -Version Hashes for v2.0.0 +Version Hashes for v%{{SPOTUBE_VERSION}}% Algorithm Hash Path --------- ---- ---- -SHA256 0b60f232a8c17686b7751a36787c9490b35ff6f3139955c72a11c8db19317a91 tools\Spotube-windows-x86_64-setup.exe \ No newline at end of file +SHA256 %{{WIN_SHA256}}% tools\Spotube-windows-x86_64-setup.exe \ No newline at end of file diff --git a/lib/components/Home/Home.dart b/lib/components/Home/Home.dart index 2b0de63f..40d984a0 100644 --- a/lib/components/Home/Home.dart +++ b/lib/components/Home/Home.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:bitsdojo_window/bitsdojo_window.dart'; import 'package:flutter/material.dart' hide Page; +import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; @@ -191,6 +192,19 @@ class Home extends HookConsumerWidget { ], )); + final brightness = Theme.of(context).brightness; + + useEffect(() { + SystemChrome.setSystemUIOverlayStyle( + SystemUiOverlayStyle( + statusBarColor: brightness == Brightness.dark + ? Colors.blueGrey[900] + : Colors.white, // status bar color + ), + ); + return null; + }, [brightness]); + return SafeArea( child: Scaffold( body: Column( diff --git a/lib/components/Lyrics/Lyrics.dart b/lib/components/Lyrics/Lyrics.dart index 8582ff5c..4a3a632a 100644 --- a/lib/components/Lyrics/Lyrics.dart +++ b/lib/components/Lyrics/Lyrics.dart @@ -18,14 +18,14 @@ class Lyrics extends HookConsumerWidget { UserPreferences userPreferences = ref.watch(userPreferencesProvider); final lyrics = useState({}); - final lyricsFuture = useMemoized(() { + final lyricsFuture = useMemoized(() async { if (playback.currentTrack == null || userPreferences.geniusAccessToken.isEmpty || (playback.currentTrack?.id != null && playback.currentTrack?.id == lyrics.value["id"])) { return null; } - return getLyrics( + final lyricsStr = await getLyrics( playback.currentTrack!.name!, playback.currentTrack!.artists ?.map((s) => s.name) @@ -35,6 +35,8 @@ class Lyrics extends HookConsumerWidget { apiKey: userPreferences.geniusAccessToken, optimizeQuery: true, ); + if (lyricsStr == null) return Future.error("No lyrics found"); + return lyricsStr; }, [playback.currentTrack, userPreferences.geniusAccessToken]); final lyricsSnapshot = useFuture(lyricsFuture); @@ -63,6 +65,17 @@ class Lyrics extends HookConsumerWidget { final breakpoint = useBreakpoints(); if (lyrics.value["lyrics"] == null && playback.currentTrack != null) { + if (lyricsSnapshot.hasError) { + return Expanded( + child: Center( + child: Text( + "Sorry, no Lyrics were found for `${playback.currentTrack?.name}` :'(", + style: Theme.of(context).textTheme.headline4, + textAlign: TextAlign.center, + ), + ), + ); + } return const Expanded( child: Center( child: CircularProgressIndicator.adaptive(), diff --git a/lib/components/Player/PlayerView.dart b/lib/components/Player/PlayerView.dart index 3ffd7060..0d5893e5 100644 --- a/lib/components/Player/PlayerView.dart +++ b/lib/components/Player/PlayerView.dart @@ -1,5 +1,6 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; @@ -45,6 +46,15 @@ class PlayerView extends HookConsumerWidget { final PaletteColor paletteColor = usePaletteColor(context, albumArt); + useEffect(() { + SystemChrome.setSystemUIOverlayStyle( + SystemUiOverlayStyle( + statusBarColor: paletteColor.color, // status bar color + ), + ); + return null; + }, [paletteColor.color]); + return SafeArea( child: Scaffold( appBar: const PageWindowTitleBar( diff --git a/lib/main.dart b/lib/main.dart index 8ee33562..61e868ad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -43,10 +43,10 @@ class MyApp extends HookConsumerWidget { MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context, ref) { - var themeMode = + final themeMode = ref.watch(userPreferencesProvider.select((s) => s.themeMode)); - var player = ref.watch(audioPlayerProvider); - var youtube = ref.watch(youtubeProvider); + final player = ref.watch(audioPlayerProvider); + final youtube = ref.watch(youtubeProvider); useEffect(() { return () { player.dispose(); diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc index cbbd750a..4c36cee9 100644 --- a/windows/runner/Runner.rc +++ b/windows/runner/Runner.rc @@ -69,7 +69,7 @@ IDI_APP_ICON ICON "resources\\icon.ico" #ifdef FLUTTER_BUILD_NAME #define VERSION_AS_STRING #FLUTTER_BUILD_NAME #else -#define VERSION_AS_STRING "2.0.0" +#define VERSION_AS_STRING "%{{SPOTUBE_VERSION}}%" #endif VS_VERSION_INFO VERSIONINFO