Skip to content

MunifTanjim/luarocks-publish-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LuaRocks Publish - GitHub Action

πŸŒ› Publish to LuaRocks using GitHub Actions

Preparation

Rockspec Template:

Create a <packge-name>-dev-1.rockspec file on your repository root:

rockspec_format = "3.0"
package = "dummy.lua"
version = "dev-1"
source = {
  url = "git+https://github.com/MunifTanjim/dummy.lua.git",
  tag = nil,
}
description = {
  summary = "Dummy Package to test LuaRocks!",
  detailed = [[
    Dummy Package to test LuaRocks!
  ]],
  license = "MIT",
  homepage = "https://github.com/MunifTanjim/dummy.lua",
  issues_url = "https://github.com/MunifTanjim/dummy.lua/issues",
  maintainer = "Munif Tanjim (https://muniftanjim.dev)",
  labels = {},
}
build = {
  type = "builtin",
}

This will be used as a template for your package rockspec.

Note

  • version must be "dev-1"
  • source.tag must be nil

Configuration

input description
lua_version Lua version to install (required)
luajit_version LuaJIT version to install (optional)
luarocks_version LuaRocks version to install (required)
name Package name (optional, default: repository name )
version Version to publish (optional, default: 'dev')
api_key LuaRocks API Key (required)
force Force publish (optional, default: 'false')

Check action.yml.

Usage

Basic

# .github/workflows/publish.yml

name: Publish

on:
  push:
    tags:
      - "[0-1].[0-9]+.[0-9]+"

jobs:
  publish:
    name: publish
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: LuaRocks Publish
        uses: MunifTanjim/luarocks-publish-action@v1
        with:
          lua_version: 5.1.5
          luarocks_version: 3.9.1
          api_key: ${{ secrets.LUAROCKS_API_KEY }}

Workflow Dispatch

# .github/workflows/publish.yml

name: Publish

on:
  push:
    tags:
      - "[0-1].[0-9]+.[0-9]+"
  workflow_dispatch:
    inputs:
      version:
        description: Version to publish
        required: false
        type: string
      force:
        description: Force publish
        required: false
        default: false
        type: boolean

jobs:
  publish:
    name: publish
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: LuaRocks Publish
        uses: MunifTanjim/luarocks-publish-action@v1
        with:
          lua_version: 5.1.5
          luarocks_version: 3.9.1
          version: ${{ inputs.version }}
          api_key: ${{ secrets.LUAROCKS_API_KEY }}
          force: ${{ inputs.force }}

Trigger using GitHub CLI:

gh workflow run --repo MunifTanjim/dummy.lua publish.yml -f version=dev -f force=false

Trigger using Release Please Action:

# .github/workflows/ci.yml

name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  release:
    name: release
    if: ${{ github.ref == 'refs/heads/main' }}
    runs-on: ubuntu-latest
    permissions:
      actions: write
      contents: write
      pull-requests: write
    steps:
      - uses: google-github-actions/release-please-action@v3
        id: release
        with:
          release-type: simple
          package-name: dummy.lua
          bump-minor-pre-major: true
          pull-request-title-pattern: "chore: release ${version}"
          include-v-in-tag: false
      - name: Trigger Publish
        if: ${{ steps.release.outputs.release_created }}
        env:
          GH_TOKEN: ${{ github.token }}
          TAG_NAME: ${{ steps.release.outputs.tag_name }}
        run: |
          gh workflow run --repo ${GITHUB_REPOSITORY} publish.yml -f version=${TAG_NAME}

License

Licensed under the MIT License. Check the LICENSE file for details.