feat: inno installer for Windows

This commit is contained in:
Jan De Dobbeleer 2021-01-28 21:53:45 +01:00 committed by Jan De Dobbeleer
parent af4b1c6c39
commit 7aeb61ba86
4 changed files with 98 additions and 0 deletions

View file

@ -240,3 +240,36 @@ jobs:
asset_path: ${{ github.workspace }}/packages/scoop/posh-windows-wsl-amd64.7z.sha256
asset_name: posh-windows-wsl-amd64.7z.sha256
asset_content_type: text/plain
inno:
needs: [release, artifacts]
if: ${{ needs.release.outputs.skipped == 'false' }}
runs-on: windows-latest
defaults:
run:
shell: pwsh
working-directory: ${{ github.workspace }}/packages/inno
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build installer
run: ./build.ps1 -Version ${{ needs.release.outputs.version }}
- name: Upload Inno Installer
id: upload-inno-installer
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/packages/inno/Output/install.exe
asset_name: install.exe
asset_content_type: text/plain
- name: Upload Inno Installer Hash
id: upload-inno-installer-hash
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ github.workspace }}/packages/inno/Output/install.exe.sha256
asset_name: install.exe.sha256
asset_content_type: text/plain

2
.gitignore vendored
View file

@ -150,3 +150,5 @@ dist
# linux binary
/src/oh-my-posh3
bin/
Output/

25
packages/inno/build.ps1 Normal file
View file

@ -0,0 +1,25 @@
Param
(
[parameter(Mandatory = $true)]
[string]
$Version
)
New-Item -Path "." -Name "bin" -ItemType Directory
Copy-Item -Path "../../themes" -Destination "./bin" -Recurse
# download the files and pack them
@{name = 'posh-windows-amd64.exe' }, @{name = 'posh-linux-amd64' }, @{name = 'posh-windows-386.exe' } | ForEach-Object -Process {
$download = "https://github.com/jandedobbeleer/oh-my-posh3/releases/download/v$Version/$($_.name)"
Invoke-WebRequest $download -Out "./bin/$($_.name)"
}
# lisence
Invoke-WebRequest "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh3/v$Version/COPYING" -Out "./bin/COPYING.txt"
$content = Get-Content '.\oh-my-posh.iss' -Raw
$content = $content.Replace('<VERSION>', $Version)
$content | Out-File -Encoding 'UTF8' ".oh-my-posh-$Version.iss"
# package content
ISCC.exe ".oh-my-posh-$Version.iss"
# get hash
$zipHash = Get-FileHash 'Output/install.exe' -Algorithm SHA256
$zipHash.Hash | Out-File -Encoding 'UTF8' 'Output/install.exe.sha256'

View file

@ -0,0 +1,38 @@
[Setup]
AppName=Oh my Posh
AppVersion=<VERSION>
DefaultDirName={autopf}\oh-my-posh
DefaultGroupName=Oh my Posh
PrivilegesRequired=lowest
AppPublisher=Jan De Dobbeleer
AppPublisherURL=https://ohmyposh.dev
AppSupportURL=https://github.com/JanDeDobbeleer/oh-my-posh3/issues
LicenseFile="bin\COPYING.txt"
OutputBaseFilename=install
[Files]
Source: "bin\posh-windows-amd64.exe"; DestDir: "{app}\bin"; DestName: "oh-my-posh.exe"; Flags: 64bit
Source: "bin\posh-windows-386.exe"; DestDir: "{app}\bin"; DestName: "oh-my-posh.exe"; Flags: 32bit
Source: "bin\posh-linux-amd64"; DestDir: "{app}\bin"; DestName: "oh-my-posh-wsl"; Flags: 64bit
Source: "bin\themes\*"; DestDir: "{app}\themes"
[Registry]
Root: "HKCU"; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\bin"; Check: NeedsAddPathHKCU(ExpandConstant('{app}\bin'))
Root: "HKCU"; Subkey: "Environment"; ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\themes"; Check: NeedsAddPathHKCU(ExpandConstant('{app}\themes'))
[Code]
function NeedsAddPathHKCU(Param: string): boolean;
var
OrigPath: string;
begin
if not RegQueryStringValue(HKEY_CURRENT_USER,
'Environment',
'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;