Skip to content

Commit

Permalink
Feat(CI): Add automated builds (#1)
Browse files Browse the repository at this point in the history
* Feat(CI): Add automated builds
  • Loading branch information
magicaldave authored Oct 16, 2023
1 parent c3abdb7 commit 45bef91
Show file tree
Hide file tree
Showing 6 changed files with 547 additions and 1 deletion.
77 changes: 77 additions & 0 deletions .github/workflows/cjson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CJSON-Main

on:
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
branches: [ master ]

jobs:
CJSON_MASTER:
strategy:
matrix:
build_type: [Release, RelWithDebInfo, MinSizeRel, Debug]
target_system: [ ubuntu-22.04, windows-2022 ]
runs-on: ${{ matrix.target_system }}
env:
BUILD_EXT: ${{ matrix.target_system == 'windows-2022' && '.dll' || '.so' }}

steps:
- uses: actions/checkout@v4

- name: Prime ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.target_system }}-${{ matrix.build_type }}
max-size: 1000M

- name: Cache LuaJIT
id: cache-Lua
uses: actions/cache@v3
with:
path: |
${{ runner.os == 'Linux' && 'apt-cache' || 'LuaJIT' }}
key: ${{ runner.os }}-Lua

- name: Get Deps (LuaJIT)
shell: bash
if: steps.cache-Lua.outputs.cache-hit != 'true'
run: |
${{ runner.os == 'Linux' && 'sudo' || '' }} CI/get_luajit.${{runner.os}}.sh openmw-deps
- name: Configure
shell: bash
run: |
LUA_DIR=LuaJIT/ cmake .
- name: Build
run: |
cmake --build . --config ${{ matrix.build_type }}
- name: Prep Windows Release
if: runner.os == 'Windows'
run: |
mv ${{ github.workspace }}/${{ matrix.build_type }}/cjson.dll ${{ github.workspace }}/cjson-${{ matrix.build_type }}.dll
- name: Prep Linux Release
if: runner.os != 'Windows'
run: |
mv ${{ github.workspace }}/cjson.so ${{ github.workspace }}/cjson-${{ matrix.build_type }}.so
- name: Upload Release
if: github.event_name != 'pull_request'
uses: softprops/action-gh-release@v1
with:
tag_name: Stable-CI
files: ${{ github.workspace }}/cjson-${{ matrix.build_type }}${{ env.BUILD_EXT }}
body: |
CI Build for Dreamweave IO2 fork
- name: Upload Artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
with:
name: cjson-${{ matrix.build_type }}-${{matrix.target_system}}
path: ${{ github.workspace }}/cjson-${{ matrix.build_type }}${{ env.BUILD_EXT }}
36 changes: 36 additions & 0 deletions CI/get_luajit.Linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -euo pipefail

print_help() {
echo "usage: $0 [group]..."
echo
echo " available groups: "${!GROUPED_DEPS[@]}""
}

declare -rA GROUPED_DEPS=(
# Common dependencies for building OpenMW.
[openmw-deps]="
libluajit-5.1-dev
"
)

if [[ $# -eq 0 ]]; then
>&2 print_help
exit 1
fi

deps=()
for group in "$@"; do
if [[ ! -v GROUPED_DEPS[$group] ]]; then
>&2 echo "error: unknown group ${group}"
exit 1
fi
deps+=(${GROUPED_DEPS[$group]})
done

export APT_CACHE_DIR="${PWD}/apt-cache"
set -x
mkdir -pv "$APT_CACHE_DIR"
apt-get update -yq
apt-get -q -o dir::cache::archives="$APT_CACHE_DIR" install -y --no-install-recommends "${deps[@]}"
52 changes: 52 additions & 0 deletions CI/get_luajit.windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
set -e

download() {
if [ $# -lt 3 ]; then
echo "Invalid parameters to download."
return 1
fi

NAME=$1
shift

echo "$NAME..."

while [ $# -gt 1 ]; do
URL=$1
FILE=$2
shift
shift

if ! [ -f $FILE ]; then
printf " Downloading $FILE... "

if [ -z $VERBOSE ]; then
RET=0
curl --silent --fail --retry 10 -Ly 5 -o $FILE $URL || RET=$?
else
RET=0
curl --fail --retry 10 -Ly 5 -o $FILE $URL || RET=$?
fi

if [ $RET -ne 0 ]; then
echo "Failed!"
wrappedExit $RET
else
echo "Done."
fi
else
echo " $FILE exists, skipping."
fi
done

if [ $# -ne 0 ]; then
echo "Missing parameter."
fi
}

download "LuaJIT v2.1.0-beta3-452-g7a0cf5fd" \
"https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z" \
"LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z"

echo "Extracting LuaJIT . . ."
eval 7z x -y LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z -o./LuaJIT
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ if(NOT CMAKE_BUILD_TYPE)
FORCE)
endif()

find_package(Lua51 REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)

find_package(LuaJit REQUIRED)
include_directories(${LUA_INCLUDE_DIR})

if(NOT USE_INTERNAL_FPCONV)
Expand Down
16 changes: 16 additions & 0 deletions cmake/FindLuaJit.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(LibFindMacros)

libfind_pkg_detect(LuaJit luajit
FIND_PATH luajit.h
HINTS $ENV{LUA_DIR}
PATH_SUFFIXES include include/luajit-2.1
FIND_LIBRARY luajit-5.1 luajit lua51
HINTS $ENV{LUA_DIR}
PATH_SUFFIXES lib
)


libfind_process(LuaJit)

set(LUA_LIBRARY ${LuaJit_LIBRARY})
set(LUA_INCLUDE_DIR ${LuaJit_INCLUDE_DIR})
Loading

0 comments on commit 45bef91

Please sign in to comment.