Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,31 @@ jobs:
bash .agent/setup.sh
bash .agent/quick-build.sh

- name: Install Velopack CLI
run: dotnet tool install -g vpk

- name: Publish application
run: dotnet publish OpenpilotToolkit/OpenpilotToolkit.csproj -p:PublishProfile=FolderProfile -c Release /p:EnableWindowsTargeting=true

- name: Download Previous Release for Deltas
continue-on-error: true
run: |
export PATH="$PATH:$HOME/.dotnet/tools"
vpk download github --repoUrl https://github.com/spektor56/openpilottoolkit -o ReleasePackages

- name: Package application
run: |
zip -r OpenpilotToolkit-${{ github.event.inputs.version }}.zip OpenpilotToolkit/bin/Release/net10.0-windows10.0.19041/win-x64/
export PATH="$PATH:$HOME/.dotnet/tools"
VERSION="${{ github.event.inputs.version }}"
VERSION="${VERSION#v}"
vpk pack -u OpenpilotToolkit -v $VERSION -p OpenpilotToolkit/bin/publish/ -o ReleasePackages -i OpenpilotToolkit/Resources/ic_launcher-web.ico -s OpenpilotToolkit/Resources/ssh.png

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.version }}
body: ${{ github.event.inputs.release_notes }}
files: ./OpenpilotToolkit-${{ github.event.inputs.version }}.zip
files: ./ReleasePackages/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions OpenpilotToolkit/OpenpilotToolkit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@
<PackageReference Include="LiveChartsCore.SkiaSharpView.WinForms" Version="2.0.0-rc6.1" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="10.0.0-rc.2.25502.107" />
<PackageReference Include="Octokit" Version="14.0.0" />
<PackageReference Include="Velopack" Version="0.0.1053" />
<PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.1-dev-02315" />
Expand Down
81 changes: 81 additions & 0 deletions OpenpilotToolkit/OpenpilotToolkitForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.Measure;
using Velopack;
using Velopack.Sources;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView.Painting.Effects;
using LiveChartsCore.SkiaSharpView.SKCharts;
Expand Down Expand Up @@ -330,11 +332,90 @@ private async void Form1_Load(object sender, EventArgs e)
await ScanDevices().ConfigureAwait(false);

//Look for updates
_ = Task.Run(CheckForUpdatesAsync);

//TODO: implement self-updater
//var test = await _githubClient.Repository.Release.GetLatest("spektor56", "openpilotToolkit");
}

private async Task CheckForUpdatesAsync()
{
try
{
var mgr = new UpdateManager(new GithubSource("https://github.com/spektor56/openpilottoolkit", null, false));

if (!mgr.IsInstalled)
{
try
{
var release = await _githubClient.Repository.Release.GetLatest("spektor56", "openpilotToolkit");
if (release != null)
{
var currentVersionStr = Assembly.GetExecutingAssembly().GetName().Version.ToString();
if (Version.TryParse(currentVersionStr, out var currentVersion) &&
Version.TryParse(release.TagName.TrimStart('v'), out var latestVersion) &&
latestVersion > currentVersion)
{
Invoke(new MethodInvoker(() =>
{
var result = ToolkitMessageDialog.ShowDialog($"An update to version {release.TagName} is available, but this version of OpenpilotToolkit was not installed via the auto-updating installer. Would you like to open the download page to install the new version?", this, MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
Process.Start(new ProcessStartInfo
{
FileName = "https://github.com/spektor56/openpilottoolkit/releases/latest",
UseShellExecute = true
});
}
}));
}
}
}
catch (Exception ex)
{
Serilog.Log.Error(ex, "Failed to check for non-Velopack updates from GitHub");
}
return;
}

var newVersion = await mgr.CheckForUpdatesAsync();
if (newVersion == null)
{
return; // No update available
}

Invoke(new MethodInvoker(() =>
{
var result = ToolkitMessageDialog.ShowDialog($"An update to version {newVersion.TargetFullRelease.Version} is available. Would you like to update now?", this, MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
Task.Run(async () =>
{
try
{
Invoke(new MethodInvoker(() =>
{
var message = new MaterialSnackBar("Downloading update, the application will restart automatically...", "OK", false);
message.Show(this);
}));
await mgr.DownloadUpdatesAsync(newVersion);
mgr.ApplyUpdatesAndRestart(newVersion);
}
catch (Exception ex)
{
Serilog.Log.Error(ex, "Failed to download/apply update");
Invoke(new MethodInvoker(() => ToolkitMessageDialog.ShowDialog("Failed to apply update: " + ex.Message, this)));
}
});
}
}));
}
catch (Exception ex)
{
Serilog.Log.Error(ex, "Error checking for updates.");
}
}

private async void FileWatcherOnChanged(object sender, FileSystemEventArgs e)
{
if (e.ChangeType == WatcherChangeTypes.Changed && _watchedFiles.Count > 0)
Expand Down
10 changes: 10 additions & 0 deletions OpenpilotToolkit/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using Velopack;

namespace OpenpilotToolkit
{
Expand All @@ -26,6 +27,15 @@ static class Program
[STAThread]
public static int Main(string[] args)
{
try
{
VelopackApp.Build().Run();
}
catch (Exception)
{
// Ignore errors related to Velopack initialization
}

Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.SetHighDpiMode(HighDpiMode.DpiUnaware);
Application.EnableVisualStyles();
Expand Down