From ac338c85a0b3d68a27c88ab458ae14169593930d Mon Sep 17 00:00:00 2001 From: Ossama Hjaji Date: Thu, 26 May 2022 14:54:20 +0200 Subject: [PATCH] Generate Windows installer from CD (#668) * add onefetch.ico * Create windows-installer.iss * Delete windows-installer.iss * Create windows-installer.iss * Update cd.yml * Update Makefile * Update windows-installer.iss * Update Makefile --- .github/workflows/cd.yml | 1 + .github/workflows/windows-installer.iss | 111 ++++++++++++++++++++++++ Makefile | 2 + assets/onefetch.ico | Bin 0 -> 2265 bytes 4 files changed, 114 insertions(+) create mode 100644 .github/workflows/windows-installer.iss create mode 100644 assets/onefetch.ico diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 7aa31b39..77fe6e76 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -42,6 +42,7 @@ jobs: files: | ./release/*.tar.gz ./release/*.zip + ./onefetch-setup.exe env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/windows-installer.iss b/.github/workflows/windows-installer.iss new file mode 100644 index 00000000..fd2985da --- /dev/null +++ b/.github/workflows/windows-installer.iss @@ -0,0 +1,111 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "onefetch" +;#define MyAppVersion "1.0" +#define MyAppPublisher "Ossama Hjaji" +#define MyAppURL "https://github.com/o2sh/onefetch" +#define MyAppExeName "onefetch.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={{BB44DE71-B34D-4707-AE9D-5FF3FA632283} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={autopf}\{#MyAppName} +DisableDirPage=yes +DisableProgramGroupPage=yes +; Uncomment the following line to run in non administrative install mode (install for current user only.) +;PrivilegesRequired=lowest +OutputDir=..\.. +OutputBaseFilename=onefetch-setup +SetupIconFile=..\..\assets\onefetch.ico +Compression=lzma +SolidCompression=yes +WizardStyle=modern +ChangesEnvironment=true + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Files] +Source: "..\..\target\release\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" + +[Code] +{ https://stackoverflow.com/a/46609047/149111 } +const EnvironmentKey = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'; +procedure EnvAddPath(instlPath: string); +var + Paths: string; +begin + { Retrieve current path (use empty string if entry not exists) } + if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then + Paths := ''; + if Paths = '' then + Paths := instlPath + ';' + else + begin + { Skip if string already found in path } + if Pos(';' + Uppercase(instlPath) + ';', ';' + Uppercase(Paths) + ';') > 0 then exit; + if Pos(';' + Uppercase(instlPath) + '\;', ';' + Uppercase(Paths) + ';') > 0 then exit; + { Append App Install Path to the end of the path variable } + if Paths[length(Paths)] <> ';' then + Paths := Paths + ';'; + Paths := Paths + instlPath + ';'; + end; + { Overwrite (or create if missing) path environment variable } + if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) + then Log(Format('The [%s] added to PATH: [%s]', [instlPath, Paths])) + else Log(Format('Error while adding the [%s] to PATH: [%s]', [instlPath, Paths])); +end; +procedure EnvRemovePath(instlPath: string); +var + Paths: string; + P, Offset, DelimLen: Integer; +begin + { Skip if registry entry not exists } + if not RegQueryStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) then + exit; + { Skip if string not found in path } + DelimLen := 1; { Length(';') } + P := Pos(';' + Uppercase(instlPath) + ';', ';' + Uppercase(Paths) + ';'); + if P = 0 then + begin + { perhaps instlPath lives in Paths, but terminated by '\;' } + DelimLen := 2; { Length('\;') } + P := Pos(';' + Uppercase(instlPath) + '\;', ';' + Uppercase(Paths) + ';'); + if P = 0 then exit; + end; + { Decide where to start string subset in Delete() operation. } + if P = 1 then + Offset := 0 + else + Offset := 1; + { Update path variable } + Delete(Paths, P - Offset, Length(instlPath) + DelimLen); + { Overwrite path environment variable } + if RegWriteStringValue(HKEY_LOCAL_MACHINE, EnvironmentKey, 'Path', Paths) + then Log(Format('The [%s] removed from PATH: [%s]', [instlPath, Paths])) + else Log(Format('Error while removing the [%s] from PATH: [%s]', [instlPath, Paths])); +end; + +procedure CurStepChanged(CurStep: TSetupStep); +begin + if CurStep = ssPostInstall then + EnvAddPath(ExpandConstant('{app}')); +end; +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +begin + if CurUninstallStep = usPostUninstall then + EnvRemovePath(ExpandConstant('{app}')); +end; diff --git a/Makefile b/Makefile index 35fbce39..4b5b6968 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,11 @@ release-mac: mkdir -p release tar -C ./target/release/ -czvf ./release/onefetch-mac.tar.gz ./onefetch +release-win: TAG_NAME = $$(git describe --abbrev=0 --tags) release-win: mkdir -p release tar -C ./target/release/ -czvf ./release/onefetch-win.tar.gz ./onefetch.exe + iscc.exe -DMyAppVersion=${TAG_NAME} ./.github/workflows/windows-installer.iss release-linux: strip target/release/onefetch diff --git a/assets/onefetch.ico b/assets/onefetch.ico new file mode 100644 index 0000000000000000000000000000000000000000..2950b9e355409207100bc254eafb9d1e374d6334 GIT binary patch literal 2265 zcmaJ@2{hDe8~@K>W@MQx35|%5CA*5rQVmm<;WMKoG1R2RG6-obgUV8r?3uj6&$|EsXtQrM5TF9Q zf&qZsCQfq3pe42`Zrg+sCyt|BwsyA$On7ryAmP6N04(_g>Im-I;Fn>4Ki6<2#vI>* zF7o110>@p3Y3F@UqP-V#>r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