- Notifications
You must be signed in to change notification settings - Fork5
chore: various finish line tasks#23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
permissions: | ||
contents: write | ||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.0.x' | ||
- name: Get version from tag | ||
id: version | ||
shell: pwsh | ||
run: | | ||
$tag = $env:GITHUB_REF -replace 'refs/tags/','' | ||
if ($tag -notmatch '^v\d+\.\d+\.\d+$') { | ||
throw "Tag must be in format v1.2.3" | ||
} | ||
$version = $tag -replace '^v','' | ||
$assemblyVersion = "$version.0" | ||
echo "VERSION=$version" >> $env:GITHUB_OUTPUT | ||
echo "ASSEMBLY_VERSION=$assemblyVersion" >> $env:GITHUB_OUTPUT | ||
- name: Build and publish x64 | ||
run: | | ||
dotnet publish src/App/App.csproj -c Release -r win-x64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/x64 | ||
dotnet publish src/Vpn.Service/Vpn.Service.csproj -c Release -r win-x64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/x64 | ||
- name: Build and publish arm64 | ||
run: | | ||
dotnet publish src/App/App.csproj -c Release -r win-arm64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/arm64 | ||
dotnet publish src/Vpn.Service/Vpn.Service.csproj -c Release -r win-arm64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/arm64 | ||
- name: Create ZIP archives | ||
shell: pwsh | ||
run: | | ||
Compress-Archive -Path "publish/x64/*" -DestinationPath "./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-x64.zip" | ||
Compress-Archive -Path "publish/arm64/*" -DestinationPath "./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-arm64.zip" | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-x64.zip | ||
./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-arm64.zip | ||
name: Release ${{ steps.version.outputs.VERSION }} | ||
generate_release_notes: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
using Microsoft.UI.Dispatching; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.Windows.AppLifecycle; | ||
using WinRT; | ||
namespace Coder.Desktop.App; | ||
#if DISABLE_XAML_GENERATED_MAIN | ||
public static class Program | ||
{ | ||
private static App? app; | ||
#if DEBUG | ||
[DllImport("kernel32.dll")] | ||
private static extern bool AllocConsole(); | ||
#endif | ||
[DllImport("user32.dll", CharSet = CharSet.Unicode)] | ||
private static extern int MessageBoxW(IntPtr hWnd, string text, string caption, int type); | ||
[STAThread] | ||
private static void Main(string[] args) | ||
{ | ||
try | ||
{ | ||
ComWrappersSupport.InitializeComWrappers(); | ||
if (!CheckSingleInstance()) return; | ||
Application.Start(p => | ||
{ | ||
var context = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread()); | ||
SynchronizationContext.SetSynchronizationContext(context); | ||
app = new App(); | ||
app.UnhandledException += (_, e) => | ||
{ | ||
e.Handled = true; | ||
ShowExceptionAndCrash(e.Exception); | ||
}; | ||
}); | ||
} | ||
catch (Exception e) | ||
{ | ||
ShowExceptionAndCrash(e); | ||
} | ||
} | ||
[STAThread] | ||
private static bool CheckSingleInstance() | ||
{ | ||
#if !DEBUG | ||
const string appInstanceName = "Coder.Desktop.App"; | ||
#else | ||
const string appInstanceName = "Coder.Desktop.App.Debug"; | ||
#endif | ||
var instance = AppInstance.FindOrRegisterForKey(appInstanceName); | ||
return instance.IsCurrent; | ||
} | ||
[STAThread] | ||
private static void ShowExceptionAndCrash(Exception e) | ||
{ | ||
const string title = "Coder Desktop Fatal Error"; | ||
var message = | ||
"Coder Desktop has encountered a fatal error and must exit.\n\n" + | ||
e + "\n\n" + | ||
Environment.StackTrace; | ||
MessageBoxW(IntPtr.Zero, message, title, 0); | ||
if (app != null) | ||
app.Exit(); | ||
// This will log the exception to the Windows Event Log. | ||
#if DEBUG | ||
// And, if in DEBUG mode, it will also log to the console window. | ||
AllocConsole(); | ||
#endif | ||
Environment.FailFast("Coder Desktop has encountered a fatal error and must exit.", e); | ||
} | ||
} | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -32,7 +32,7 @@ public VpnLifecycleException(string message) : base(message) | ||
} | ||
} | ||
public interface IRpcController : IAsyncDisposable | ||
{ | ||
public event EventHandler<RpcModel> StateChanged; | ||
@@ -224,6 +224,13 @@ public async Task StopVpn(CancellationToken ct = default) | ||
new InvalidOperationException($"Service reported failure: {reply.Stop.ErrorMessage}")); | ||
} | ||
public async ValueTask DisposeAsync() | ||
{ | ||
if (_speaker != null) | ||
await _speaker.DisposeAsync(); | ||
GC.SuppressFinalize(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't understand why this is necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. You don't understand why the entire DisposeAsync implementation is necessary or why the If you mean the whole implementation, we're calling it when the app closes to close the named pipe and remove the async receive tasks from the background. If you mean the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yeah, I meant I don't see an explicit I ask because I'm concerned that this is somewhat fragile. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Honestly I don't know that much about how the C# GC works, so I'm not sure. From what I can tell in most cases where you don't explicitly write a finalizer it won't try to run it, so it's probably fine without it. The main reason this is here is because thelinter said we should include it even though we don't have a finalizer:
So it seems like it's more about convention | ||
} | ||
private void MutateState(Action<RpcModel> mutator) | ||
{ | ||
RpcModel newState; | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.