Skip to content

Commit

Permalink
feat: inno installer for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Jan 28, 2021
1 parent af4b1c6 commit 7aeb61b
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -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 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -150,3 +150,5 @@ dist

# linux binary
/src/oh-my-posh3
bin/
Output/
25 changes: 25 additions & 0 deletions packages/inno/build.ps1
@@ -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'
38 changes: 38 additions & 0 deletions packages/inno/oh-my-posh.iss
@@ -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;

0 comments on commit 7aeb61b

Please sign in to comment.