Skip to content

Commit

Permalink
Added self updating support (through github releases)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoobNotFound committed Mar 7, 2024
1 parent 43d00cb commit 4674cd7
Show file tree
Hide file tree
Showing 13 changed files with 331 additions and 29 deletions.
26 changes: 13 additions & 13 deletions Emerald.App/Emerald.App.Package/Package.WinUI.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,39 +57,39 @@
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<PackageCertificateThumbprint>BA30AECD14618A89C2822FC6912530F0B59E436D</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
<AppInstallerUri>D:\Projects\Emerald\Emerald.App\Emerald.App.Package\AppPackages\</AppInstallerUri>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='SkipOld|x64'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='SkipOld|arm64'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm64'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='SkipOld|x86'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<AppxBundle>Always</AppxBundle>
<AppxBundle>Auto</AppxBundle>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand Down Expand Up @@ -157,10 +157,10 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1">
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview">
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26031-preview">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Emerald.App/Emerald.App.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="Riverside.Emerald"
Publisher="CN=NoobNotFound"
Version="0.7.1.0" />
Version="0.7.8.0" />

<Properties>
<DisplayName>Emerald</DisplayName>
Expand Down
10 changes: 5 additions & 5 deletions Emerald.App/Emerald.App/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Emerald.WinUI.Helpers.AppInstancing;
using Emerald.WinUI.Helpers.Updater;
using Microsoft.UI.Xaml;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.Management.Deployment;
using Windows.Storage;

namespace Emerald.WinUI;
Expand All @@ -10,12 +13,8 @@ public partial class App : Application
{
private readonly SingleInstanceDesktopApp _singleInstanceApp;
public Core.Emerald Launcher { get; private set; } = new();
public Updater Updater { get; private set; } = new();
public ElementTheme ActualTheme => (MainWindow.Content as FrameworkElement).ActualTheme;
public static Task<string> CheckForUpdates()
{
return null;
}

public App()
{
InitializeComponent();
Expand Down Expand Up @@ -66,6 +65,7 @@ private void OnSingleInstanceLaunched(object? sender, SingleInstanceLaunchEventA
if (e.IsFirstLaunch)
{
System.Net.ServicePointManager.DefaultConnectionLimit = 256;
_ = Updater.Initialize();
InitializeMainWindow();
}
else
Expand Down
2 changes: 2 additions & 0 deletions Emerald.App/Emerald.App/DirectResources.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommunityToolkit.WinUI.Helpers;
using Emerald.WinUI.Helpers;
using System.Runtime.InteropServices;
using Windows.UI;

namespace Emerald.WinUI;
Expand All @@ -26,6 +27,7 @@ public static string BuildType
#endif
}
}
public static Architecture Architecture => RuntimeInformation.ProcessArchitecture;

public static string AppVersion
=> $"{SystemInformation.Instance.ApplicationVersion.Major}.{SystemInformation.Instance.ApplicationVersion.Minor}.{SystemInformation.Instance.ApplicationVersion.Build}.{SystemInformation.Instance.ApplicationVersion.Revision}";
Expand Down
14 changes: 11 additions & 3 deletions Emerald.App/Emerald.App/Emerald.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@
</PropertyGroup>

<ItemGroup>
<None Remove="GithubClientID.txt" />
<None Remove="Helpers\rlbl1cxv.0sq~" />
<None Remove="Restart.bat" />
<None Remove="Views\Store\InstallerPage.xaml" />
</ItemGroup>

<ItemGroup>
<Content Include="GithubClientID.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Content Include="MsalClientID.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand All @@ -33,11 +40,12 @@
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Animations" Version="7.1.2" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240227000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26031-preview" />
<PackageReference Include="Octokit" Version="10.0.0" />
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
<PackageReference Include="ProjBobcat" Version="1.16.0" />
<PackageReference Include="WinUIEx" Version="2.3.3" />
<PackageReference Include="WinUIEx" Version="2.3.4" />
<PackageReference Include="XboxAuthNet.Game.Msal" Version="0.0.5" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
Expand Down
2 changes: 0 additions & 2 deletions Emerald.App/Emerald.App/Helpers/SingleInstanceDesktopApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public void Launch(string arguments)
SendArgumentsToRunningInstance(arguments);

Process.GetCurrentProcess().Kill();
// Note: needed to kill the process in WinAppSDK 1.0, since Application.Current.Exit() does not work there.
//Application.Current.Exit();
}
}

Expand Down
90 changes: 90 additions & 0 deletions Emerald.App/Emerald.App/Helpers/Updater/GithubJSON.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Emerald.WinUI.Helpers.Updater;
public class Asset
{
public string url { get; set; }
public int id { get; set; }
public string node_id { get; set; }
public string name { get; set; }
public object label { get; set; }
public Uploader uploader { get; set; }
public string content_type { get; set; }
public string state { get; set; }
public int size { get; set; }
public int download_count { get; set; }
public DateTime created_at { get; set; }
public DateTime updated_at { get; set; }
public string browser_download_url { get; set; }
}

public class Author
{
public string login { get; set; }
public int id { get; set; }
public string node_id { get; set; }
public string avatar_url { get; set; }
public string gravatar_id { get; set; }
public string url { get; set; }
public string html_url { get; set; }
public string followers_url { get; set; }
public string following_url { get; set; }
public string gists_url { get; set; }
public string starred_url { get; set; }
public string subscriptions_url { get; set; }
public string organizations_url { get; set; }
public string repos_url { get; set; }
public string events_url { get; set; }
public string received_events_url { get; set; }
public string type { get; set; }
public bool site_admin { get; set; }
}

public class Release
{
public string url { get; set; }
public string assets_url { get; set; }
public string upload_url { get; set; }
public string html_url { get; set; }
public int id { get; set; }
public Author author { get; set; }
public string node_id { get; set; }
public string tag_name { get; set; }
public string target_commitish { get; set; }
public string name { get; set; }
public bool draft { get; set; }
public bool prerelease { get; set; }
public DateTime created_at { get; set; }
public DateTime published_at { get; set; }
public List<Asset> assets { get; set; }
public string tarball_url { get; set; }
public string zipball_url { get; set; }
public string body { get; set; }
}

public class Uploader
{
public string login { get; set; }
public int id { get; set; }
public string node_id { get; set; }
public string avatar_url { get; set; }
public string gravatar_id { get; set; }
public string url { get; set; }
public string html_url { get; set; }
public string followers_url { get; set; }
public string following_url { get; set; }
public string gists_url { get; set; }
public string starred_url { get; set; }
public string subscriptions_url { get; set; }
public string organizations_url { get; set; }
public string repos_url { get; set; }
public string events_url { get; set; }
public string received_events_url { get; set; }
public string type { get; set; }
public bool site_admin { get; set; }
}

Loading

0 comments on commit 4674cd7

Please sign in to comment.