ref: 58181c2d7392e3d780458a641076d0168e263f0c
parent: 0f86084e08c20bbba44c60c981776c54e7101aab
author: ISSOtm <eldredhabert0@gmail.com>
date: Sun Oct 16 07:38:08 EDT 2022
Hoist common Windows dep grabbing code to a script Function courtesy of @aaaaaa123456789
--- /dev/null
+++ b/.github/scripts/get_win_deps.ps1
@@ -1,0 +1,23 @@
+function getlibrary ([string] $URI, [string] $filename, [string] $hash, [string] $destdir) {
+ $wc = New-Object Net.WebClient
+ [string] $downloadhash = $null
+ try {
+ $wc.DownloadFile($URI, $filename)
+ $downloadhash = $(Get-FileHash $filename -Algorithm SHA256).Hash
+ } catch {
+ Write-Host "${filename}: failed to download"
+ exit 1
+ }
+ if ($hash -ne $downloadhash) {
+ Write-Host "${filename}: SHA256 mismatch ($downloadhash)"
+ exit 1
+ }
+ Expand-Archive -DestinationPath $destdir $filename
+}
+
+getlibrary 'https://www.zlib.net/zlib1213.zip' 'zlib.zip' 'd233fca7cf68db4c16dc5287af61f3cd01ab62495224c66639ca3da537701e42' .
+getlibrary 'https://download.sourceforge.net/libpng/lpng1637.zip' 'libpng.zip' '3b4b1cbd0bae6822f749d39b1ccadd6297f05e2b85a83dd2ce6ecd7d09eabdf2' .
+getlibrary 'https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_bison-2.5.24.zip' 'winflexbison.zip' '39c6086ce211d5415500acc5ed2d8939861ca1696aee48909c7f6daf5122b505' install_dir
+
+Move-Item zlib-1.2.13 zlib
+Move-Item lpng1637 libpng
--- a/.github/workflows/create-release-artifacts.yaml
+++ b/.github/workflows/create-release-artifacts.yaml
@@ -25,31 +25,8 @@
VERSION="${{ github.ref_name }}"
echo "version=${VERSION#v}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- - name: Get zlib, libpng and bison
- run: | # TODO: use an array; remember to update the versions being downloaded, *and* the paths being extracted! (`Move-Item`)
- $wc = New-Object System.Net.WebClient
- $wc.DownloadFile('https://www.zlib.net/zlib1213.zip', 'zlib.zip')
- $hash = (Get-FileHash "zlib.zip" -Algorithm SHA256).Hash
- if ($hash -ne 'd233fca7cf68db4c16dc5287af61f3cd01ab62495224c66639ca3da537701e42') {
- Write-Host "zlib SHA256 mismatch! ($hash)"
- exit 1
- }
- $wc.DownloadFile('https://download.sourceforge.net/libpng/lpng1637.zip', 'libpng.zip')
- $hash = (Get-FileHash "libpng.zip" -Algorithm SHA256).Hash
- if ($hash -ne '3b4b1cbd0bae6822f749d39b1ccadd6297f05e2b85a83dd2ce6ecd7d09eabdf2') {
- Write-Host "libpng SHA256 mismatch! ($hash)"
- exit 1
- }
- $wc.DownloadFile('https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_bison-2.5.24.zip', 'winflexbison.zip')
- $hash = (Get-FileHash "winflexbison.zip" -Algorithm SHA256).Hash
- if ($hash -ne '39c6086ce211d5415500acc5ed2d8939861ca1696aee48909c7f6daf5122b505') {
- Write-Host "bison SHA256 mismatch! ($hash)"
- }
- Expand-Archive -DestinationPath . "zlib.zip"
- Expand-Archive -DestinationPath . "libpng.zip"
- Expand-Archive -DestinationPath install_dir "winflexbison.zip"
- Move-Item zlib-1.2.13 zlib
- Move-Item lpng1637 libpng
+ - name: Install deps
+ run: .github/scripts/get_win_deps.ps1
- uses: actions/cache@v3
id: cache
with:
--- a/.github/workflows/testing.yml
+++ b/.github/workflows/testing.yml
@@ -76,31 +76,8 @@
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- - name: Get zlib, libpng and bison
- run: | # TODO: use an array; remember to update the versions being downloaded, *and* the paths being extracted! (`Move-Item`)
- $wc = New-Object System.Net.WebClient
- $wc.DownloadFile('https://www.zlib.net/zlib1213.zip', 'zlib.zip')
- $hash = (Get-FileHash "zlib.zip" -Algorithm SHA256).Hash
- if ($hash -ne 'd233fca7cf68db4c16dc5287af61f3cd01ab62495224c66639ca3da537701e42') {
- Write-Host "zlib SHA256 mismatch! ($hash)"
- exit 1
- }
- $wc.DownloadFile('https://download.sourceforge.net/libpng/lpng1637.zip', 'libpng.zip')
- $hash = (Get-FileHash "libpng.zip" -Algorithm SHA256).Hash
- if ($hash -ne '3b4b1cbd0bae6822f749d39b1ccadd6297f05e2b85a83dd2ce6ecd7d09eabdf2') {
- Write-Host "libpng SHA256 mismatch! ($hash)"
- exit 1
- }
- $wc.DownloadFile('https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_bison-2.5.24.zip', 'winflexbison.zip')
- $hash = (Get-FileHash "winflexbison.zip" -Algorithm SHA256).Hash
- if ($hash -ne '39c6086ce211d5415500acc5ed2d8939861ca1696aee48909c7f6daf5122b505') {
- Write-Host "bison SHA256 mismatch! ($hash)"
- }
- Expand-Archive -DestinationPath . "zlib.zip"
- Expand-Archive -DestinationPath . "libpng.zip"
- Expand-Archive -DestinationPath install_dir "winflexbison.zip"
- Move-Item zlib-1.2.13 zlib
- Move-Item lpng1637 libpng
+ - name: Install deps
+ run: .github/scripts/get_win_deps.ps1
- uses: actions/cache@v3
id: cache
with: