CI: upload rockspec to LuaRocks on tag push
Overview
Since https://github.com/openresty/lua-cjson has become such a core dependency to a huge amount of packages on LuaRocks, this PR adds a new job to the current CI to upload the rockspec to LuaRocks once a new tag is pushed to GitHub.
Description
- Added a
uploadjob to CI, which uploads the rockspec to LuaRocks once a new tag is pushed to GitHub;
[!NOTE]
There is a guard to make sure that the GitHub tag matches the rockspec tag (field
source.tag), failing the upload job otherwise.
-
Once a new tag is pushed, this PR partially fixes https://github.com/openresty/lua-cjson/issues/96 and https://github.com/openresty/lua-cjson/issues/102 regarding the published rockspecs on LuaRocks;
-
Replaced the GitHub actions
leafo/gh-actions-lua@masterandleafo/gh-actions-luarocks@masterwithluarocks/gh-actions-lua@masterandluarocks/gh-actions-luarocks@masterrespectively, due to the former failing to install LuaJIT. See https://github.com/leafo/gh-actions-lua/issues/49 and https://github.com/leafo/gh-actions-lua/pull/50.
Requeriments
In order to upload rockspecs to LuaRocks, a few steps are required:
- Generate an API key to upload rockspecs to LuaRocks:
- Visit https://luarocks.org/;
- Log in;
- Go to
Settings; - Generate a new API key and save it to store on a GitHub secret used by the upload job.
- Generate a GitHub secret to hold LuaRocks API key:
- Visit https://github.com/openresty/lua-cjson;
- Log in;
- Go to
Settings > Secrets and variables > Actionsand clickNew repository secretbutton; - Paste
LUAROCKS_APIKEYinto Name field, paste LuaRocks API key generated from LuaRocks in the Secret box, and hitAdd secretbutton.
[!IMPORTANT]
The secret name must be
LUAROCKS_APIKEY, as is defined in the upload job.
Workflow Testing
Visit my fork's workflow runs https://github.com/luau-project/lua-cjson/actions and check how it ran:
-
The run https://github.com/luau-project/lua-cjson/actions/runs/11882520402 happened on a branch
test-commit, which had some modifications to allow it reach the upload job (and avoiding the final upload to LuaRocks). That run was triggered by agit push; -
The run https://github.com/luau-project/lua-cjson/actions/runs/11882535036 happened on the same branch
test-commit, but this time triggered by annotating a taggit tag -a "2.1.0.14" -m "Release v2.1.0.14"and pushing it to the remote repogit push origin 2.1.0.14.