diff --git a/lib/apis/github_api.dart b/lib/apis/github_api.dart index 991b4a4..0452f1a 100644 --- a/lib/apis/github_api.dart +++ b/lib/apis/github_api.dart @@ -6,9 +6,10 @@ class GithubApi { static const baseUrl = "https://api.github.com"; static Future getLatestTagName() async { - final response = await http.get(Uri.parse("$baseUrl/repos/Nutcake/ReCon/releases/latest")); + final response = await http.get(Uri.parse("$baseUrl/repos/Nutcake/ReCon/releases?per_page=1")); if (response.statusCode != 200) return ""; - final body = jsonDecode(response.body); - return body["tag_name"] ?? ""; + final body = jsonDecode(response.body) as List; + if (body.isEmpty) return ""; + return body.first["tag_name"] ?? ""; } } \ No newline at end of file diff --git a/lib/models/sem_ver.dart b/lib/models/sem_ver.dart index 995d67a..2d1f015 100644 --- a/lib/models/sem_ver.dart +++ b/lib/models/sem_ver.dart @@ -1,12 +1,13 @@ class SemVer { static final RegExp _versionMatcher = RegExp(r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"); - static final RegExp _characterFilter = RegExp(r"[a-z]"); + static final RegExp _characterFilter = RegExp(r"^[a-zA-Z]+"); final int major; final int minor; final int patch; + final String? label; - SemVer({required this.major, required this.minor, required this.patch}); + SemVer({required this.major, required this.minor, required this.patch, this.label}); factory SemVer.fromString(String str) { str = str.replaceAll(_characterFilter, ""); @@ -19,6 +20,7 @@ class SemVer { major: int.parse(match.group(1)!), minor: int.parse(match.group(2) ?? "0"), patch: int.parse(match.group(3) ?? "0"), + label: match.group(4), ); } @@ -38,7 +40,7 @@ class SemVer { @override String toString() { - return "$major.$minor.$patch"; + return "$major.$minor.$patch${label == null ? "" : "-$label"}"; } @override @@ -48,10 +50,11 @@ class SemVer { runtimeType == other.runtimeType && major == other.major && minor == other.minor && - patch == other.patch; + patch == other.patch && + label == other.label; @override - int get hashCode => major.hashCode ^ minor.hashCode ^ patch.hashCode; + int get hashCode => major.hashCode ^ minor.hashCode ^ patch.hashCode ^ label.hashCode; bool operator >(SemVer other) { if (major > other.major || (major == other.major && minor > other.minor) || (major == other.major && minor == other.minor && patch > other.patch)) { diff --git a/pubspec.yaml b/pubspec.yaml index 3835209..0da794f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.9.1+1 +version: 0.9.2-beta+1 environment: sdk: '>=3.0.1'