Installs Lua / LuaJIT / OpenResty + LuaRocks in a single step inside the .lua folder in the current directory.
name: Setup Lua
on: push
jobs:
install-lua:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
lua-version:
- 5.1
- 5.2
- 5.3
- 5.4
- luajit
- openresty
is-msvc:
- true
- false
exclude:
- os: ubuntu-latest
is-msvc: true
- os: macos-latest
is-msvc: true
steps:
- uses: actions/checkout@v5
- name: Setup MSVC developer prompt
uses: ilammy/msvc-dev-cmd@v1
if: ${{ runner.os == 'Windows' && matrix.is-msvc }}
- name: Install Lua
uses: luau-project/setup-lua@v1
with:
lua-version: ${{ matrix.lua-version }}
- name: Display the Lua version
run: lua -v
- name: Test Lua
run: lua -e "print('this is a test from ' .. _VERSION)"
- name: Display LuaRocks version
run: luarocks --versionExplanation: This snippet installs Lua (or LuaJIT or OpenResty, depending on the matrix) + LuaRocks, and configures the environment for the toolchain that was used to build Lua. When the lua-version field of the matrix assumes luajit or openresty values, it fetches the latest source code from their GitHub repositories, https://github.com/LuaJIT/LuaJIT/ and https://github.com/openresty/luajit2/, respectively.
Note
-
On most operating systems,
setup-luausesccas the default C compiler and linker to build Lua / LuaJIT / OpenResty, which is oftenGCCorClang. -
On Windows, when you load Visual Studio developer prompt details (e.g.: ilammy/msvc-dev-cmd) for the Microsoft Visual Studio C/C++ compiler (MSVC),
setup-luaadopts MSVC as the selected toolchain to build Lua / LuaJIT / OpenResty. Otherwise, if you don't load Visual Studio developer prompt,setup-luaexamines environment variables to decide between the use ofgccorccto build Lua / LuaJIT / OpenResty.
In setup-lua, the most important inputs are lua-version and luarocks-version, so that you can choose specific versions to install. There are many options to tweak setup-lua: see GitHub Actions docs for an exhaustive list of inputs.
- Lua:
- PUC-Lua (≥ 5.1.1)
- LuaJIT (≥ v2.0.0)
- OpenResty (≥ v2.0.0)
- LuaRocks (≥ 3.9.1)
- name: Install Lua
uses: luau-project/setup-lua@v1
with:
lua-version: 5.3.4
luarocks-version: 3.12.0In order to skip LuaRocks installation, use none as the value for the luarocks-version input as follows:
- name: Install Lua
uses: luau-project/setup-lua@v1
with:
lua-version: 5.4.7
luarocks-version: noneTip
setup-lua also handles work versions of Lua (≥ 5.1.1):
- current work: https://lua.org/work/
- legacy work: https://lua.org/work/old/
Thus, you can test your project on the upcoming Lua 5.5.0. However, be aware that LuaRocks does not support it yet:
- name: Install Lua 5.5.0 (RC4)
uses: luau-project/setup-lua@v1
with:
lua-version: 5.5.0-rc4
luarocks-version: noneUse the syntax luajit@ref with ref meaning a branch name, a tag or the sha of a commit. The example below installs LuaJIT from the commit 871db2c84ecefd70a850e03a6c340214a81739f0:
- name: Install LuaJIT
uses: luau-project/setup-lua@v1
with:
lua-version: luajit@871db2c84ecefd70a850e03a6c340214a81739f0
luarocks-version: 3.12.1Use the syntax openresty@ref with ref meaning a branch name, a tag or the sha of a commit. The example below installs OpenResty from the tag v2.1-20250826:
- name: Install OpenResty
uses: luau-project/setup-lua@v1
with:
lua-version: openresty@v2.1-20250826
luarocks-version: 3.12.2setup-lua works in two modes: i) as a GitHub Action; ii) as a standalone CLI nodejs application.
In order to ease navigation and avoid excess of information, a complete reference for both modes can be found in the following documents: