Skip to content

Commit

Permalink
feat: support "scm" and "dev" versions (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Mar 7, 2024
1 parent e48b699 commit 2b77919
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<number_of_commits>`, and publishes to LuaRocks
if there have been any commits in the last 24 hours:
Expand Down
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
3 changes: 2 additions & 1 deletion bin/luarocks-tag-release-action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lua/luarocks-tag-release.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 6 additions & 0 deletions resources/rockspec.template
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2b77919

Please sign in to comment.