name: Luarocks

on:
  workflow_dispatch:
  push:
    tags:
      - '*'

jobs:
  luarocks-upload:
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0 # Required to get the tags

      - name: Get Version
        run: echo "LUAROCKS_VERSION=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV

      - name: Install C/C++ Compiler
        uses: rlalik/setup-cpp-compiler@master
        with:
          compiler: clang-latest

      - name: Install tree-sitter CLI
        uses: baptiste0928/cargo-install@v3
        with:
          crate: tree-sitter-cli

      - name: LuaRocks Upload
        uses: nvim-neorocks/luarocks-tag-release@v7
        env:
          LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
        with:
          version: ${{ env.LUAROCKS_VERSION }}
          dependencies: |
            tree-sitter-markdown
            tree-sitter-latex
            nvim-web-devicons
