Skip to content

Commit

Permalink
Merge pull request #7 from GewoonJaap/feature/squirrel-installer
Browse files Browse the repository at this point in the history
Add installer with auto updating
  • Loading branch information
GewoonJaap authored Nov 2, 2023
2 parents 2634946 + 4b1ab02 commit e59ae93
Show file tree
Hide file tree
Showing 33 changed files with 272 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
Expand Down Expand Up @@ -177,7 +175,6 @@ DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
Expand Down
19 changes: 19 additions & 0 deletions ConsoleApp/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Reflection;
using System.Runtime.InteropServices;

// In SDK-style projects such as this one, several assembly attributes that were historically
// defined in this file are now automatically added during build and populated with
// values defined in project properties. For details of which attributes are included
// and how to customise this process see: https://aka.ms/assembly-info-properties


// Setting ComVisible to false makes the types in this assembly not visible to COM
// components. If you need to access a type in this assembly from COM, set the ComVisible
// attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM.

[assembly: Guid("d00ae3f6-c5d1-4d62-a28e-33dbc4bb9ed8")]

4 changes: 3 additions & 1 deletion ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
<AssemblyName>WinWhisper</AssemblyName>
<ApplicationIcon>WinWhisper-White_Icon.ico</ApplicationIcon>
<Platforms>AnyCPU;ARM64</Platforms>
<Version>1.2</Version>
<Version>1.2.0</Version>
<Description>WinWhisper is a Windows application that uses AI to detect and remove background noise from audio files.</Description>
<Authors>Jaap</Authors>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

<ItemGroup>
<Content Include="WinWhisper-White_Icon.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Clowd.Squirrel" Version="2.9.42" />
<PackageReference Include="Sentry" Version="3.40.1" />
</ItemGroup>

Expand Down
54 changes: 53 additions & 1 deletion ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using AudioExtractor;
using Data;
using Sentry;
using Squirrel;
using System.Reflection;
using System.Runtime.InteropServices;
using Utility;
using WhisperAI;

Expand All @@ -21,6 +24,11 @@ private static void Main(string[] args)

try
{
//only on windows
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
RegisterSquirrel();
}

//create folder Subtitles if not exists
FolderManager.CreateFolder(FolderManager.SubtitlesFolder);
Expand Down Expand Up @@ -72,10 +80,20 @@ private static void Main(string[] args)
}

}

private static void RegisterSquirrel()
{
SquirrelAwareApp.HandleEvents(
onInitialInstall: OnAppInstall,
onAppUninstall: OnAppUninstall,
onEveryRun: OnAppRun);

}

private static GatherVideoResult GatherVideosToConvert()
{
Console.Clear();
Console.WriteLine("Welcome to WinWhisper. Generate subtitles with ease using WhisperAI.");
Console.WriteLine($"Welcome to WinWhisper ({Assembly.GetExecutingAssembly().GetName().Version}). Generate subtitles with ease using WhisperAI.");

Console.WriteLine("Enter the path where you want the subtitles to be saved...");
Console.WriteLine("Leave empty to save the subtitles in the ./Subtitles folder");
Expand All @@ -92,4 +110,38 @@ private static GatherVideoResult GatherVideosToConvert()
return new GatherVideoResult(videos, subtitleOutputPath);

}

private static void OnAppInstall(SemanticVersion version, IAppTools tools)
{
tools.CreateShortcutForThisExe(ShortcutLocation.StartMenu | ShortcutLocation.Desktop);
}

private static void OnAppUninstall(SemanticVersion version, IAppTools tools)
{
tools.RemoveShortcutForThisExe(ShortcutLocation.StartMenu | ShortcutLocation.Desktop);
}

private static async Task UpdateMyApp()
{
using var mgr = new UpdateManager("https://winwhisper.ams3.digitaloceanspaces.com");
var newVersion = await mgr.UpdateApp();

// optionally restart the app automatically, or ask the user if/when they want to restart
if (newVersion != null)
{
Console.WriteLine($"WinWhisper update {newVersion.Version} is available! Installing on exit.");
UpdateManager.RestartAppWhenExited();
}
}

private static void OnAppRun(SemanticVersion version, IAppTools tools, bool firstRun)
{
tools.SetProcessAppUserModelId();
// show a welcome message when the app is first installed
if (firstRun)
{
Console.WriteLine($"Thanks for installing WinWhisper version {Assembly.GetExecutingAssembly().GetName().Version}");
}
UpdateMyApp();
}
}
80 changes: 80 additions & 0 deletions ConsoleApp/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<SquirrelAwareVersion xmlns="urn:schema-squirrel-com:asm.v1">1</SquirrelAwareVersion>
<assemblyIdentity version="1.0.0.0" name="WinWhisper.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->

</assembly>
7 changes: 7 additions & 0 deletions Publish/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore all in this directory except .gitignore
*.dll
*.exe
*.pdb
*.json
*.zip
runtimes/
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ With WinWhisper you can easily generate subtitles for your videos. These subtitl
4. Create a pull request


## How to generate a publishable release?
1. Open the `publish.bat` file
2. Enter the new version number
3. Upload all files inside `Releases` to the storage bucket
4. Create a new release on GitHub
5. Upload the WinWhisperSetup.exe file to the release


