Skip to content

Commit

Permalink
feat: build appimage with ci
Browse files Browse the repository at this point in the history
Xenapte committed Feb 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 3655bcb commit c1ed75d
Showing 2 changed files with 38 additions and 8 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
@@ -38,25 +38,44 @@ jobs:
# 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
cmake -B ${{github.workspace}}/build -S ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_SERVER=ON -DBUILD_CLIENT=OFF -DCMAKE_INSTALL_PREFIX=/usr
echo "BMMO_VER=$(cat version.txt)" >> "$GITHUB_ENV"
echo "SHA_SHORT=$(git rev-parse --short ${{github.sha}})" >> "$GITHUB_ENV"
- name: Build
- name: Build and install
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
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
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
run: |
appfile=$(ls BallanceMMOLaunchSelector*.AppImage | awk '{print $1}')
chmod +x $appfile
mkdir artifacts
mv -t artifacts $appfile BallanceMMOServer/start_ballancemmo_loop.sh
artifacts/$appfile --launch Server --dry-run
- name: Release Artifact
uses: actions/upload-artifact@v3
with:
name: server-linux-${{env.BMMO_VER}}-${{env.SHA_SHORT}}
path: build/BallanceMMOServer
path: build/artifacts

build-server-windows:
runs-on: windows-latest
@@ -108,9 +127,10 @@ jobs:
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/${{env.BUILD_TYPE}}
run: ${{github.workspace}}/build/BallanceMMOServer/${{env.BUILD_TYPE}}/BallanceMMOServer.exe --dry-run
working-directory: ${{github.workspace}}/build/BallanceMMOServer
run: ${{env.BUILD_TYPE}}/BallanceMMOServer.exe --dry-run

- name: Release Artifact
uses: actions/upload-artifact@v3
14 changes: 12 additions & 2 deletions BallanceMMOServer/start_ballancemmo_loop.sh
Original file line number Diff line number Diff line change
@@ -12,9 +12,19 @@ trap "ctrlc_exit" 2
for (( ; ; ))
do
log_name=$(date +"log_%Y%m%d%H%M.log")
chmod +x ./BallanceMMOServer
server_binary="./BallanceMMOServer"
extra_options=()
if [ ! -f "$server_binary" ]; then
server_binary=$(ls ./BallanceMMOLaunchSelector*.AppImage | awk '{print $1}')
if [ ! -f "$server_binary" ]; then
echo "Error: server executable not found." >&2
exit 1
fi
extra_options=("--launch" "Server")
fi
chmod +x $server_binary
SECONDS=0
./BallanceMMOServer --log=$log_name "$@"
$server_binary "${extra_options[@]}" --log=$log_name "$@"
server_status=$?
archive_logs
if [ $server_status -eq 0 ] || [ $server_status -eq 1 ] || [ $SECONDS -lt 10 ]

0 comments on commit c1ed75d

Please sign in to comment.