Skip to content

ci(windows): use vcpkg nlohmann json package (#398) #39

ci(windows): use vcpkg nlohmann json package (#398)

ci(windows): use vcpkg nlohmann json package (#398) #39

Workflow file for this run

name: sdk-release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Optional tag to build/release (e.g. v2.6.0). If empty, uses the current ref."
required: false
default: ""
permissions:
contents: write
concurrency:
group: sdk-release-${{ github.workflow }}-${{ github.event.inputs.tag || github.ref }}
cancel-in-progress: false
jobs:
build-sdk:
name: build-sdk-full (linux / x86_64)
runs-on: ubuntu-24.04
env:
BUILD_DIR: build-sdk-full
INSTALL_DIR: install-sdk-full
ASSET: vix-sdk-linux-x86_64.tar.gz
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Checkout tag (manual input)
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }}
shell: bash
run: |
set -euxo pipefail
git fetch --tags --force
git checkout "tags/${{ github.event.inputs.tag }}"
- name: Install deps (Linux)
shell: bash
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
pkg-config \
ninja-build \
ca-certificates \
git \
curl \
unzip \
zip \
tar \
nlohmann-json3-dev \
libssl-dev \
zlib1g-dev \
libsqlite3-dev \
libbrotli-dev \
libspdlog-dev \
libfmt-dev \
libmysqlcppconn-dev \
libsdl2-dev \
libsdl2-image-dev \
libgl1-mesa-dev
- name: Configure SDK full
shell: bash
run: |
set -euxo pipefail
cmake -S . -B "$BUILD_DIR" -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}/${INSTALL_DIR}" \
-DVIX_ENABLE_INSTALL=ON \
-DVIX_BUILD_EXAMPLES=OFF \
-DVIX_BUILD_TESTS=OFF \
-DVIX_ENABLE_HTTP_COMPRESSION=ON \
-DVIX_ENABLE_DB=ON \
-DVIX_DB_USE_SQLITE=ON \
-DVIX_DB_USE_MYSQL=ON \
-DVIX_DB_USE_POSTGRES=OFF \
-DVIX_DB_USE_REDIS=OFF \
-DVIX_CORE_WITH_MYSQL=OFF \
-DVIX_ENABLE_ORM=ON \
-DVIX_ENABLE_WEBSOCKET=ON \
-DVIX_ENABLE_CLI=ON \
-DVIX_ENABLE_MIDDLEWARE=ON \
-DVIX_ENABLE_P2P=ON \
-DVIX_ENABLE_P2P_HTTP=ON \
-DVIX_ENABLE_CACHE=ON \
-DVIX_ENABLE_ASYNC=ON \
-DVIX_ENABLE_VALIDATION=ON \
-DVIX_ENABLE_CRYPTO=ON \
-DVIX_ENABLE_WEBRPC=ON \
-DVIX_ENABLE_TIME=ON \
-DVIX_ENABLE_TESTS_MODULE=ON \
-DVIX_ENABLE_TEMPLATE=ON \
-DVIX_ENABLE_PROCESS=ON \
-DVIX_ENABLE_THREADPOOL=ON \
-DVIX_ENABLE_KV=ON \
-DVIX_ENABLE_AGENT=ON \
-DVIX_ENABLE_GAME=ON \
-DVIX_GAME_ENABLE_SDL=ON \
-DVIX_GAME_ENABLE_SDL_OPENGL=ON \
-DVIX_TIME_BUILD_TESTS=OFF \
-DVIX_TIME_BUILD_BENCH=OFF \
-DVIX_TEMPLATE_BUILD_TESTS=OFF \
-DVIX_TEMPLATE_BUILD_EXAMPLES=OFF \
-DVIX_TEMPLATE_BUILD_BENCH=OFF \
-DVIX_AGENT_BUILD_TESTS=OFF \
-DVIX_AGENT_BUILD_EXAMPLES=OFF \
-DVIX_GAME_BUILD_TESTS=OFF \
-DVIX_GAME_BUILD_EXAMPLES=OFF
- name: Build SDK
shell: bash
run: |
set -euxo pipefail
cmake --build "$BUILD_DIR" -j2
- name: Install SDK
shell: bash
run: |
set -euxo pipefail
cmake --install "$BUILD_DIR"
- name: Install vendored Asio headers into SDK
shell: bash
run: |
set -euxo pipefail
ASIO_INCLUDE_DIR="third_party/asio-src/asio/include"
test -d "$ASIO_INCLUDE_DIR/asio"
mkdir -p "$INSTALL_DIR/include"
cp -a "$ASIO_INCLUDE_DIR/asio" "$INSTALL_DIR/include/"
if [ -f "$ASIO_INCLUDE_DIR/asio.hpp" ]; then
cp -a "$ASIO_INCLUDE_DIR/asio.hpp" "$INSTALL_DIR/include/"
fi
test -f "$INSTALL_DIR/include/asio/io_context.hpp"
- name: Verify installed SDK tree
shell: bash
run: |
set -euxo pipefail
test -d "$INSTALL_DIR"
test -f "$INSTALL_DIR/bin/vix"
test -f "$INSTALL_DIR/lib/cmake/Vix/VixConfig.cmake"
test -f "$INSTALL_DIR/lib/cmake/Vix/VixTargets.cmake"
test -f "$INSTALL_DIR/include/asio/io_context.hpp"
find "$INSTALL_DIR/include" -maxdepth 4 -type f | sort > installed-headers.txt
find "$INSTALL_DIR/lib/cmake" -maxdepth 4 -type f | sort > installed-cmake-files.txt
sed -n '1,80p' installed-headers.txt
cat installed-cmake-files.txt
- name: Package SDK
shell: bash
run: |
set -euxo pipefail
mkdir -p dist
tar -C "$INSTALL_DIR" -czf "dist/$ASSET" .
ls -lah dist
- name: Validate packaged SDK binary
shell: bash
run: |
set -euxo pipefail
rm -rf smoke-bin
mkdir -p smoke-bin
tar -xzf "dist/$ASSET" -C smoke-bin
test -f smoke-bin/bin/vix
file smoke-bin/bin/vix
ldd smoke-bin/bin/vix || true
smoke-bin/bin/vix --version
- name: Validate packaged SDK with full consumer project
shell: bash
run: |
set -euxo pipefail
rm -rf smoke-sdk consumer
mkdir -p smoke-sdk consumer
tar -xzf "dist/$ASSET" -C smoke-sdk
cat > consumer/CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.20)
project(vix_sdk_consumer LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Vix CONFIG REQUIRED)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE vix::vix)
EOF
cat > consumer/main.cpp <<'EOF'
#include <vix.hpp>
#include <vix/json/Simple.hpp>
#include <vix/error/Error.hpp>
#include <vix/path/Path.hpp>
#include <vix/fs.hpp>
#include <vix/console.hpp>
#include <vix/env.hpp>
#include <vix/log.hpp>
#include <vix/core.hpp>
#include <vix/async.hpp>
#include <vix/time.hpp>
#include <vix/crypto.hpp>
#include <vix/cache.hpp>
#include <vix/db.hpp>
#include <vix/orm.hpp>
#include <vix/websocket.hpp>
#include <vix/validation.hpp>
#include <vix/process.hpp>
#include <vix/threadpool.hpp>
#include <vix/kv.hpp>
#include <vix/template.hpp>
#include <vix/p2p.hpp>
#include <vix/p2p_http.hpp>
#include <vix/webrpc.hpp>
#include <vix/game.hpp>
#include <vix/ai.hpp>
#include <iostream>
int main()
{
std::cout << "Vix full SDK consumer build works\n";
return 0;
}
EOF
cmake -S consumer -B consumer/build \
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/smoke-sdk"
cmake --build consumer/build -j2
./consumer/build/app
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: sdk-dist-linux-x86_64
path: dist/*
if-no-files-found: error
publish-sdk:
name: publish-sdk
needs: build-sdk
runs-on: ubuntu-24.04
steps:
- name: Download SDK artifact
uses: actions/download-artifact@v4
with:
path: dist-all
- name: Flatten SDK assets
shell: bash
run: |
set -euxo pipefail
mkdir -p dist
find dist-all -type f -name "vix-sdk-linux-x86_64.tar.gz" -exec cp -f {} dist/ \;
test -f dist/vix-sdk-linux-x86_64.tar.gz
ls -lah dist
- name: Generate sha256 files
shell: bash
run: |
set -euxo pipefail
cd dist
for f in vix-sdk-*.tar.gz; do
[ -f "$f" ] || continue
sha256sum "$f" > "$f.sha256"
done
ls -lah
- name: Determine tag
id: tag
shell: bash
run: |
set -euxo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag }}" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
fi
- name: Upload SDK assets to GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
files: dist/*