copilot-swe-agent[bot] 02c0810561 Simplify vcpkg library count in packaging step
Co-authored-by: Valorith <76063792+Valorith@users.noreply.github.com>
2026-01-25 04:04:13 +00:00

375 lines
13 KiB
YAML

name: Release
on:
push:
branches:
- master
tags:
- 'v*'
jobs:
build-linux:
name: Build Linux
runs-on: ubuntu-latest
container:
image: akkadius/eqemu-server:v16
# Run as root to avoid EACCES on GitHub Actions runner file command writes in the container.
options: --user 0
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: recursive
- name: Mark workspace safe
shell: bash
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-release-ccache-${{ hashFiles('.github/workflows/release.yaml') }}
- name: Install dependencies
shell: bash
run: |
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential ninja-build ccache uuid-dev
- name: Configure
shell: bash
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DEQEMU_BUILD_LOGIN=ON \
-DEQEMU_BUILD_LUA=ON \
-DEQEMU_BUILD_PERL=ON \
-DEQEMU_BUILD_CLIENT_FILES=ON
- name: Build
shell: bash
run: cmake --build build --parallel
- name: Package binaries
shell: bash
run: |
cd build/bin
# Verify that critical binaries exist
REQUIRED_BINARIES=(world zone ucs queryserv eqlaunch shared_memory loginserver import_client_files export_client_files)
MISSING_BINARIES=()
for binary in "${REQUIRED_BINARIES[@]}"; do
if [ ! -f "$binary" ]; then
MISSING_BINARIES+=("$binary")
fi
done
if [ ${#MISSING_BINARIES[@]} -ne 0 ]; then
echo "Error: Required binaries not found: ${MISSING_BINARIES[*]}"
echo "Build may have failed. Refusing to create incomplete package."
exit 1
fi
ZIP_CONTENTS=""
zip_add() {
zip -uj eqemu-server-linux-x64.zip "$1"
}
zip_add_unique() {
local target_name
target_name="$(basename "$1")"
if [ -f eqemu-server-linux-x64.zip ] && printf '%s\n' "$ZIP_CONTENTS" | grep -qx "$target_name"; then
echo "Skipping duplicate library: $target_name"
return 0
fi
zip_add "$1"
ZIP_CONTENTS="${ZIP_CONTENTS}${target_name}"$'\n'
}
# Add all executable files (excluding tests)
for f in *; do
if [ -f "$f" ] && [ -x "$f" ] && [ "$f" != "tests" ]; then
zip_add_unique "$f"
fi
done
# Add shared libraries needed for runtime (from build/bin, build/libs, and vcpkg_installed)
bin_lib_count="$(find . -maxdepth 1 -type f \( -name "*.so" -o -name "*.so.[0-9]*" \) | wc -l)"
if [ "$bin_lib_count" -gt 0 ]; then
find . -maxdepth 1 -type f \( -name "*.so" -o -name "*.so.[0-9]*" \) -print0 | \
while IFS= read -r -d '' lib; do
zip_add_unique "$lib"
done
fi
if [ -d ../libs ]; then
lib_count="$(find ../libs -type f \( -name "*.so" -o -name "*.so.[0-9]*" \) | wc -l)"
if [ "$lib_count" -gt 0 ]; then
find ../libs -type f \( -name "*.so" -o -name "*.so.[0-9]*" \) -print0 | \
while IFS= read -r -d '' lib; do
zip_add_unique "$lib"
done
else
echo "No shared libraries found in build/libs"
fi
else
echo "No build/libs directory found; skipping shared library packaging"
fi
for vcpkg_dir in ../vcpkg_installed ../../vcpkg_installed; do
if [ -d "$vcpkg_dir" ]; then
lib_count="$(find "$vcpkg_dir" -type f \( -name "*.so" -o -name "*.so.[0-9]*" \) ! -path "*/debug/*" -print | wc -l)"
if [ "$lib_count" -gt 0 ]; then
find "$vcpkg_dir" -type f \( -name "*.so" -o -name "*.so.[0-9]*" \) ! -path "*/debug/*" -print0 | \
while IFS= read -r -d '' lib; do
zip_add_unique "$lib"
done
else
echo "No shared libraries found in $vcpkg_dir"
fi
else
echo "No $vcpkg_dir directory found; skipping vcpkg shared library packaging"
fi
done
# Verify zip file was created and contains files
if [ ! -f eqemu-server-linux-x64.zip ]; then
echo "Error: Failed to create zip file"
exit 1
fi
FILE_COUNT=$(unzip -Z1 eqemu-server-linux-x64.zip | wc -l)
EXPECTED_MIN_FILES=${#REQUIRED_BINARIES[@]}
if [ "$FILE_COUNT" -lt "$EXPECTED_MIN_FILES" ]; then
echo "Error: Zip file contains fewer than expected files ($FILE_COUNT, expected at least $EXPECTED_MIN_FILES)"
unzip -l eqemu-server-linux-x64.zip
exit 1
fi
echo "Successfully packaged $FILE_COUNT files"
ls -lh eqemu-server-linux-x64.zip
echo ""
echo "Package contents:"
unzip -l eqemu-server-linux-x64.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: eqemu-server-linux-x64
path: build/bin/eqemu-server-linux-x64.zip
retention-days: 90
build-windows:
name: Build Windows
runs-on: windows-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
submodules: recursive
- name: Enable long paths
run: git config --global core.longpaths true
- name: Setup MSVC environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Configure
shell: pwsh
run: |
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DEQEMU_BUILD_LOGIN=ON `
-DEQEMU_BUILD_LUA=ON `
-DEQEMU_BUILD_ZLIB=ON `
-DEQEMU_BUILD_PERL=ON `
-DEQEMU_BUILD_CLIENT_FILES=ON
- name: Build
shell: pwsh
run: cmake --build build --config RelWithDebInfo --target ALL_BUILD -- /m:4
- name: Package binaries
shell: pwsh
run: |
$binDir = "build/bin/RelWithDebInfo"
$outZip = "eqemu-server-windows-x64.zip"
# Minimum expected zip size (core binaries should be at least this size)
$minZipSize = 100KB
# Verify that critical binaries exist
$requiredBinaries = @("world.exe", "zone.exe", "ucs.exe", "queryserv.exe", "eqlaunch.exe", "shared_memory.exe", "loginserver.exe", "import_client_files.exe", "export_client_files.exe")
$missingBinaries = @()
foreach ($binary in $requiredBinaries) {
$path = Join-Path $binDir $binary
if (-not (Test-Path $path)) {
$missingBinaries += $binary
}
}
if ($missingBinaries.Count -gt 0) {
Write-Host "Error: Required binaries not found: $($missingBinaries -join ', ')"
Write-Host "Build may have failed. Refusing to create incomplete package."
exit 1
}
# Collect all exe and dll files
$files = @()
# Add executables (exclude tests.exe)
Get-ChildItem -Path $binDir -Filter "*.exe" | Where-Object { $_.Name -ne "tests.exe" } | ForEach-Object {
$files += $_.FullName
}
# Add DLLs from bin directory
Get-ChildItem -Path $binDir -Filter "*.dll" -ErrorAction SilentlyContinue | ForEach-Object {
$files += $_.FullName
}
# Add zlib DLLs if they exist
$zlibDir = "build/libs/zlibng/RelWithDebInfo"
if (Test-Path $zlibDir) {
Get-ChildItem -Path $zlibDir -Filter "*.dll" -ErrorAction SilentlyContinue | ForEach-Object {
$files += $_.FullName
}
}
# Verify we have files to package
if ($files.Count -eq 0) {
Write-Host "Error: No files found to package"
exit 1
}
# Create zip
Compress-Archive -Path $files -DestinationPath $outZip -Force
# Verify zip was created successfully
if (-not (Test-Path $outZip)) {
Write-Host "Error: Failed to create zip file"
exit 1
}
# Verify zip contains files (should contain at least the core binaries)
$zipInfo = Get-Item $outZip
if ($zipInfo.Length -lt $minZipSize) {
Write-Host "Error: Zip file is suspiciously small ($($zipInfo.Length) bytes, expected at least $minZipSize)"
exit 1
}
# Show contents
Write-Host "Successfully packaged $($files.Count) files"
Write-Host "Package contents:"
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = [System.IO.Compression.ZipFile]::OpenRead($outZip)
try {
foreach ($entry in $zip.Entries) {
Write-Host (" - {0} ({1} bytes)" -f $entry.FullName, $entry.Length)
}
}
finally {
$zip.Dispose()
}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: eqemu-server-windows-x64
path: eqemu-server-windows-x64.zip
retention-days: 90
release:
name: Create Release
needs: [build-linux, build-windows]
runs-on: ubuntu-latest
# Only run on tag pushes
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: eqemu-server-linux-x64
path: artifacts/
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: eqemu-server-windows-x64
path: artifacts/
- name: List artifacts
run: ls -la artifacts/
- name: Generate checksums
run: |
cd artifacts
sha256sum *.zip > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
generate_release_notes: true
files: |
artifacts/eqemu-server-linux-x64.zip
artifacts/eqemu-server-windows-x64.zip
artifacts/SHA256SUMS.txt
- name: Notify Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
TAG_NAME: ${{ github.ref_name }}
REPO: ${{ github.repository }}
run: |
if [ -z "$DISCORD_WEBHOOK_URL" ]; then
echo "DISCORD_WEBHOOK_URL is not set; skipping Discord notification."
exit 0
fi
LINUX_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/eqemu-server-linux-x64.zip"
WINDOWS_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/eqemu-server-windows-x64.zip"
SHA_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/SHA256SUMS.txt"
payload=$(jq -n \
--arg tag "$TAG_NAME" \
--arg repo "$REPO" \
--arg linux "$LINUX_URL" \
--arg windows "$WINDOWS_URL" \
--arg sha "$SHA_URL" \
--arg footer "Clumsy's World EQEmu Release" \
'{
embeds: [
{
title: ("Release " + $tag),
url: ("https://github.com/" + $repo + "/releases/tag/" + $tag),
color: 5793266,
thumbnail: { url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" },
fields: [
{ name: "Linux (x64)", value: ("[Download](" + $linux + ")"), inline: true },
{ name: "Windows (x64)", value: ("[Download](" + $windows + ")"), inline: true },
{ name: "Checksums", value: ("[SHA256SUMS.txt](" + $sha + ")"), inline: false }
],
footer: { text: $footer }
}
]
}')
response_file=$(mktemp)
trap 'rm -f "$response_file"' EXIT
http_code=$(curl -sS -o "$response_file" -w "%{http_code}" \
-H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL")
curl_status=$?
if [ $curl_status -ne 0 ]; then
echo "Failed to send Discord notification (curl exit $curl_status)."
exit 0
fi
if [ "$http_code" -lt 200 ] || [ "$http_code" -ge 300 ]; then
echo "Discord notification failed with HTTP $http_code: $(cat "$response_file")"
echo "Continuing without failing the release job."
fi