-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
267 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using Avalonia; | ||
|
||
namespace Pitago.Mac | ||
namespace Pitago | ||
{ | ||
class Program | ||
{ | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using Avalonia; | ||
|
||
namespace Pitago.Win | ||
namespace Pitago | ||
{ | ||
class Program | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Pitago.Constants | ||
{ | ||
public static class Info | ||
{ | ||
|
||
/// <summary> | ||
/// Link to the newest version txt on Github | ||
/// </summary> | ||
public const string NewestVersionUrl = | ||
#if BETA | ||
"https://raw.githubusercontent.com/help-14/pitago/main/version/beta.txt"; | ||
#else | ||
"https://raw.githubusercontent.com/help-14/pitago/main/version/stable.txt"; | ||
#endif | ||
|
||
/// <summary> | ||
/// Link to download the newest version | ||
/// </summary> | ||
public const string DownloadUrl = "https://github.com/help-14/pitago/releases"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Net.NetworkInformation; | ||
|
||
namespace Pitago.Utils | ||
{ | ||
public static class Network | ||
{ | ||
|
||
/// <summary> | ||
/// Check if the computer is connected to the internet | ||
/// </summary> | ||
/// <returns>bool</returns> | ||
public static bool IsConnected() | ||
{ | ||
return NetworkInterface.GetIsNetworkAvailable(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
|
||
namespace Pitago.Utils | ||
{ | ||
public static class Update | ||
{ | ||
|
||
/// <summary> | ||
/// Return current version from app assembly | ||
/// </summary> | ||
/// <returns>Version?</returns> | ||
public static Version? CurrentVersion() | ||
{ | ||
return Assembly.GetExecutingAssembly().GetName().Version; | ||
} | ||
|
||
/// <summary> | ||
/// Return newest version from Github | ||
/// </summary> | ||
/// <returns>Task<Version?></returns> | ||
public static async Task<Version?> NewestVersion() | ||
{ | ||
try | ||
{ | ||
var http = new HttpClient(); | ||
var result = await http.GetStringAsync(Constants.Info.NewestVersionUrl); | ||
if (string.IsNullOrEmpty(result)) return null; | ||
return new Version(result); | ||
} catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex.Message); | ||
return null; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Check if newest version is greater than current version | ||
/// </summary> | ||
/// <returns>Task<bool></returns> | ||
public static async Task<bool> CanUpdate() | ||
{ | ||
if (!Network.IsConnected()) return false; | ||
|
||
var currentVersion = CurrentVersion(); | ||
if (currentVersion == null) return true; | ||
var newestVersion = await NewestVersion(); | ||
if(newestVersion == null) return false; | ||
return newestVersion.Major > currentVersion.Major || | ||
(newestVersion.Major == currentVersion.Major && newestVersion.Minor > currentVersion.Minor) || | ||
(newestVersion.Major == currentVersion.Major && newestVersion.Minor == currentVersion.Minor && newestVersion.Build > currentVersion.Build); | ||
} | ||
|
||
/// <summary> | ||
/// Run update task | ||
/// For now, open download link for the newest version | ||
/// </summary> | ||
public static void RunUpdate() | ||
{ | ||
Process.Start(new ProcessStartInfo | ||
{ | ||
FileName = Constants.Info.DownloadUrl, | ||
UseShellExecute = true | ||
}); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dotnet publish .\Pitago.Win\Pitago.Win.csproj -c Release --runtime win-x64 --self-contained true --output .\Pitago.Win\bin\Release\x64 | ||
|
||
dotnet publish .\Pitago.Win\Pitago.Win.csproj -c Release --runtime win-x86 --self-contained true --output .\Pitago.Win\bin\Release\x86 | ||
|
||
dotnet publish .\Pitago.Win\Pitago.Win.csproj -c Release --runtime win-arm64 --self-contained true --output .\Pitago.Win\bin\Release\arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
dotnet publish .\Pitago.Linux\Pitago.Linux.csproj -c Release --runtime linux-x64 --self-contained true --output .\Pitago.Linux\bin\Release\x64 | ||
dotnet publish .\Pitago.Linux\Pitago.Linux.csproj -c Release --runtime linux-x86 --self-contained true --output .\Pitago.Linux\bin\Release\x86 | ||
dotnet publish .\Pitago.Linux\Pitago.Linux.csproj -c Release --runtime linux-arm --self-contained true --output .\Pitago.Linux\bin\Release\arm | ||
dotnet publish .\Pitago.Linux\Pitago.Linux.csproj -c Release --runtime linux-arm64 --self-contained true --output .\Pitago.Linux\bin\Release\arm64 | ||
|
||
#dotnet workload install macos | ||
#dotnet publish .\Pitago.Mac\Pitago.Mac.csproj -c Release --runtime osx-x64 --self-contained true --output .\Pitago.Mac\bin\Release\x64 | ||
#dotnet publish .\Pitago.Mac\Pitago.Mac.csproj -c Release --runtime osx.12-arm64 --self-contained true --output .\Pitago.Mac\bin\Release\arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.