Skip to content

Commit

Permalink
feat: add experimental Windows installer
Browse files Browse the repository at this point in the history
  • Loading branch information
anacierdem committed Sep 16, 2024
1 parent 9caffc9 commit 83aab64
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,44 @@ jobs:
name: Run Tests
uses: ./.github/workflows/tests.yml

installer:
name: Build the Inno Setup Installer
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Prepare
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'

- name: Install
run: npm ci

- name: Build
id: prepare-installer
run: |
npm run pack
mv libdragon-win.exe libdragon.exe
npx semantic-release --dry-run --no-ci
echo "::set-output name=nextVersion::`cat .VERSION`"
- name: Compile .ISS to .EXE Installer
uses: Minionguyjpro/Inno-Setup-Action@v1.2.2
with:
path: ./setup.iss
options: /dMyAppVersion=${{ steps.prepare-installer.outputs.nextVersion }}

- name: Upload installer
uses: actions/upload-artifact@v3
with:
name: installer-artifact
include-hidden-files: true
path: |
./Output/libdragon-installer.exe
./.VERSION
release:
name: Release
runs-on: ubuntu-latest
Expand All @@ -19,6 +57,11 @@ jobs:
with:
persist-credentials: false

- name: Download installer
uses: actions/download-artifact@master
with:
name: installer-artifact

- name: Prepare
uses: actions/setup-node@v3
with:
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
[
"@semantic-release/exec",
{
"prepareCmd": "./pack.sh"
"prepareCmd": "./pack.sh",
"verifyReleaseCmd": "echo ${nextRelease.version} > .VERSION"
}
],
[
Expand All @@ -101,6 +102,10 @@
{
"path": "libdragon-win-x86_64.zip",
"label": "Windows executable"
},
{
"path": "libdragon-installer.exe",
"label": "Windows installer"
}
]
}
Expand Down
103 changes: 103 additions & 0 deletions setup.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "libdragon"
#define MyAppVersion "none"
#define MyAppPublisher "Libdragon"
#define MyAppURL "https://libdragon.dev/"
#define MyAppExeName "libdragon.exe"

[Setup]
; 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={{B9EE00C4-986A-4E99-BE51-2730EFB899FF}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=.\LICENSE.md
OutputBaseFilename=libdragon-installer
Compression=lzma
SolidCompression=yes
WizardStyle=modern
ChangesEnvironment=yes
; TODO: It is possible to enable this if the executable itself does the
; PrivilegesRequiredOverridesAllowed=dialog

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Files]
Source: ".\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"

[Registry]
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \
Check: NeedsAddPath(ExpandConstant('{app}'))

[Code]
const
EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
function NeedsAddPath(Param: string): boolean;
var
OrigPath: string;
begin
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
EnvironmentKey,
'Path', OrigPath)
then begin
Result := True;
exit;
end;
{ look for the path with leading and trailing semicolon }
{ Pos() returns 0 if not found }
Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
end;
procedure RemovePath(Path: string);
var
Paths: string;
P: Integer;
begin
if not RegQueryStringValue(HKLM, EnvironmentKey, 'Path', Paths) then begin
Log('PATH not found');
end else begin
Log(Format('PATH is [%s]', [Paths]));
P := Pos(';' + Uppercase(Path) + ';', ';' + Uppercase(Paths) + ';');
if P = 0 then begin
Log(Format('Path [%s] not found in PATH', [Path]));
end else begin
if P > 1 then P := P - 1;
Delete(Paths, P, Length(Path) + 1);
Log(Format('Path [%s] removed from PATH => [%s]', [Path, Paths]));
if RegWriteStringValue(HKLM, EnvironmentKey, 'Path', Paths) then begin
Log('PATH written');
end
end
end
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usUninstall then
begin
RemovePath(ExpandConstant('{app}'));
end;
end;

0 comments on commit 83aab64

Please sign in to comment.