Skip to content

Commit

Permalink
feat: add specrev input (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored May 6, 2024
1 parent 9696a5c commit f6d8fb5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ Example:
### `version` (optional)

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

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

### `specrev` (optional)

The specrev (revision) of the generated rockspec. Defaults to `'1'`.

> [!TIP]
>
> When publishing `scm` or `dev` rockspecs, it can be useful to set
> point the source to a commit hash, and increment the `specrev` with every
> new push.
> This allows consumers to roll back or pin dev versions.

Example:

```yaml
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v5
with:
version: "scm"
# Add logic or determining if the specrev needs to be incremented
specrev: "${{ env.SPECREV }}"
```

### `extra_luarocks_args`

Extra args to pass to the luarocks command.
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ inputs:
Can also be set to `null`, `"scm"` or `"dev"` to publish a development rockspec.
required: false
default: ${{ github.ref_name }}
specrev:
description: |
The rockspec revision. Defaults to '1', resulting in <version>-1 as the <modrev>-<specrev>.
required: false
default: "1"
dependencies:
description: "List of LuaRocks dependencies."
required: false
Expand Down Expand Up @@ -76,6 +81,7 @@ runs:
env:
INPUT_NAME: ${{ inputs.name }}
INPUT_VERSION: ${{ inputs.version }}
INPUT_SPECREV: ${{ inputs.specrev }}
INPUT_DEPENDENCIES: ${{ inputs.dependencies }}
INPUT_TEST_DEPENDENCIES: ${{ inputs.test_dependencies }}
INPUT_LABELS: ${{ inputs.labels }}
Expand Down
4 changes: 3 additions & 1 deletion bin/luarocks-tag-release-action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ end

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

local specrev = '1'
local specrev
if is_pull_request then
print('Running in a pull request.')
specrev = assert(os.getenv('GITHUB_RUN_ATTEMPT'), 'GITHUB_RUN_ATTEMPT not set')
args.git_ref = get_github_sha()
else
specrev = os.getenv('INPUT_SPECREV') or '1'
end

luarocks_tag_release(package_name, package_version, specrev, args)

0 comments on commit f6d8fb5

Please sign in to comment.