From 3dd37f4d7da7b72675c166fcb606d6e43417c4b0 Mon Sep 17 00:00:00 2001 From: Geoff Evans Date: Sun, 4 Oct 2020 18:05:08 -0700 Subject: [PATCH] Add installer, connect to actions --- .github/workflows/build.yml | 36 +++++++-- .gitmodules | 3 + build_installer.bat | 11 +++ installer.iss | 146 ++++++++++++++++++++++++++++++++++++ submodule/InnoSetup | 1 + 5 files changed, 191 insertions(+), 6 deletions(-) create mode 100644 build_installer.bat create mode 100644 installer.iss create mode 160000 submodule/InnoSetup diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1ef355..44a2934 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: build +name: Build on: push: @@ -8,8 +8,8 @@ on: jobs: - Debug: - name: build-debug + build-debug: + name: Debug runs-on: [windows-latest] steps: @@ -30,8 +30,8 @@ jobs: run: | MSBuild.exe PowerMateTray.sln -p:Configuration=Debug - Release: - name: build-release + build-release: + name: Release runs-on: [windows-latest] steps: @@ -50,4 +50,28 @@ jobs: - name: Build PowerMateTray Release run: | - MSBuild.exe PowerMateTray.sln -p:Configuration=Release \ No newline at end of file + MSBuild.exe PowerMateTray.sln -p:Configuration=Release + + - name: Build Installer + run: | + cmd.exe /c call build_installer.bat + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + + - name: Upload Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: build/x64/Release/PowerMateTraySetup.exe + asset_name: Installer + asset_content_type: application/vnd.microsoft.portable-executable \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 320e76e..4b23c2d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "submodule/wxWidgets"] path = submodule/wxWidgets url = https://github.com/wxWidgets/wxWidgets.git +[submodule "submodule/InnoSetup"] + path = submodule/InnoSetup + url = https://github.com/HeliumProject/InnoSetup.git diff --git a/build_installer.bat b/build_installer.bat new file mode 100644 index 0000000..c91098a --- /dev/null +++ b/build_installer.bat @@ -0,0 +1,11 @@ +@echo off + +setlocal + +for /f "tokens=3" %%f in ( 'findstr /C:"#define VERSION_MAJOR" resource.h' ) do SET MAJOR=%%f +for /f "tokens=3" %%f in ( 'findstr /C:"#define VERSION_MINOR" resource.h' ) do SET MINOR=%%f +for /f "tokens=3" %%f in ( 'findstr /C:"#define VERSION_PATCH" resource.h' ) do SET PATCH=%%f + +%~dp0submodule\InnoSetup\ISCC.exe installer.iss /d"_AppVersionMajor=%MAJOR%" /d"_AppVersionMinor=%MINOR%" /d"_AppVersionPatch=%PATCH%" + +endlocal \ No newline at end of file diff --git a/installer.iss b/installer.iss new file mode 100644 index 0000000..c5ff046 --- /dev/null +++ b/installer.iss @@ -0,0 +1,146 @@ +; This script uses Inno Setup Preprocessor (ISPP) by Alex Yackimoff. +; To download and install ISPP, get the Inno Setup QuickStart Pack from http://www.jrsoftware.org/isdl.php#qsp + +#define _AppName "PowerMateTray" +#define _AppMutex "PowerMateTray" +#define _AppPublisher "gorlak" +#define _AppPublisherURL "https://github.com/gorlak/PowerMateTray" + +#ifndef _AppVersionMajor +#define _AppVersionMajor "0" +#endif + +#ifndef _AppVersionMinor +#define _AppVersionMinor "0" +#endif + +#ifndef _AppVersionPatch +#define _AppVersionPatch "0" +#endif + +#define _AppVersion _AppVersionMajor + "." + _AppVersionMinor + "." + _AppVersionPatch + +#ifndef _BuildOutput +#define _BuildOutput "build\x64\Release" +#endif + +#define _VersionInfoComments "PowerMateTray is a Windows app for the Griffin PowerMate Bluetooth." +#define _VersionInfoCopyright "Copyright (C) " + _AppPublisher +#define _VersionInfoDescription "PowerMateTray" +#define _VersionInfoVersion _AppVersion + +[Setup] +AllowNoIcons=yes +AlwaysShowDirOnReadyPage=yes +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{2c3049ab-4ea4-4617-9f7c-0fb0eaf72317} +AppName={#_AppName} +AppMutex={#_AppMutex} +AppVerName={cm:NameAndVersion,{#_AppName},{#_AppVersion}} +AppPublisher={#_AppPublisher} +AppPublisherURL={#_AppPublisherURL} +AppSupportURL={#_AppPublisherURL} +AppUpdatesURL={#_AppPublisherURL} +ArchitecturesAllowed=x64 +ArchitecturesInstallIn64BitMode=x64 +Compression=lzma +CreateUninstallRegKey=yes +DefaultDirName={commonpf64}\{#_AppName} +DisableDirPage=no +DefaultGroupName={#_AppName} +OutputDir={#_BuildOutput} +OutputBaseFilename={#_AppName}Setup +PrivilegesRequired=admin +SetupIconFile=icons\logo.ico +SolidCompression=yes +Uninstallable=yes +UninstallDisplayIcon={uninstallexe} +UsePreviousAppDir=yes +UsePreviousGroup=yes +UsePreviousTasks=yes +VersionInfoCompany={#_AppPublisher} +VersionInfoCopyright={#_AppName} {#_AppVersion} +VersionInfoDescription={#_VersionInfoDescription} +VersionInfoProductName={#_AppName} +VersionInfoProductVersion={#_VersionInfoVersion} +VersionInfoTextVersion={#_VersionInfoVersion} +VersionInfoVersion={#_VersionInfoVersion} + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "windowsstartupicon"; Description: "Start on Windows Startup (Recommended)"; GroupDescription: "Startup:" + +[Files] +; NOTE: Don't use "Flags: ignoreversion" on any shared system files +Source: "{#_BuildOutput}\PowerMateTray.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#_BuildOutput}\PowerMateTray.pdb"; DestDir: "{app}"; Flags: ignoreversion + +[Icons] +Name: "{group}\{#_AppName}"; Filename: "{app}\PowerMateTray.exe"; Comment: {#_VersionInfoComments} +Name: "{group}\{cm:UninstallProgram,{#_AppName}}"; Filename: "{uninstallexe}"; Comment: {#_VersionInfoComments} +Name: "{commonstartup}\{#_AppName}"; Filename: "{app}\PowerMateTray.exe"; Comment: {#_VersionInfoComments}; Tasks: windowsstartupicon + +[Run] +Filename: "{app}\PowerMateTray.exe"; Description: "Run {#_AppName}"; Flags: nowait postinstall shellexec + +[Code] +///////////////////////////////////////////////////////////////////// +function GetUninstallString(): String; +var + sUnInstPath: String; + sUnInstallString: String; +begin + sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1'); + sUnInstallString := ''; + if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then + RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString); + Result := sUnInstallString; +end; + +///////////////////////////////////////////////////////////////////// +function IsUpgrade(): Boolean; +begin + Result := (GetUninstallString() <> ''); +end; + +///////////////////////////////////////////////////////////////////// +function UnInstallOldVersion(): Integer; +var + sUnInstallString: String; + iResultCode: Integer; +begin +// Return Values: +// 1 - uninstall string is empty +// 2 - error executing the UnInstallString +// 3 - successfully executed the UnInstallString + + // default return value + Result := 0; + + // get the uninstall string of the old app + sUnInstallString := GetUninstallString(); + if sUnInstallString <> '' then begin + sUnInstallString := RemoveQuotes(sUnInstallString); + if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then + Result := 3 + else + Result := 2; + end else + Result := 1; +end; + +///////////////////////////////////////////////////////////////////// +procedure CurStepChanged(CurStep: TSetupStep); +begin + if (CurStep=ssInstall) then + begin + if (IsUpgrade()) then + begin + UnInstallOldVersion(); + end; + end; +end; \ No newline at end of file diff --git a/submodule/InnoSetup b/submodule/InnoSetup new file mode 160000 index 0000000..3786cc4 --- /dev/null +++ b/submodule/InnoSetup @@ -0,0 +1 @@ +Subproject commit 3786cc42fdae8fe80a8f2e6ce1fe7defdac193e9