Skip to content

Commit f6d8fb5

Browse files
authored
feat: add specrev input (#407)
1 parent 9696a5c commit f6d8fb5

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

README.md

+24-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ Example:
284284
### `version` (optional)
285285

286286
The package version to release to LuaRocks (without the rockspec revision).
287-
By default, this workflow will use `github.ref_name` (the git tag or branch name) to determine the LuaRocks
288-
package version.
287+
By default, this workflow will use `github.ref_name` (the git tag or branch name)
288+
to determine the LuaRocks package version.
289289
If you do not have a workflow that releases based on tags,
290290
you can manually set the version input.
291291

@@ -332,6 +332,28 @@ jobs:
332332
> A `v` prefix (e.g. git tags such as `v1.0.0`) is also supported.
333333
> It will be removed from the LuaRocks version.
334334

335+
### `specrev` (optional)
336+
337+
The specrev (revision) of the generated rockspec. Defaults to `'1'`.
338+
339+
> [!TIP]
340+
>
341+
> When publishing `scm` or `dev` rockspecs, it can be useful to set
342+
> point the source to a commit hash, and increment the `specrev` with every
343+
> new push.
344+
> This allows consumers to roll back or pin dev versions.
345+
346+
Example:
347+
348+
```yaml
349+
- name: LuaRocks Upload
350+
uses: nvim-neorocks/luarocks-tag-release@v5
351+
with:
352+
version: "scm"
353+
# Add logic or determining if the specrev needs to be incremented
354+
specrev: "${{ env.SPECREV }}"
355+
```
356+
335357
### `extra_luarocks_args`
336358

337359
Extra args to pass to the luarocks command.

action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ inputs:
1616
Can also be set to `null`, `"scm"` or `"dev"` to publish a development rockspec.
1717
required: false
1818
default: ${{ github.ref_name }}
19+
specrev:
20+
description: |
21+
The rockspec revision. Defaults to '1', resulting in <version>-1 as the <modrev>-<specrev>.
22+
required: false
23+
default: "1"
1924
dependencies:
2025
description: "List of LuaRocks dependencies."
2126
required: false
@@ -76,6 +81,7 @@ runs:
7681
env:
7782
INPUT_NAME: ${{ inputs.name }}
7883
INPUT_VERSION: ${{ inputs.version }}
84+
INPUT_SPECREV: ${{ inputs.specrev }}
7985
INPUT_DEPENDENCIES: ${{ inputs.dependencies }}
8086
INPUT_TEST_DEPENDENCIES: ${{ inputs.test_dependencies }}
8187
INPUT_LABELS: ${{ inputs.labels }}

bin/luarocks-tag-release-action.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ end
7474

7575
local luarocks_tag_release = require('luarocks-tag-release')
7676

77-
local specrev = '1'
77+
local specrev
7878
if is_pull_request then
7979
print('Running in a pull request.')
8080
specrev = assert(os.getenv('GITHUB_RUN_ATTEMPT'), 'GITHUB_RUN_ATTEMPT not set')
8181
args.git_ref = get_github_sha()
82+
else
83+
specrev = os.getenv('INPUT_SPECREV') or '1'
8284
end
8385

8486
luarocks_tag_release(package_name, package_version, specrev, args)

0 commit comments

Comments
 (0)