From 0c0583f8e7314cfcf00033f7cd5ec0dbaa2d9ebf Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Thu, 29 Feb 2024 21:53:53 +0100 Subject: [PATCH] CI: Install gettext for Windows Before that the gettext command shipping with git for Windows were used. Since git 2.44.0 these are no longer bundled. # Conflicts: # .github/workflows/package-pypi.yml # .github/workflows/package-windows.yml --- .github/workflows/package-pypi.yml | 10 ++++++++++ .github/workflows/package.yml | 8 ++++++++ .github/workflows/run-tests.yml | 9 +++++++++ scripts/package/win-common.ps1 | 27 ++++++++++++++++++++++++++ scripts/package/win-setup-gettext.ps1 | 20 +++++++++++++++++++ scripts/package/win-setup.ps1 | 28 ++------------------------- 6 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 scripts/package/win-setup-gettext.ps1 diff --git a/.github/workflows/package-pypi.yml b/.github/workflows/package-pypi.yml index 942b04d94..795dbb284 100644 --- a/.github/workflows/package-pypi.yml +++ b/.github/workflows/package-pypi.yml @@ -85,6 +85,16 @@ jobs: brew install gettext brew link gettext --force echo "/usr/local/opt/gettext/bin" >> $GITHUB_PATH + - name: Install gettext (Windows) + if: runner.os == 'Windows' + run: | + & .\scripts\package\win-setup-gettext.ps1 ` + -GettextVersion $Env:GETTEXT_VERSION -GettextSha256Sum $Env:GETTEXT_SHA256SUM + Add-Content $env:GITHUB_PATH (Join-Path -Path (Resolve-Path .) -ChildPath gettext\bin) + shell: pwsh + env: + GETTEXT_VERSION: 0.22.4 + GETTEXT_SHA256SUM: 220068ac0b9e7aedda03534a3088e584640ac1e639800b3a0baa9410aa6d012a - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 96785cd36..1834f53a9 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -154,6 +154,14 @@ jobs: DISCID_SHA256SUM: 330199495d71f71251e91eb0b4e3103b6c663fea09ffc9fd3e5108d48e0452c8 FPCALC_VERSION: 1.5.1 FPCALC_SHA256SUM: 36b478e16aa69f757f376645db0d436073a42c0097b6bb2677109e7835b59bbc + - name: Install gettext + run: | + & .\scripts\package\win-setup-gettext.ps1 ` + -GettextVersion $Env:GETTEXT_VERSION -GettextSha256Sum $Env:GETTEXT_SHA256SUM + Add-Content $env:GITHUB_PATH (Join-Path -Path (Resolve-Path .) -ChildPath gettext\bin) + env: + GETTEXT_VERSION: 0.22.4 + GETTEXT_SHA256SUM: 220068ac0b9e7aedda03534a3088e584640ac1e639800b3a0baa9410aa6d012a - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a0f468b45..f97f60a27 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -122,6 +122,15 @@ jobs: brew install gettext brew link gettext --force echo "/usr/local/opt/gettext/bin" >> $GITHUB_PATH + - name: Install gettext (Windows) + if: runner.os == 'Windows' + run: | + & .\scripts\package\win-setup-gettext.ps1 ` + -GettextVersion $Env:GETTEXT_VERSION -GettextSha256Sum $Env:GETTEXT_SHA256SUM + Add-Content $env:GITHUB_PATH (Join-Path -Path (Resolve-Path .) -ChildPath gettext\bin) + env: + GETTEXT_VERSION: 0.22.4 + GETTEXT_SHA256SUM: 220068ac0b9e7aedda03534a3088e584640ac1e639800b3a0baa9410aa6d012a - name: Run pip install . run: | python -m pip install --upgrade pip diff --git a/scripts/package/win-common.ps1 b/scripts/package/win-common.ps1 index 30e09fb50..5e8c6d6e7 100644 --- a/scripts/package/win-common.ps1 +++ b/scripts/package/win-common.ps1 @@ -54,3 +54,30 @@ Function FinalizePackage { Move-Item -Path (Join-Path -Path $Qt5BinDir -ChildPath *.dll) -Destination $Path -Force Remove-Item -Path $Qt5BinDir } + +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") +} + +Function VerifyHash { + Param( + [Parameter(Mandatory = $true)] + [String] + $FileName, + [Parameter(Mandatory = $true)] + [String] + $Sha256Sum + ) + If ((Get-FileHash "$FileName").hash -ne "$Sha256Sum") { + Throw "Invalid SHA256 hash for $FileName" + } +} diff --git a/scripts/package/win-setup-gettext.ps1 b/scripts/package/win-setup-gettext.ps1 new file mode 100644 index 000000000..2975a6da5 --- /dev/null +++ b/scripts/package/win-setup-gettext.ps1 @@ -0,0 +1,20 @@ +Param( + [Parameter(Mandatory = $true)] + [String] + $GettextVersion, + [Parameter(Mandatory = $true)] + [String] + $GettextSha256Sum +) + +$ErrorActionPreference = "Stop" + +$ScriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent +. $ScriptDirectory\win-common.ps1 + +$ArchiveFile = ".\gettext-tools-windows.zip" +Write-Output "Downloading gettext-tools-windows $GettextVersion to $ArchiveFile..." +DownloadFile -Url "https://github.com/vslavik/gettext-tools-windows/releases/download/v$GettextVersion/gettext-tools-windows-$GettextVersion.zip" ` + -FileName $ArchiveFile +VerifyHash -FileName $ArchiveFile -Sha256Sum $GettextSha256Sum +Expand-Archive -Path $ArchiveFile -DestinationPath .\gettext -Force diff --git a/scripts/package/win-setup.ps1 b/scripts/package/win-setup.ps1 index ede348c63..60e7817cc 100644 --- a/scripts/package/win-setup.ps1 +++ b/scripts/package/win-setup.ps1 @@ -15,32 +15,8 @@ Param( $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") -} - -Function VerifyHash { - Param( - [Parameter(Mandatory = $true)] - [String] - $FileName, - [Parameter(Mandatory = $true)] - [String] - $Sha256Sum - ) - If ((Get-FileHash "$FileName").hash -ne "$Sha256Sum") { - Throw "Invalid SHA256 hash for $FileName" - } -} +$ScriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent +. $ScriptDirectory\win-common.ps1 New-Item -Name .\build -ItemType Directory -ErrorAction Ignore