From 30579eada646a4ac7f90aba7c5ae26f58d6c1b5e Mon Sep 17 00:00:00 2001 From: goldenstein64 Date: Fri, 8 Aug 2025 11:43:12 -0400 Subject: [PATCH 1/3] ci(publish): add publish workflow --- .github/workflows/publish.yml | 49 +++++++++++++++++++++++++++++++++++ rockspec.template | 36 +++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100644 rockspec.template diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..bf5938b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,49 @@ +name: Publish + +on: + push: + tags: v[0-9]+.[0-9]+.[0-9]+.[0-9]+* + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: write + env: + package_name: lls-addon-luafilesystem + spec_revision: 1 + src_rock_name: "" + + name: Publish to LuaRocks and GitHub + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Publish to LuaRocks + uses: nvim-neorocks/luarocks-tag-release@v7 + env: + LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} + with: + name: ${{ env.package_name }} + copy_directories: "" + license: MIT + template: ./rockspec.template + specrev: ${{ env.spec_revision }} + + - name: Retrieve Source Rock + run: | + if [[ "${{ github.ref_name }}" =~ ^v(.+)$ ]]; then + spec_version="${BASH_REMATCH[1]}-${{ env.spec_revision }}" + else + echo "rockspec version not found" >&2 + exit 1 + fi + + src_rock_name="${{ env.package_name }}-${spec_version}.src.rock" + curl --fail --output "${src_rock_name}" "https://luarocks.org/${src_rock_name}" + echo "src_rock_name=${src_rock_name}" >> $GITHUB_ENV + + - name: GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: ${{ env.src_rock_name }} diff --git a/rockspec.template b/rockspec.template new file mode 100644 index 0000000..78f1707 --- /dev/null +++ b/rockspec.template @@ -0,0 +1,36 @@ +local git_ref = '$git_ref' +local modrev = '$modrev' +local specrev = '$specrev' + +local repo_url = '$repo_url' + +rockspec_format = '3.0' +package = '$package' +version = modrev ..'-'.. specrev + +description = { + summary = '$summary', + detailed = $detailed_description, + labels = $labels, + homepage = '$homepage', + $license +} + +dependencies = $dependencies + +test_dependencies = $test_dependencies + +source = { + url = repo_url .. '/archive/' .. git_ref .. '.zip', + dir = '$repo_name-' .. '$archive_dir_suffix', +} + +if modrev == 'scm' or modrev == 'dev' then + source = { + url = repo_url:gsub('https', 'git') + } +end + +build = { + type = 'lls-addon', +} From 757855782055fcdc128d3a41748832d07029ecb0 Mon Sep 17 00:00:00 2001 From: goldenstein64 Date: Thu, 14 Aug 2025 11:03:39 -0400 Subject: [PATCH 2/3] ci(publish): upload using LuaRocks CLI --- .github/workflows/publish.yml | 54 ++++++++++++---------- lls-addon-luafilesystem-release-1.rockspec | 22 +++++++++ rockspec.template | 36 --------------- 3 files changed, 51 insertions(+), 61 deletions(-) create mode 100644 lls-addon-luafilesystem-release-1.rockspec delete mode 100644 rockspec.template diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bf5938b..1b3ffb5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,39 +11,43 @@ jobs: contents: write env: package_name: lls-addon-luafilesystem - spec_revision: 1 - src_rock_name: "" + spec_version: "" # this gets set in the Get Rockspec Version step - name: Publish to LuaRocks and GitHub steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Publish to LuaRocks - uses: nvim-neorocks/luarocks-tag-release@v7 - env: - LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} - with: - name: ${{ env.package_name }} - copy_directories: "" - license: MIT - template: ./rockspec.template - specrev: ${{ env.spec_revision }} - - - name: Retrieve Source Rock + - name: Get Rockspec Version run: | if [[ "${{ github.ref_name }}" =~ ^v(.+)$ ]]; then - spec_version="${BASH_REMATCH[1]}-${{ env.spec_revision }}" + echo "spec_version=${BASH_REMATCH[1]}-1" >> $GITHUB_ENV else - echo "rockspec version not found" >&2 + echo "rockspec version could not be matched" >&2 exit 1 fi - src_rock_name="${{ env.package_name }}-${spec_version}.src.rock" - curl --fail --output "${src_rock_name}" "https://luarocks.org/${src_rock_name}" - echo "src_rock_name=${src_rock_name}" >> $GITHUB_ENV + - uses: actions/checkout@v4 + + - name: Set up Lua + uses: leafo/gh-actions-lua@v11 + with: + luaVersion: "5.4.8" + + - name: Set up LuaRocks + uses: leafo/gh-actions-luarocks@v5 + with: + luaRocksVersion: "3.12.2" + + - name: Write LuaRocks Rockspec + run: | + luarocks new_version \ + --tag ${{ github.ref_name }} \ + ${{ env.package_name }}-release-1.rockspec + + - name: Publish to LuaRocks + run: | + luarocks upload \ + "./${{ env.package_name }}-${{ env.spec_version }}.rockspec" \ + --api-key=${{ secrets.LUAROCKS_API_KEY }} - - name: GitHub Release + - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - files: ${{ env.src_rock_name }} + files: "${{ env.package_name }}-${{ env.spec_version }}.src.rock" diff --git a/lls-addon-luafilesystem-release-1.rockspec b/lls-addon-luafilesystem-release-1.rockspec new file mode 100644 index 0000000..ea42af3 --- /dev/null +++ b/lls-addon-luafilesystem-release-1.rockspec @@ -0,0 +1,22 @@ +rockspec_format = "3.0" +package = "lls-addon-luafilesystem" +version = "release-1" + +source = { + url = "git+https://github.com/LuaCATS/luafilesystem", +} + +description = { + summary = "LuaLS type definitions for LuaFileSystem library", + license = "MIT", + homepage = "https://github.com/LuaCATS/luafilesystem", +} + +build = { + type = "lls-addon", + settings = { + diagnostics = { + globals = { "lfs" } + } + } +} \ No newline at end of file diff --git a/rockspec.template b/rockspec.template deleted file mode 100644 index 78f1707..0000000 --- a/rockspec.template +++ /dev/null @@ -1,36 +0,0 @@ -local git_ref = '$git_ref' -local modrev = '$modrev' -local specrev = '$specrev' - -local repo_url = '$repo_url' - -rockspec_format = '3.0' -package = '$package' -version = modrev ..'-'.. specrev - -description = { - summary = '$summary', - detailed = $detailed_description, - labels = $labels, - homepage = '$homepage', - $license -} - -dependencies = $dependencies - -test_dependencies = $test_dependencies - -source = { - url = repo_url .. '/archive/' .. git_ref .. '.zip', - dir = '$repo_name-' .. '$archive_dir_suffix', -} - -if modrev == 'scm' or modrev == 'dev' then - source = { - url = repo_url:gsub('https', 'git') - } -end - -build = { - type = 'lls-addon', -} From 6757f7440908b11119a95e34b12fd466f870eeb6 Mon Sep 17 00:00:00 2001 From: goldenstein64 Date: Thu, 14 Aug 2025 11:09:14 -0400 Subject: [PATCH 3/3] style(rockspec): add EOF newline and some commas --- lls-addon-luafilesystem-release-1.rockspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lls-addon-luafilesystem-release-1.rockspec b/lls-addon-luafilesystem-release-1.rockspec index ea42af3..ba06b3c 100644 --- a/lls-addon-luafilesystem-release-1.rockspec +++ b/lls-addon-luafilesystem-release-1.rockspec @@ -16,7 +16,7 @@ build = { type = "lls-addon", settings = { diagnostics = { - globals = { "lfs" } + globals = { "lfs" }, } } -} \ No newline at end of file +}