mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-28 13:27:15 +00:00
Merge pull request #24 from Valorith/copilot/modify-linux-job-for-artifacts
Containerize Linux build/test and package runtime shared libs
This commit is contained in:
@@ -9,6 +9,10 @@ jobs:
|
|||||||
linux:
|
linux:
|
||||||
name: Linux
|
name: Linux
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout source
|
- name: Checkout source
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
@@ -18,30 +22,38 @@ jobs:
|
|||||||
- name: Setup ccache
|
- name: Setup ccache
|
||||||
uses: hendrikmuhs/ccache-action@v1.2
|
uses: hendrikmuhs/ccache-action@v1.2
|
||||||
with:
|
with:
|
||||||
key: ${{ runner.os }}-ccache
|
key: ${{ runner.os }}-ccache-${{ hashFiles('CMakeLists.txt', '.github/workflows/build.yaml') }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Ensure ccache installed
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
if ! command -v ccache >/dev/null 2>&1; then
|
||||||
sudo apt-get install -y build-essential ninja-build ccache uuid-dev
|
echo "ccache not found in container; installing."
|
||||||
|
apt-get update -qq
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq ccache
|
||||||
|
command -v ccache >/dev/null 2>&1 || { echo "ccache install failed"; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Configure
|
- name: Mark workspace safe
|
||||||
|
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
run: |
|
run: |
|
||||||
cmake -S . -B build -G Ninja \
|
mkdir -p build && cd build
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
cmake \
|
||||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
|
||||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
||||||
-DEQEMU_BUILD_TESTS=ON \
|
-DEQEMU_BUILD_TESTS=ON \
|
||||||
-DEQEMU_BUILD_LOGIN=ON \
|
-DEQEMU_BUILD_LOGIN=ON \
|
||||||
-DEQEMU_BUILD_LUA=ON \
|
-DEQEMU_BUILD_LUA=ON \
|
||||||
-DEQEMU_BUILD_PERL=ON \
|
-DEQEMU_BUILD_PERL=ON \
|
||||||
-DEQEMU_BUILD_CLIENT_FILES=ON
|
-DEQEMU_BUILD_CLIENT_FILES=ON \
|
||||||
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||||
- name: Build
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||||
run: cmake --build build --parallel
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
|
..
|
||||||
|
make -j"$(nproc)"
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: build
|
working-directory: ${{ github.workspace }}/build
|
||||||
run: ./bin/tests
|
run: ./bin/tests
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
|
|||||||
@@ -11,12 +11,19 @@ jobs:
|
|||||||
build-linux:
|
build-linux:
|
||||||
name: Build Linux
|
name: Build Linux
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Checkout source
|
- name: Checkout source
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Mark workspace safe
|
||||||
|
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
- name: Setup ccache
|
- name: Setup ccache
|
||||||
uses: hendrikmuhs/ccache-action@v1.2
|
uses: hendrikmuhs/ccache-action@v1.2
|
||||||
with:
|
with:
|
||||||
@@ -24,8 +31,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
apt-get update -qq
|
||||||
sudo apt-get install -y build-essential ninja-build ccache uuid-dev
|
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential ninja-build ccache uuid-dev
|
||||||
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: |
|
run: |
|
||||||
@@ -61,13 +68,51 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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)
|
# Add all executable files (excluding tests)
|
||||||
for f in *; do
|
for f in *; do
|
||||||
if [ -f "$f" ] && [ -x "$f" ] && [ "$f" != "tests" ]; then
|
if [ -f "$f" ] && [ -x "$f" ] && [ "$f" != "tests" ]; then
|
||||||
zip -uj eqemu-server-linux-x64.zip "$f"
|
zip_add_unique "$f"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Add shared libraries needed for runtime (from build/bin and build/libs)
|
||||||
|
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
|
||||||
|
|
||||||
# Verify zip file was created and contains files
|
# Verify zip file was created and contains files
|
||||||
if [ ! -f eqemu-server-linux-x64.zip ]; then
|
if [ ! -f eqemu-server-linux-x64.zip ]; then
|
||||||
echo "Error: Failed to create zip file"
|
echo "Error: Failed to create zip file"
|
||||||
|
|||||||
Reference in New Issue
Block a user