-
Notifications
You must be signed in to change notification settings - Fork 244
133 lines (117 loc) · 4.24 KB
/
lua-build.yml
File metadata and controls
133 lines (117 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: lua-build
on:
workflow_dispatch:
inputs:
push:
default: true
type: boolean
description: "Push built dynamic libraries"
workflow_call:
inputs:
push:
default: true
type: boolean
description: "Push built dynamic libraries"
permissions:
contents: write
defaults:
run:
shell: bash
env:
LUA_SOURCE_DIR: ${{ github.workspace }}/src/kOS/Lua/lua
LUA_BUILD_DIR: ${{ github.workspace }}/src/kOS/Lua/lua/_build
LUA_OUTPUT_DIR: ${{ github.workspace }}/src/kOS/Lua/include
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set vars
id: vars
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
echo 'LUA_LIB_NAME=liblua54.so" >> "$GITHUB_OUTPUT'
echo 'LUA_LIB_PATH=$LUA_BUILD_DIR/lib64/liblua54.so' >> "$GITHUB_OUTPUT"
echo 'LUA_LUAROCKS_LIB_PATH=/usr/local/lib/lua/5.4' >> "$GITHUB_OUTPUT"
elif [ "$RUNNER_OS" == "Windows" ]; then
echo 'LUA_LIB_NAME=lua54.dll" >> "$GITHUB_OUTPUT'
echo 'LUA_LIB_PATH=$LUA_BUILD_DIR/bin/lua54.dll' >> "$GITHUB_OUTPUT"
echo 'LUA_LUAROCKS_LIB_PATH=~/.luarocks/lib/lua/5.4' >> "$GITHUB_OUTPUT"
elif [ "$RUNNER_OS" == "macOS" ]; then
echo 'LUA_LIB_NAME=liblua54.dylib" >> "$GITHUB_OUTPUT'
echo 'LUA_LIB_PATH=$LUA_BUILD_DIR/lib64/liblua54.dylib' >> "$GITHUB_OUTPUT"
echo 'LUA_LUAROCKS_LIB_PATH=/usr/local/lib/lua/5.4' >> "$GITHUB_OUTPUT"
fi
- name: Configure CMake
run: cmake -S $LUA_SOURCE_DIR -B $LUA_BUILD_DIR
- name: Build
run: cmake --build $LUA_BUILD_DIR --config Release
- name: Test
working-directory: ${{ env.LUA_BUILD_DIR }}
run: ctest --build-config Release
- name: Install LuaRocks
run: |
mv $LUA_BUILD_DIR/bin64 $LUA_BUILD_DIR/bin # luarocks gets lost if lua binary is not in "bin" directory
if [ "$RUNNER_OS" == "Windows" ]; then
curl http://luarocks.github.io/luarocks/releases/luarocks-3.11.1-windows-64.zip --output luarocks.zip
unzip luarocks.zip -d ~/luarocks
mv ~/luarocks/luarocks-3.11.1-windows-64/* ~/luarocks
rm -rf ~/luarocks/luarocks-3.11.1-windows-64
else
wget https://luarocks.org/releases/luarocks-3.11.1.tar.gz
tar zxpf luarocks-3.11.1.tar.gz
cd luarocks-3.11.1
./configure --with-lua-bin="$LUA_BUILD_DIR/bin"
make && sudo make install
fi
- name: Install modules
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
PATH=~/luarocks:$LUA_BUILD_DIR/bin:$PATH
luarocks install lua-cjson 2.1.0.10-1
else
sudo luarocks install lua-cjson 2.1.0.10-1
fi
- name: Create artifact
run: |
rm -rf artifact
mkdir artifact
cp ${{ steps.vars.outputs.LUA_LIB_PATH }} artifact/${{ steps.vars.outputs.LUA_LIB_NAME }}
mkdir artifact/LuaModules artifact/LuaModules/${{ runner.os }}
cp -r ${{ steps.vars.outputs.LUA_LUAROCKS_LIB_PATH }}/. artifact/LuaModules/${{ runner.os }}
- uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}
if-no-files-found: error
retention-days: 7
path: ${{ github.workspace }}/artifact
push:
runs-on: ubuntu-latest
needs: build
if: inputs.push
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Clear output directory
run: rm -rf $LUA_OUTPUT_DIR
- uses: actions/download-artifact@v4
with:
merge-multiple: 'true'
path: ${{ env.LUA_OUTPUT_DIR }}
- name: Push
env:
GIT_COMMITTER_NAME: lua-build automation
GIT_AUTHOR_NAME: lua-build automation
GIT_COMMITTER_EMAIL: noreply@github.com
GIT_AUTHOR_EMAIL: noreply@github.com
run: |
git add $LUA_OUTPUT_DIR
git commit -am "Build lua"
git push