Skip to content

refactor: li'l code cleanups #347

refactor: li'l code cleanups

refactor: li'l code cleanups #347

Workflow file for this run

name: Server
on:
push:
branches: [ main ]
paths-ignore:
- 'BallanceMMOClient/**'
- '.git*'
- 'README.md'
- '.github/workflows/client.yml'
pull_request:
branches: [ main ]
paths-ignore:
- 'BallanceMMOClient/**'
- '.git*'
- 'README.md'
- '.github/workflows/client.yml'
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build-server-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Fetch git submodules
run: git submodule update --init --recursive
- name: Install dependencies (OpenSSL, Protobuf)
run: sudo apt install libssl-dev libprotobuf-dev protobuf-compiler
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
echo -e "\nfile(WRITE version.txt \${BMMO_VER})" >> CMakeLists.txt
cmake -B ${{github.workspace}}/build -S ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SERVER=ON -DBUILD_CLIENT=OFF -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SERVER_APPIMAGE=ON
echo "BMMO_VER=$(cat version.txt)" >> "$GITHUB_ENV"
echo "SHA_SHORT=$(git rev-parse --short ${{github.sha}})" >> "$GITHUB_ENV"
- name: Build and install
# Build your program with the given configuration
working-directory: ${{github.workspace}}
run: DESTDIR=AppDir cmake --build ./build --config ${{env.BUILD_TYPE}} --target install
- name: Test
working-directory: ${{github.workspace}}
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}
- name: Build AppImage
working-directory: ${{github.workspace}}/build/BallanceMMOServer
run: |
curl -o linuxdeploy.AppImage -L https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20240109-1/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy.AppImage
appdeploy=$(./linuxdeploy.AppImage --appimage-extract | grep AppRun | head -n 1)
echo Got linuxdeploy exec entry at $appdeploy
$appdeploy --appdir ../AppDir --output appimage --desktop-file ../../BallanceMMOServer/appimage/BMMOLaunchSelector.desktop --icon-file ../../BallanceMMOServer/appimage/BallanceMMO.svg
- name: Prepare artifact directory and dry run
working-directory: ${{github.workspace}}/build/BallanceMMOServer
run: |
appfile=$(ls BallanceMMOLaunchSelector*.AppImage | awk '{print $1}')
chmod +x $appfile
mkdir artifacts
mv -t artifacts $appfile start_ballancemmo_loop.sh
server_binary=$(artifacts/$appfile --appimage-extract | grep "bin/BallanceMMOServer" | head -n 1)
chmod +x $server_binary && ./$server_binary --dry-run
- name: Release Artifact
uses: actions/upload-artifact@v3
with:
name: server-linux-${{env.BMMO_VER}}-${{env.SHA_SHORT}}
path: build/BallanceMMOServer/artifacts
build-server-windows:
runs-on: windows-latest
env:
VCPKG_ROOT: ${{github.workspace}}/submodule/vcpkg
steps:
- uses: actions/checkout@v2
- uses: lukka/get-cmake@latest
- name: Fetch git submodules
run: git submodule update --init --recursive
# Setup MSVC command prompt environment vars
- uses: ilammy/msvc-dev-cmd@v1
- name: Restore artifacts, setup vcpkg
uses: lukka/run-vcpkg@v10
with:
vcpkgGitCommitId: 861c33057553ee836e7061ffbdabc25ea343145d
vcpkgDirectory: '${{env.VCPKG_ROOT}}'
vcpkgJsonGlob: vcpkg.json
runVcpkgInstall: false
# - name: vcpkg check / install dependencies
# working-directory: ${{env.VCPKG_ROOT}}
# run: vcpkg install --triplet x64-windows
- name: Configure CMake
run: |
echo "`nfile(WRITE version.txt `${BMMO_VER})" | Out-File CMakeLists.txt -Encoding "UTF8" -Append
cmake -B ${{github.workspace}}/build -S ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE="${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_MODE=ON -DVCPKG_MANIFEST_DIR="${{github.workspace}}" -DYAML_BUILD_SHARED_LIBS=ON -DBUILD_SERVER=ON -DBUILD_CLIENT=OFF
echo "BMMO_VER=$(cat version.txt)" >> $env:GITHUB_ENV
echo "SHA_SHORT=$(git rev-parse --short ${{github.sha}})" >> $env:GITHUB_ENV
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
# - name: List build dir
# working-directory: ${{github.workspace}}/build
# run: dir
# - name: Run post-build script
# working-directory: ${{github.workspace}}/build/BallanceMMOServer
# run: ${{github.workspace}}/build/BallanceMMOServer/postbuild.bat ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}
run: ctest -C ${{env.BUILD_TYPE}}
# by setting a different working directory we avoid releasing the config file
- name: Dry run
working-directory: ${{github.workspace}}/build/BallanceMMOServer
run: ${{env.BUILD_TYPE}}/BallanceMMOServer.exe --dry-run
- name: Release Artifact
uses: actions/upload-artifact@v3
with:
name: server-windows-${{env.BMMO_VER}}-${{env.SHA_SHORT}}
path: build/BallanceMMOServer/${{env.BUILD_TYPE}}