## Thanks to
- [@hirowa](https://github.com/hirowa) for creating the WinWhisper logo and banner ❤️

Expand Down
Empty file added Releases/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions Releases/RELEASES
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C19E0B9DDEAD0F24C49002381A3AD3362C31E642 WinWhisper-1.2.0-full.nupkg 10961944
Binary file added Releases/WinWhisperSetup.exe
Binary file not shown.
Binary file added SquirrelTools/7z.dll
Binary file not shown.
Binary file added SquirrelTools/7z.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SquirrelTools/Setup.exe
Binary file not shown.
Binary file added SquirrelTools/Squirrel.exe
Binary file not shown.
Binary file added SquirrelTools/StubExecutable.exe
Binary file not shown.
Binary file added SquirrelTools/Update.exe
Binary file not shown.
Binary file added SquirrelTools/WixNetFxExtension.dll
Binary file not shown.
Binary file added SquirrelTools/candle.exe
Binary file not shown.
18 changes: 18 additions & 0 deletions SquirrelTools/candle.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
<copyright file="app.config" company="Outercurve Foundation">
Copyright (c) 2004, Outercurve Foundation.
This software is released under Microsoft Reciprocal License (MS-RL).
The license and further copyright text can be found in the file
LICENSE.TXT at the root directory of the distribution.
</copyright>
-->
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
Binary file added SquirrelTools/darice.cub
Binary file not shown.
Binary file added SquirrelTools/light.exe
Binary file not shown.
18 changes: 18 additions & 0 deletions SquirrelTools/light.exe.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
<copyright file="app.config" company="Outercurve Foundation">
Copyright (c) 2004, Outercurve Foundation.
This software is released under Microsoft Reciprocal License (MS-RL).
The license and further copyright text can be found in the file
LICENSE.TXT at the root directory of the distribution.
</copyright>
-->
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
Binary file added SquirrelTools/nuget.exe
Binary file not shown.
Binary file added SquirrelTools/rcedit.exe
Binary file not shown.
Binary file added SquirrelTools/signtool.exe
Binary file not shown.
Binary file added SquirrelTools/singlefilehost.exe
Binary file not shown.
39 changes: 39 additions & 0 deletions SquirrelTools/template.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product Id="*" Name="{{Title}} Deployment Tool" Language="1033" Codepage="{{Codepage}}" Version="{{Version}}" UpgradeCode="{{IdAsGuid1}}" Manufacturer="{{Author}}">

<Package Description="This package installs a deployment tool for {{Title}}. Not {{Title}} itself. {{Title}} is only installed if a user logs into the machine." InstallScope="perMachine" Comments="Comments" InstallerVersion="200" Compressed="yes" Platform="{{Platform}}"/>
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A later version of this product is already installed. Setup will now exit."/>
<Media Id="1" Cabinet="contents.cab" EmbedCab="yes" CompressionLevel="high"/>

<PropertyRef Id="NETFRAMEWORK45" />

<Condition Message="This application requires .NET Framework 4.5 or higher. Please install the latest .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="{{ProgramFilesFolder}}">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="{{Title}} Deployment Tool" />
</Directory>
</Directory>

<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Component Id="{{Id}}.exe" Guid="{{IdAsGuid2}}" Win64="{{Win64YesNo}}">
<File Id="{{Id}}.exe" Name="{{Id}}DeploymentTool.exe" Source="./{{SetupName}}.exe" KeyPath="yes"/>
</Component>
</DirectoryRef>

<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="{{IdAsGuid3}}" Win64="{{Win64YesNo}}">
<RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Run">
<RegistryValue Type="expandable" Name="{{Id}}Deployment" Value="&quot;[#{{Id}}.exe]&quot; --checkInstall" />
</RegistryKey>
</Component>
</DirectoryRef>

<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentRef Id="{{Id}}.exe" />
<ComponentRef Id="RegistryEntries" />
</Feature>
</Product>
</Wix>
Binary file added SquirrelTools/wconsole.dll
Binary file not shown.
Binary file added SquirrelTools/winterop.dll
Binary file not shown.
Binary file added SquirrelTools/wix.dll
Binary file not shown.
26 changes: 26 additions & 0 deletions publish.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@echo off

set /p version="New version number (e.g. 1.0.0): "
dotnet publish -c Release -o ".\Publish" /p:AssemblyVersion=%version% /p:FileVersion=%version% /p:InformationalVersion=%version%

:: Set the path to Squirrel.exe
set SQUIRREL_PATH=.\SquirrelTools\Squirrel.exe

:: Download the currently live version
%SQUIRREL_PATH% http-down --url "https://winwhisper.ams3.digitaloceanspaces.com"

:: Ask for the new version number

:: Build new version and delta updates
%SQUIRREL_PATH% pack ^
--framework net7,vcredist143-x86 ^
--packId "WinWhisper" ^
--packVersion %version% ^
--packAuthors "Jaap" ^
--packDir ".\Publish" ^
--icon ".\ConsoleApp\WinWhisper-White_Icon.ico" ^
--splashImage ".\Assets\Cover\1x\WinWhisper-Blue_Cover.png" ^
--releaseDir ".\Releases"

:: Zip all files in Publish to WinWHisper-<version>-standalone.zip
powershell Compress-Archive -Path ".\Publish\*" -DestinationPath ".\Publish\WinWhisper-%version%-standalone.zip"

0 comments on commit e59ae93

Please sign in to comment.