|
| 1 | +name: "Set up LuaRocks" |
| 2 | +description: > |
| 3 | + Build and install LuaRocks against the Lua tree produced by leafo/gh-actions-lua. |
| 4 | + This replaces leafo/gh-actions-luarocks, which the Apache enterprise action |
| 5 | + allowlist does not permit. Actions living in this repository are always allowed, |
| 6 | + so the same steps are kept here instead. |
| 7 | +
|
| 8 | +inputs: |
| 9 | + luaRocksVersion: |
| 10 | + description: "The version of LuaRocks to build, as published on https://luarocks.org/releases/" |
| 11 | + required: false |
| 12 | + default: "3.13.0" |
| 13 | + withLuaPath: |
| 14 | + description: "Existing Lua installation to build against (./configure --with-lua). Defaults to the .lua directory created by leafo/gh-actions-lua." |
| 15 | + required: false |
| 16 | + default: "" |
| 17 | + |
| 18 | +runs: |
| 19 | + using: composite |
| 20 | + steps: |
| 21 | + - name: Build and install LuaRocks |
| 22 | + shell: bash |
| 23 | + env: |
| 24 | + LUAROCKS_VERSION: ${{ inputs.luaRocksVersion }} |
| 25 | + WITH_LUA_PATH: ${{ inputs.withLuaPath }} |
| 26 | + run: | |
| 27 | + set -euo pipefail |
| 28 | +
|
| 29 | + lua_dir="${WITH_LUA_PATH:-}" |
| 30 | + if [ -z "$lua_dir" ]; then |
| 31 | + # Default install path used by leafo/gh-actions-lua. |
| 32 | + lua_dir="${GITHUB_WORKSPACE}/.lua" |
| 33 | + fi |
| 34 | +
|
| 35 | + build_dir="${RUNNER_TEMP}/.build-luarocks" |
| 36 | + install_dir="${GITHUB_WORKSPACE}/.luarocks" |
| 37 | +
|
| 38 | + mkdir -p "$build_dir" |
| 39 | + curl -fsSL "https://luarocks.org/releases/luarocks-${LUAROCKS_VERSION}.tar.gz" \ |
| 40 | + | tar -xz -C "$build_dir" |
| 41 | +
|
| 42 | + cd "${build_dir}/luarocks-${LUAROCKS_VERSION}" |
| 43 | + ./configure --with-lua="$lua_dir" --prefix="$install_dir" |
| 44 | + make |
| 45 | + make install |
| 46 | +
|
| 47 | + # Expose luarocks and the rocks tree to the following steps. |
| 48 | + luarocks="${install_dir}/bin/luarocks" |
| 49 | + "$luarocks" path --lr-bin >> "$GITHUB_PATH" |
| 50 | + { |
| 51 | + echo "LUA_PATH=;;$("$luarocks" path --lr-path)" |
| 52 | + echo "LUA_CPATH=;;$("$luarocks" path --lr-cpath)" |
| 53 | + } >> "$GITHUB_ENV" |
0 commit comments