This commit is contained in:
Grisha 2025-04-23 09:18:07 +03:00 committed by GitHub
commit 67cb221442
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 133 additions and 0 deletions

View file

@ -102,6 +102,51 @@ jobs:
path: "*.msi" path: "*.msi"
if-no-files-found: error if-no-files-found: error
build-zip-windows:
strategy:
fail-fast: false
matrix:
pkgarch: ["x64", "x86", "arm", "arm64"]
name: Package (Windows-zip, ${{ matrix.pkgarch }})
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4
- name: Get info
id: vars
run: |
echo "PKGNAME=$(contrib/semver/name.sh)" >> $GITHUB_ENV
echo "PKGVERSION=$(contrib/msi/msversion.sh --bare)" >> $GITHUB_ENV
shell: bash
- name: Build package
run: sh contrib/zip/build-zip.sh ${{ matrix.pkgarch }}
- name: Archive Release
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: '${{ env.PKGNAME }}-${{ env.PKGVERSION }}-${{ matrix.pkgarch }}.zip'
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Windows zip package (${{ matrix.pkgarch }})
path: "*.zip"
if-no-files-found: error
build-packages-router: build-packages-router:
strategy: strategy:
fail-fast: false fail-fast: false

88
contrib/zip/build-zip.sh Normal file
View file

@ -0,0 +1,88 @@
#!/bin/sh
PKGARCH=$1
if [ "${PKGARCH}" == "" ];
then
echo "tell me the architecture: x86, x64, arm or arm64"
exit 1
fi
# Download the wix tools!
dotnet tool install --global wix --version 5.0.0
# Build Yggdrasil!
[ "${PKGARCH}" == "x64" ] && GOOS=windows GOARCH=amd64 CGO_ENABLED=0 ./build
[ "${PKGARCH}" == "x86" ] && GOOS=windows GOARCH=386 CGO_ENABLED=0 ./build
[ "${PKGARCH}" == "arm" ] && GOOS=windows GOARCH=arm CGO_ENABLED=0 ./build
[ "${PKGARCH}" == "arm64" ] && GOOS=windows GOARCH=arm64 CGO_ENABLED=0 ./build
# Create the postinstall script
cat > start.bat << EOF
@echo off
net session >nul 2>&1
if %errorlevel% neq 0 (
powershell -Command "Start-Process '%~0' -Verb RunAs"
exit /b
)
set "SCRIPT_DIR=%~dp0"
if not exist "%SCRIPT_DIR%yggdrasil.conf" (
if exist "%SCRIPT_DIR%yggdrasil.exe" (
echo Generating yggdrasil.conf...
"%SCRIPT_DIR%yggdrasil.exe" -genconf > "%SCRIPT_DIR%yggdrasil.conf"
if errorlevel 1 (
echo Failed to generate the configuration file!
pause
exit /b 1
)
) else (
echo yggdrasil.exe not found!
pause
exit /b 1
)
)
if exist "%SCRIPT_DIR%yggdrasil.conf" (
echo Starting Yggdrasil with the configuration file...
"%SCRIPT_DIR%yggdrasil.exe" -useconffile "%SCRIPT_DIR%yggdrasil.conf"
if errorlevel 1 (
echo Failed to start Yggdrasil!
pause
exit /b 1
)
) else (
echo yggdrasil.conf file is missing!
pause
exit /b 1
)
EOF
# Download the Wintun driver
if [ ! -d wintun ];
then
curl -o wintun.zip https://www.wintun.net/builds/wintun-0.14.1.zip
if [ `sha256sum wintun.zip | cut -f 1 -d " "` != "07c256185d6ee3652e09fa55c0b673e2624b565e02c4b9091c79ca7d2f24ef51" ];
then
echo "wintun package didn't match expected checksum"
exit 1
fi
unzip wintun.zip
fi
if [ $PKGARCH = "x64" ]; then
mv ./wintun/bin/amd64/wintun.dll ./wintun.dll
elif [ $PKGARCH = "x86" ]; then
mv ./wintun/bin/x86/wintun.dll ./wintun.dll
elif [ $PKGARCH = "arm" ]; then
mv ./wintun/bin/arm/wintun.dll ./wintun.dll
elif [ $PKGARCH = "arm64" ]; then
mv ./wintun/bin/arm64/wintun.dll ./wintun.dll
else
echo "wasn't sure which architecture to get wintun for"
exit 1
fi
rm -rf ./wintun
find . -type f ! -name 'yggdrasilctl.exe' ! -name 'yggdrasil.exe' ! -name 'wintun.dll' ! -name 'start.bat' -delete
find . -depth -type d -empty -delete