Installs Lua / LuaJIT / OpenResty + LuaRocks in a single step inside the .lua folder in the current directory.
name: Setup Luaon: pushjobs:
install-lua:
runs-on: ${{ matrix.os }}strategy:
fail-fast: falsematrix:
os:
- ubuntu-latest
- windows-latest
- macos-latestlua-version:
- 5.1
- 5.2
- 5.3
- 5.4
- 5.5
- luajit
- openrestytoolchain:
- msvc
- ccexclude:
- os: ubuntu-latesttoolchain: msvc
- os: macos-latesttoolchain: msvcsteps:
- uses: actions/checkout@v7
- name: Setup MSVC developer promptuses: step-security/msvc-dev-cmd@v1if: ${{ runner.os == 'Windows' && matrix.toolchain == 'msvc' }}
- name: Install Luauses: luau-project/setup-lua@v2with:
lua-version: ${{ matrix.lua-version }}
- name: Display the Lua versionrun: lua -v
- name: Test Luarun: lua -e "print('this is a test from ' .. _VERSION)"
- name: Display LuaRocks versionrun: 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 Luauses: luau-project/setup-lua@v2with:
lua-version: 5.3.4luarocks-version: 3.12.0In order to skip LuaRocks installation, use none as the value for the luarocks-version input as follows:
- name: Install Luauses: luau-project/setup-lua@v2with:
lua-version: 5.4.7luarocks-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 LuaJITuses: luau-project/setup-lua@v2with:
lua-version: luajit@871db2c84ecefd70a850e03a6c340214a81739f0luarocks-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 OpenRestyuses: luau-project/setup-lua@v2with:
lua-version: openresty@v2.1-20250826luarocks-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 MSYS2on: pushjobs:
msys2-install-lua:
runs-on: windows-latestdefaults:
run:
shell: msys2 {0}strategy:
fail-fast: falsematrix:
lua-version:
- 5.1
- 5.2
- 5.3
- 5.4
- 5.5
- luajit
- openrestysys:
- MINGW64
- UCRT64
- CLANG64steps:
- uses: msys2/setup-msys2@v2with:
msystem: ${{ matrix.sys }}install: | base-devel unzippacboy: | cc:p make:p - name: Download `setup-lua`run: curl -LO "https://github.com/luau-project/setup-lua/archive/refs/tags/v2.tar.gz"
- name: Extract `setup-lua`run: tar -xf v2.tar.gz
- name: Setup Luarun: | env \ LUA_VERSION=${{ matrix.lua-version }} \ "/c/Program Files/nodejs/node.exe" \ ./setup-lua-2/dist/cli/index.js - name: Display the Lua versionrun: lua.exe -v
- name: Display LuaRocks versionrun: 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;
- When using Lua 5.1, Lua 5.2 and LuaJIT / OpenResty, it is required to use
lua.exeand not onlylua. The reason for this is the presence of aluadirectory inside thebinfolder. Thus,bashtries to execute suchluadirectory as an executable and fails.
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@v2with:
lua-version: 5.4.9-rc1luarocks-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.