Bump version

This commit is contained in:
sardelka9515
2022-10-15 15:54:46 +08:00
parent d0b6bbaa3a
commit d7c0abdfc2
5 changed files with 19 additions and 9 deletions

View File

@ -1,6 +1,7 @@
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
using LemonUI.Menus; using LemonUI.Menus;
using RageCoop.Client.Scripting; using RageCoop.Client.Scripting;
using RageCoop.Core;
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
@ -31,6 +32,11 @@ namespace RageCoop.Client.Menus
private static void StartUpdate(object sender, EventArgs e) private static void StartUpdate(object sender, EventArgs e)
{ {
if (CoreUtils.GetLatestVersion() < Main.Version)
{
GTA.UI.Notification.Show("Local version is newer than remote version, update can't continue");
return;
}
IsUpdating = true; IsUpdating = true;
Menu.Clear(); Menu.Clear();
Menu.Add(_updatingItem); Menu.Add(_updatingItem);

View File

@ -16,7 +16,7 @@ using System.Resources;
// Version informationr( // Version informationr(
[assembly: AssemblyVersion("1.5.4.333")] [assembly: AssemblyVersion("1.5.4.334")]
[assembly: AssemblyFileVersion("1.5.4.333")] [assembly: AssemblyFileVersion("1.5.4.334")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )] [assembly: NeutralResourcesLanguageAttribute( "en-US" )]

View File

@ -34,6 +34,14 @@ namespace RageCoop.Core
"ScriptHookVDotNet3", "ScriptHookVDotNet3",
"ScriptHookVDotNet" "ScriptHookVDotNet"
}; };
public static Version GetLatestVersion(string branch = "dev-nightly")
{
var url = $"https://raw.githubusercontent.com/RAGECOOP/RAGECOOP-V/{branch}/RageCoop.Server/Properties/AssemblyInfo.cs";
var versionLine = HttpHelper.DownloadString(url).Split(new char[] {'\n'}, StringSplitOptions.RemoveEmptyEntries).Where(x => x.Contains("[assembly: AssemblyVersion(")).First();
var start = versionLine.IndexOf('\"') + 1;
var end = versionLine.LastIndexOf('\"');
return Version.Parse(versionLine.Substring(start, end - start));
}
public static bool CanBeIgnored(this string name) public static bool CanBeIgnored(this string name)
{ {
return ToIgnore.Contains(Path.GetFileNameWithoutExtension(name)); return ToIgnore.Contains(Path.GetFileNameWithoutExtension(name));

View File

@ -17,7 +17,6 @@ namespace RageCoop.Server
{ {
public partial class Server public partial class Server
{ {
private const string _versionURL = "https://raw.githubusercontent.com/RAGECOOP/RAGECOOP-V/main/RageCoop.Server/Properties/AssemblyInfo.cs";
private void SendPlayerUpdate() private void SendPlayerUpdate()
{ {
foreach (var c in ClientsByNetHandle.Values.ToArray()) foreach (var c in ClientsByNetHandle.Values.ToArray())
@ -148,10 +147,7 @@ namespace RageCoop.Server
{ {
try try
{ {
var versionLine = HttpHelper.DownloadString(_versionURL).Split('\n', StringSplitOptions.RemoveEmptyEntries).Where(x => x.Contains("[assembly: AssemblyVersion(")).First(); var latest = CoreUtils.GetLatestVersion();
var start = versionLine.IndexOf('\"') + 1;
var end = versionLine.LastIndexOf('\"');
var latest = Version.Parse(versionLine.AsSpan(start, end - start));
if (latest <= Version) { return; } if (latest <= Version) { return; }
// wait ten minutes for the build to complete // wait ten minutes for the build to complete

View File

@ -15,7 +15,7 @@ using System.Resources;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Version information // Version information
[assembly: AssemblyVersion("1.5.4.105")] [assembly: AssemblyVersion("1.5.4.106")]
[assembly: AssemblyFileVersion("1.5.4.105")] [assembly: AssemblyFileVersion("1.5.4.106")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )] [assembly: NeutralResourcesLanguageAttribute( "en-US" )]