Changes names of rockspecs to conform to luarocks requirements/best p… #61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test-and-publish | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
pull_request: | |
jobs: | |
tests-51: | |
uses: ./.github/workflows/run-tests.yml | |
with: | |
lua-version: 5.1 | |
tests-52: | |
uses: ./.github/workflows/run-tests.yml | |
with: | |
lua-version: 5.2 | |
tests-53: | |
uses: ./.github/workflows/run-tests.yml | |
with: | |
lua-version: 5.3 | |
tests-54: | |
uses: ./.github/workflows/run-tests.yml | |
with: | |
lua-version: 5.4 | |
publish: | |
name: Publish to LuaRocks | |
runs-on: ubuntu-latest | |
needs: [tests-51, tests-52, tests-53, tests-54] | |
steps: | |
- uses: actions/checkout@main | |
- name: Install Lua/LuaJIT | |
uses: leafo/gh-actions-lua@v8.0.0 | |
with: | |
luaVersion: 5.4 | |
- name: Install LuaRocks | |
uses: leafo/gh-actions-luarocks@v4.0.0 | |
- name: Install dkjson | |
# Publishing to LuaRocks requires a JSON library such as cjson, dkjson or json. | |
run: | | |
luarocks install dkjson | |
- name: Publish scm version to LuaRocks | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
luarocks upload lazylualinq-scm-1.rockspec --force --api-key=${{ secrets.LUAROCKS_API_KEY }} | |
- name: Extract version from tag | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
id: extract-version | |
run: | | |
echo "VERSION=$(echo ${{ github.ref_name }} | cut -c 2-)" >> "$GITHUB_OUTPUT" | |
- name: Fail run if there's no valid rockspec | |
if: ${{ startsWith(github.ref, 'refs/tags/v') && hashFiles(format('lazylualinq-{0}-1.rockspec', steps.extract-version.outputs.VERSION)) == '' }} | |
run: | | |
exit 1 | |
- name: Publish release version to LuaRocks | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
run: | | |
luarocks upload lazylualinq-${{ steps.extract-version.outputs.VERSION }}-1.rockspec --api-key=${{ secrets.LUAROCKS_API_KEY }} | |