mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-09 16:57:31 +00:00
feat: notification about nightly channel update
This commit is contained in:
parent
596a4b5a02
commit
5726de8bbc
6
.github/workflows/spotube-release-binary.yml
vendored
6
.github/workflows/spotube-release-binary.yml
vendored
@ -166,4 +166,8 @@ jobs:
|
|||||||
omitPrereleaseDuringUpdate: true
|
omitPrereleaseDuringUpdate: true
|
||||||
allowUpdates: true
|
allowUpdates: true
|
||||||
artifacts: Spotube-Release-Binaries/*,RELEASE.sha256sum,RELEASE.md5sum
|
artifacts: Spotube-Release-Binaries/*,RELEASE.sha256sum,RELEASE.md5sum
|
||||||
body: 'Build Number: ${{github.run_number}}'
|
body: |
|
||||||
|
Build Number: ${{github.run_number}}
|
||||||
|
|
||||||
|
Nightly release includes newest features but may contain bugs
|
||||||
|
It is preferred to use the stable version unless you know what you're doing
|
||||||
|
|||||||
@ -33,7 +33,7 @@ abstract class Env {
|
|||||||
@EnviedField(varName: "RELEASE_CHANNEL", defaultValue: "nightly")
|
@EnviedField(varName: "RELEASE_CHANNEL", defaultValue: "nightly")
|
||||||
static final String _releaseChannel = _Env._releaseChannel;
|
static final String _releaseChannel = _Env._releaseChannel;
|
||||||
|
|
||||||
ReleaseChannel get releaseChannel => _releaseChannel == "stable"
|
static ReleaseChannel get releaseChannel => _releaseChannel == "stable"
|
||||||
? ReleaseChannel.stable
|
? ReleaseChannel.stable
|
||||||
: ReleaseChannel.nightly;
|
: ReleaseChannel.nightly;
|
||||||
|
|
||||||
|
|||||||
@ -5,18 +5,23 @@ import 'package:version/version.dart';
|
|||||||
|
|
||||||
class RootAppUpdateDialog extends StatelessWidget {
|
class RootAppUpdateDialog extends StatelessWidget {
|
||||||
final Version? version;
|
final Version? version;
|
||||||
const RootAppUpdateDialog({super.key, this.version});
|
final int? nightlyBuildNum;
|
||||||
|
|
||||||
|
const RootAppUpdateDialog({super.key, this.version}) : nightlyBuildNum = null;
|
||||||
|
const RootAppUpdateDialog.nightly({super.key, required this.nightlyBuildNum})
|
||||||
|
: version = null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
const url = "https://spotube.krtirtho.dev/downloads";
|
const url = "https://spotube.krtirtho.dev/downloads";
|
||||||
|
const nightlyUrl = "https://spotube.krtirtho.dev/downloads/nightly";
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text("Spotube has an update"),
|
title: const Text("Spotube has an update"),
|
||||||
actions: [
|
actions: [
|
||||||
FilledButton(
|
FilledButton(
|
||||||
child: const Text("Download Now"),
|
child: const Text("Download Now"),
|
||||||
onPressed: () => launchUrlString(
|
onPressed: () => launchUrlString(
|
||||||
url,
|
nightlyBuildNum != null ? nightlyUrl : url,
|
||||||
mode: LaunchMode.externalApplication,
|
mode: LaunchMode.externalApplication,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -24,7 +29,12 @@ class RootAppUpdateDialog extends StatelessWidget {
|
|||||||
content: Column(
|
content: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text("Spotube v$version has been released"),
|
Text(
|
||||||
|
nightlyBuildNum != null
|
||||||
|
? "Spotube Nightly $nightlyBuildNum has been releases"
|
||||||
|
: "Spotube v$version has been released",
|
||||||
|
),
|
||||||
|
if (nightlyBuildNum != null)
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:spotube/collections/assets.gen.dart';
|
import 'package:spotube/collections/assets.gen.dart';
|
||||||
|
import 'package:spotube/collections/env.dart';
|
||||||
import 'package:spotube/components/shared/image/universal_image.dart';
|
import 'package:spotube/components/shared/image/universal_image.dart';
|
||||||
import 'package:spotube/components/shared/links/hyper_link.dart';
|
import 'package:spotube/components/shared/links/hyper_link.dart';
|
||||||
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
import 'package:spotube/components/shared/page_window_title_bar.dart';
|
||||||
@ -72,6 +73,13 @@ class AboutSpotube extends HookConsumerWidget {
|
|||||||
Text("v${packageInfo.version}")
|
Text("v${packageInfo.version}")
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
Text(context.l10n.channel),
|
||||||
|
colon,
|
||||||
|
Text(Env.releaseChannel.name)
|
||||||
|
],
|
||||||
|
),
|
||||||
TableRow(
|
TableRow(
|
||||||
children: [
|
children: [
|
||||||
Text(context.l10n.build_number),
|
Text(context.l10n.build_number),
|
||||||
|
|||||||
@ -335,9 +335,35 @@ abstract class ServiceUtils {
|
|||||||
) async {
|
) async {
|
||||||
if (!Env.enableUpdateChecker) return;
|
if (!Env.enableUpdateChecker) return;
|
||||||
if (!ref.read(userPreferencesProvider.select((s) => s.checkUpdate))) return;
|
if (!ref.read(userPreferencesProvider.select((s) => s.checkUpdate))) return;
|
||||||
|
|
||||||
final packageInfo = await PackageInfo.fromPlatform();
|
final packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
|
||||||
|
if (Env.releaseChannel == ReleaseChannel.nightly) {
|
||||||
|
final value = await http.get(
|
||||||
|
Uri.parse(
|
||||||
|
"https://api.github.com/repos/KRTirtho/spotube/releases/tags/nightly",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final body = jsonDecode(value.body)["body"] as String;
|
||||||
|
|
||||||
|
final buildNum = int.tryParse(
|
||||||
|
RegExp(r'Build Number: (\d+)').firstMatch(body)?.group(1) ?? '0',
|
||||||
|
) ??
|
||||||
|
0;
|
||||||
|
|
||||||
|
if (buildNum <= int.parse(packageInfo.buildNumber) || !context.mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: true,
|
||||||
|
barrierColor: Colors.black26,
|
||||||
|
builder: (context) {
|
||||||
|
return RootAppUpdateDialog.nightly(nightlyBuildNum: buildNum);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
final value = await http.get(
|
final value = await http.get(
|
||||||
Uri.parse(
|
Uri.parse(
|
||||||
"https://api.github.com/repos/KRTirtho/spotube/releases/latest",
|
"https://api.github.com/repos/KRTirtho/spotube/releases/latest",
|
||||||
@ -348,7 +374,8 @@ abstract class ServiceUtils {
|
|||||||
final currentVersion = packageInfo.version == "Unknown"
|
final currentVersion = packageInfo.version == "Unknown"
|
||||||
? null
|
? null
|
||||||
: Version.parse(packageInfo.version);
|
: Version.parse(packageInfo.version);
|
||||||
final latestVersion = tagName == "nightly" ? null : Version.parse(tagName);
|
final latestVersion =
|
||||||
|
tagName == "nightly" ? null : Version.parse(tagName);
|
||||||
|
|
||||||
if (currentVersion == null ||
|
if (currentVersion == null ||
|
||||||
latestVersion == null ||
|
latestVersion == null ||
|
||||||
@ -367,3 +394,4 @@ abstract class ServiceUtils {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user