Skip to content

Commit

Permalink
feat(winget): arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Sep 14, 2021
1 parent 83fc902 commit ebaa20e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 28 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/release.yml
Expand Up @@ -239,8 +239,9 @@ jobs:
needs: [release, artifacts]
if: ${{ needs.release.outputs.skipped == 'false' }}
runs-on: windows-latest
outputs:
hash: ${{ steps.hash.outputs.hash_inno }}
strategy:
matrix:
arch: [amd64, arm64]
defaults:
run:
shell: pwsh
Expand All @@ -249,21 +250,21 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Build installer
run: ./build.ps1 -Version ${{ needs.release.outputs.version }}
run: ./build.ps1 -Architecture ${{ matrix.arch }} -Version ${{ needs.release.outputs.version }}
- name: Output Hash
id: hash
run: |
$hash = Get-Content -Path Output/install.exe.sha256
Write-Output "::set-output name=hash_inno::$($hash)"
$hash = Get-Content -Path Output/install-${{ matrix.arch }}.exe.sha256
Write-Output "::set-output name=hash_inno_${{ matrix.arch }}::$($hash)"
- 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_path: ${{ github.workspace }}/packages/inno/Output/install-${{ matrix.arch }}.exe
asset_name: install-${{ matrix.arch }}.exe
asset_content_type: text/plain
- name: Upload Inno Installer Hash
id: upload-inno-installer-hash
Expand All @@ -272,8 +273,8 @@ jobs:
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_path: ${{ github.workspace }}/packages/inno/Output/install-${{ matrix.arch }}.exe.sha256
asset_name: install-${{ matrix.arch }}.exe.sha256
asset_content_type: text/plain
winget:
needs: [release, inno]
Expand All @@ -289,4 +290,4 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Create manifest and submit PR
run: ./build.ps1 -Version ${{ needs.release.outputs.version }} -Hash ${{ needs.inno.outputs.hash }} -Token $env:WINGETCREATE_TOKEN
run: ./build.ps1 -Version ${{ needs.release.outputs.version }} -Token $env:WINGETCREATE_TOKEN
17 changes: 11 additions & 6 deletions packages/inno/build.ps1
@@ -1,5 +1,8 @@
Param
(
[parameter(Mandatory = $true)]
[ValidateSet('amd64', 'arm64')]
[System.String]$Architecture,
[parameter(Mandatory = $true)]
[string]
$Version
Expand All @@ -9,17 +12,19 @@ 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-posh/releases/download/v$Version/$($_.name)"
@{file = "posh-windows-$Architecture.exe"; name = "oh-my-posh.exe" }, @{file = "posh-linux-$Architecture"; name = "oh-my-posh-wsl" } | ForEach-Object -Process {
$download = "https://github.com/jandedobbeleer/oh-my-posh/releases/download/v$Version/$($_.file)"
Invoke-WebRequest $download -Out "./bin/$($_.name)"
}
# license
Invoke-WebRequest "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/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"
$ISSName = ".oh-my-posh-$Architecture-$Version.iss"
$content | Out-File -Encoding 'UTF8' $ISSName
# package content
ISCC.exe ".oh-my-posh-$Version.iss"
$installer = "install-$Architecture"
ISCC.exe /F$installer $ISSName
# get hash
$zipHash = Get-FileHash 'Output/install.exe' -Algorithm SHA256
$zipHash.Hash | Out-File -Encoding 'UTF8' 'Output/install.exe.sha256'
$zipHash = Get-FileHash "Output/$installer.exe" -Algorithm SHA256
$zipHash.Hash | Out-File -Encoding 'UTF8' "Output/$installer.exe.sha256"
5 changes: 2 additions & 3 deletions packages/inno/oh-my-posh.iss
Expand Up @@ -11,9 +11,8 @@ 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\oh-my-posh.exe"; DestDir: "{app}\bin"
Source: "bin\oh-my-posh-wsl"; DestDir: "{app}\bin"
Source: "bin\themes\*"; DestDir: "{app}\themes"

[Registry]
Expand Down
8 changes: 6 additions & 2 deletions packages/winget/JanDeDobbeleer.OhMyPosh.installer.yaml
Expand Up @@ -5,7 +5,11 @@ InstallModes:
Installers:
- Architecture: x64
InstallerType: inno
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install.exe
InstallerSha256: <HASH>
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-amd64.exe
InstallerSha256: <HASH-AMD64>
- Architecture: arm64
InstallerType: inno
InstallerUrl: https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v<VERSION>/install-arm64.exe
InstallerSha256: <HASH-ARM64>
ManifestType: "installer"
ManifestVersion: 1.0.0
30 changes: 23 additions & 7 deletions packages/winget/build.ps1
Expand Up @@ -4,15 +4,25 @@ Param
[parameter(Mandatory = $true)]
[string]
$Version,
[parameter(Mandatory = $true)]
[string]
$Hash,
[parameter(Mandatory = $false)]
[string]
$Token
)

function Set-Version {
function Get-HashForArchitecture {
param (
[parameter(Mandatory = $true)]
[string]
$Architecture,
[parameter(Mandatory = $true)]
[string]
$Version
)
$hash = (new-object Net.WebClient).DownloadString("https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v$Version/install-$Architecture.exe.sha256")
return $hash
}

function Write-MetaData {
param (
[parameter(Mandatory = $true)]
[string]
Expand All @@ -22,18 +32,24 @@ function Set-Version {
$Version,
[parameter(Mandatory = $true)]
[string]
$Hash
$HashAmd64,
[parameter(Mandatory = $true)]
[string]
$HashArm64
)
$content = Get-Content $FileName -Raw
$content = $content.Replace('<VERSION>', $Version)
$content = $content.Replace('<HASH>', $Hash)
$content = $content.Replace('<HASH-AMD64>', $HashAmd64)
$content = $content.Replace('<HASH-ARM64>', $HashArm64)
$content | Out-File -Encoding 'UTF8' "./$Version/$FileName"
}

New-Item -Path $PWD -Name $Version -ItemType "directory"
# Get all files inside the folder and adjust the version/hash
$HashAmd64 = Get-HashForArchitecture -Architecture 'amd64' -Version $Version
$HashArm64 = Get-HashForArchitecture -Architecture 'arm64' -Version $Version
Get-ChildItem '*.yaml' | ForEach-Object -Process {
Set-Version -FileName $_.Name -Version $Version -Hash $hash
Write-MetaData -FileName $_.Name -Version $Version -HashAmd64 $HashAmd64 -HashArm64 $HashArm64
}
if (-not $Token) {
return
Expand Down

0 comments on commit ebaa20e

Please sign in to comment.