diff --git a/README.md b/README.md index 99d7946..3eca1ed 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,10 @@ package version. If you do not have a workflow that releases based on tags, you can manually set the version input. +Setting this input to either `null`, `"scm"` or `"dev"` will result in a +scm release, where the generated rockspec's source URL +is the repository's URL. + The following is an example for a basic workflow that runs daily at 00:00, sets the package version to `0.0.`, and publishes to LuaRocks if there have been any commits in the last 24 hours: diff --git a/action.yml b/action.yml index 4b1d3ee..2dec33a 100644 --- a/action.yml +++ b/action.yml @@ -11,8 +11,10 @@ inputs: required: true default: ${{ github.event.repository.name }} version: - description: "The version of your package. By default, the git tag is used." - required: true + description: | + The version of your package. Uses the git tag by default (if one exists). + Can also be set to `null`, `"scm"` or `"dev"` to publish a development rockspec. + required: false default: ${{ github.ref_name }} dependencies: description: "List of LuaRocks dependencies." diff --git a/bin/luarocks-tag-release-action.lua b/bin/luarocks-tag-release-action.lua index 1ef75b6..465cb25 100644 --- a/bin/luarocks-tag-release-action.lua +++ b/bin/luarocks-tag-release-action.lua @@ -30,7 +30,8 @@ local is_pull_request = getenv_or_empty('GITHUB_EVENT_NAME') == 'pull_request' local license_input = os.getenv('INPUT_LICENSE') local template_input = os.getenv('INPUT_TEMPLATE') local package_name = getenv_or_err('INPUT_NAME') -local package_version = is_pull_request and '0.0.0' or getenv_or_err('INPUT_VERSION') +---@type string | nil +local package_version = is_pull_request and '0.0.0' or os.getenv('INPUT_VERSION') local interpreters_input = os.getenv('INPUT_TEST_INTERPRETERS') local test_interpreters = Parser.parse_interpreter_input(interpreters_input) diff --git a/lua/luarocks-tag-release.lua b/lua/luarocks-tag-release.lua index 4ac9eb5..8c8e1cc 100755 --- a/lua/luarocks-tag-release.lua +++ b/lua/luarocks-tag-release.lua @@ -24,12 +24,12 @@ ---@field is_debug boolean Whether to enable debug logging ---@param package_name string The name of the LuaRocks package. ----@param package_version string The version of the LuaRocks package. +---@param package_version string | nil The version of the LuaRocks package. ---@param specrev string the version of the rockspec ---@param args Args local function luarocks_tag_release(package_name, package_version, specrev, args) - -- version in format 3.0 must follow the format '[%w.]+-[%d]+' - local modrev = string.gsub(package_version, 'v', '') + -- version in format 3.0 must follow the format '[%w.]+-[%d]+' or be 'dev' or 'scm' + local modrev = package_version and package_version ~= 'dev' and string.gsub(package_version, 'v', '') or 'scm' local rockspec_file_path = package_name:lower() .. '-' .. modrev .. '-' .. specrev .. '.rockspec' diff --git a/resources/rockspec.template b/resources/rockspec.template index 9d1acd7..3fd87a9 100644 --- a/resources/rockspec.template +++ b/resources/rockspec.template @@ -25,6 +25,12 @@ source = { dir = '$repo_name-' .. '$archive_dir_suffix', } +if modrev == 'scm' or modrev == 'dev' then + source = { + url = repo_url:gsub('https', 'git') + } +end + build = { type = 'builtin', copy_directories = $copy_directories,