From e2e3c1d7cdcb157d8a09e84e7de60d96aae6632e Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Mon, 25 Nov 2019 21:17:12 +0100 Subject: [PATCH] Github Actions: Package Windows app --- .github/workflows/package-windows.yml | 43 +++++++++++++++++++++++ scripts/package/win-package-appx.ps1 | 4 +++ scripts/package/win-package-installer.ps1 | 4 +++ scripts/package/win-package-portable.ps1 | 4 +++ scripts/package/win-setup.ps1 | 39 ++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 .github/workflows/package-windows.yml create mode 100644 scripts/package/win-setup.ps1 diff --git a/.github/workflows/package-windows.yml b/.github/workflows/package-windows.yml new file mode 100644 index 000000000..7df475c44 --- /dev/null +++ b/.github/workflows/package-windows.yml @@ -0,0 +1,43 @@ +name: Package for Windows + +on: [push] + +jobs: + package: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Setup Windows build environment + run: | + & .\scripts\package\win-setup.ps1 -DiscidVersion $Env:DISCID_VERSION -FpcalVersion $Env:FPCALC_VERSION + env: + DISCID_VERSION: 0.6.2 + FPCALC_VERSION: 1.4.3 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-build.txt + pip install -r requirements-win.txt + - name: Build Windows 10 app package + run: | + $Env:PATH += ";C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64" + $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] + & .\scripts\package\win-package-appx.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate + - name: Build Windows installer + if: always() + run: | + choco install nsis + $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] + & .\scripts\package\win-package-installer.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate + dist\picard\fpcalc -version + - name: Build Windows portable app + if: always() + run: | + $Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0] + & .\scripts\package\win-package-portable.ps1 -BuildNumber $(git rev-list --count HEAD) -Certificate $Certificate diff --git a/scripts/package/win-package-appx.ps1 b/scripts/package/win-package-appx.ps1 index 392b88442..cde5ac039 100644 --- a/scripts/package/win-package-appx.ps1 +++ b/scripts/package/win-package-appx.ps1 @@ -7,6 +7,10 @@ Param( $BuildNumber ) +# Errors are handled explicitly. Otherwise any output to stderr when +# calling classic Windows exes causes a script error. +$ErrorActionPreference = 'Continue' + If (-Not $BuildNumber) { $BuildNumber = 0 } diff --git a/scripts/package/win-package-installer.ps1 b/scripts/package/win-package-installer.ps1 index 1efb752e3..5a075bb97 100644 --- a/scripts/package/win-package-installer.ps1 +++ b/scripts/package/win-package-installer.ps1 @@ -7,6 +7,10 @@ Param( $BuildNumber ) +# Errors are handled explicitly. Otherwise any output to stderr when +# calling classic Windows exes causes a script error. +$ErrorActionPreference = 'Continue' + If (-Not $BuildNumber) { $BuildNumber = 0 } diff --git a/scripts/package/win-package-portable.ps1 b/scripts/package/win-package-portable.ps1 index afe333338..8b5394eed 100644 --- a/scripts/package/win-package-portable.ps1 +++ b/scripts/package/win-package-portable.ps1 @@ -7,6 +7,10 @@ Param( $BuildNumber ) +# Errors are handled explicitly. Otherwise any output to stderr when +# calling classic Windows exes causes a script error. +$ErrorActionPreference = 'Continue' + If (-Not $BuildNumber) { $BuildNumber = 0 } diff --git a/scripts/package/win-setup.ps1 b/scripts/package/win-setup.ps1 new file mode 100644 index 000000000..ea2c49ff7 --- /dev/null +++ b/scripts/package/win-setup.ps1 @@ -0,0 +1,39 @@ +Param( + [Parameter(Mandatory=$true)] + [String] + $DiscidVersion, + [Parameter(Mandatory=$true)] + [String] + $FpcalVersion +) + +$ErrorActionPreference = "Stop" + +Function DownloadFile { + Param( + [Parameter(Mandatory=$true)] + [String] + $FileName, + [Parameter(Mandatory=$true)] + [String] + $Url + ) + $OutputPath = (Join-Path (Resolve-Path .) $FileName) + (New-Object System.Net.WebClient).DownloadFile($Url, "$OutputPath") +} + +New-Item -Name .\build -ItemType Directory -ErrorAction Ignore + +$ArchiveFile = ".\build\libdiscid.zip" +Write-Output "Downloading libdiscid to $ArchiveFile..." +DownloadFile -Url "https://github.com/metabrainz/libdiscid/releases/download/v$DiscidVersion/libdiscid-$DiscidVersion-win64.zip" ` + -FileName $ArchiveFile +Expand-Archive -Path $ArchiveFile -DestinationPath .\build\libdiscid -Force +Copy-Item .\build\libdiscid\discid.dll . + +$ArchiveFile = ".\build\fpcalc.zip" +Write-Output "Downloading chromaprint-fpcalc to $ArchiveFile..." +DownloadFile -Url "https://github.com/acoustid/chromaprint/releases/download/v$FpcalVersion/chromaprint-fpcalc-$FpcalVersion-windows-x86_64.zip" ` + -FileName $ArchiveFile +Expand-Archive -Path $ArchiveFile -DestinationPath .\build\fpcalc -Force +Copy-Item .\build\fpcalc\chromaprint-fpcalc-$FpcalVersion-windows-x86_64\fpcalc.exe .