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
- 5.5
- luajit
- openresty
toolchain:
- msvc
- cc
exclude:
- os: ubuntu-latest
toolchain: msvc
- os: macos-latest
toolchain: msvc
steps:
- uses: actions/checkout@v7
- name: Setup MSVC developer prompt
uses: step-security/msvc-dev-cmd@v1
if: ${{ runner.os == 'Windows' && matrix.toolchain == 'msvc' }}
- name: Install Lua
uses: luau-project/setup-lua@v3
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.: step-security/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.
The features listed here are unique to setup-lua and are not present on other popular GitHub Actions / tools:
- Installs both Lua (or LuaJIT / OpenResty)
+LuaRocks in a single step; - Applies patches stored locally or remotely to Lua or LuaRocks source code on the fly (see here);
- Works on Windows inside MinGW-w64 shells on
MSYS2; - Has the same set of features working well on all supported platform (Linux, Windows, macOS, BSDs), with exceptions documented;
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@v3
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@v3
with:
lua-version: 5.4.7
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@v3
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@v3
with:
lua-version: openresty@v2.1-20250826
luarocks-version: 3.12.2Since setup-lua version 1.1.0, through the CLI interface (see the parameters), there is builtin support to install Lua / LuaJIT / OpenResty + LuaRocks on MSYS2 MinGW-w64 environments.
name: Setup Lua on MSYS2
on: push
jobs:
msys2-install-lua:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: false
matrix:
lua-version:
- 5.1
- 5.2
- 5.3
- 5.4
- 5.5
- luajit
- openresty
sys:
- UCRT64
- CLANG64
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
install: |
base-devel
unzip
pacboy: |
cc:p
make:p
- name: Download `setup-lua`
run: curl -LO "https://github.com/luau-project/setup-lua/archive/refs/tags/v3.tar.gz"
- name: Extract `setup-lua`
run: tar -xf v3.tar.gz
- name: Setup Lua
run: |
env \
LUA_VERSION=${{ matrix.lua-version }} \
"/c/Program Files/nodejs/node.exe" \
./setup-lua-3/dist/cli/index.js
- name: Display the Lua version
run: lua -v
- name: Display LuaRocks version
run: luarocks --versionNote
- Without any changes, at the moment, LuaRocks does need a few patches to work nicely on MSYS2. See here for the list of patches we apply by default to make it work;
- Since
setup-luaversion3.0.0, for PUC-Lua 5.1, PUC-Lua 5.2, LuaJIT and OpenResty interpreters to work in MSYS2 without.exeextension (allow the use ofluarather thanlua.exe), we also patchluaconf.h. See the patches applied toluaconf.hin LuaJIT / OpenResty and PUC-Lua 5.1 / PUC-Lua 5.2.
Tip
By default, MSYS2 does not update environment variables according to changes on ${{ github.env }} or ${{ github.path }}. In order to set environment variables on MSYS2, we store Lua and LuaRocks environment variables at /etc/profile.d/setup-lua.sh.
Tip
setup-lua also handles work versions of Lua (≥ 5.1.1):
- current work: https://lua.org/work/
- legacy work: https://lua.org/work/old/
- name: Install Lua 5.4.9 (RC1)
uses: luau-project/setup-lua@v3
with:
lua-version: 5.4.9-rc1
luarocks-version: 3.13.0setup-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:
Have you found a security issue on this software? Visit the security page for instructions to report privately.
Do you want to fix a bug or have an idea to improve this project? See the contribution page.
Browse the changelog.