Skip to content

Commit

Permalink
Add installer, connect to actions
Browse files Browse the repository at this point in the history
  • Loading branch information
gorlak committed Oct 5, 2020
1 parent c2c8291 commit 3dd37f4
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 6 deletions.
36 changes: 30 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: Build

on:
push:
Expand All @@ -8,8 +8,8 @@ on:

jobs:

Debug:
name: build-debug
build-debug:
name: Debug
runs-on: [windows-latest]

steps:
Expand All @@ -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:
Expand All @@ -50,4 +50,28 @@ jobs:

- name: Build PowerMateTray Release
run: |
MSBuild.exe PowerMateTray.sln -p:Configuration=Release
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions build_installer.bat
Original file line number Diff line number Diff line change
@@ -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
146 changes: 146 additions & 0 deletions installer.iss
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions submodule/InnoSetup
Submodule InnoSetup added at 3786cc

0 comments on commit 3dd37f4

Please sign in to comment.