feat(winget): arm64 support

This commit is contained in:
Jan De Dobbeleer 2021-09-14 18:13:33 +02:00 committed by Jan De Dobbeleer
parent 83fc90273f
commit ebaa20ea3f
5 changed files with 53 additions and 28 deletions

View file

@ -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
@ -249,12 +250,12 @@ 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
@ -262,8 +263,8 @@ jobs:
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
@ -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]
@ -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

View file

@ -1,5 +1,8 @@
Param
(
[parameter(Mandatory = $true)]
[ValidateSet('amd64', 'arm64')]
[System.String]$Architecture,
[parameter(Mandatory = $true)]
[string]
$Version
@ -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"

View file

@ -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]

View file

@ -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

View file

@ -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]
@ -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