Skip to content

Commit b010963

Browse files
committed
ci: Reuse deploy workflow from lunarmodules
1 parent 09e9cd9 commit b010963

File tree

1 file changed

+22
-61
lines changed

1 file changed

+22
-61
lines changed

.github/workflows/deploy.yml

Lines changed: 22 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,34 @@
11
name: Deploy
22

3-
on:
4-
push:
5-
tags:
6-
- v*
7-
paths:
8-
- rockspecs/*.rockspec
3+
on: [ push, workflow_dispatch ]
94

105
jobs:
116

127
affected:
13-
runs-on: ubuntu-20.04
14-
outputs:
15-
rockspecs: '["${{ steps.changed-files.outputs.all_modified_files }}"]'
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v3
19-
with:
20-
fetch-depth: 0
21-
- id: changed-files
22-
uses: tj-actions/changed-files@v18
23-
with:
24-
files: rockspecs/*.rockspec
25-
separator: '", "'
8+
uses: lunarmodules/.github/.github/workflows/list_affected_rockspecs.yml@main
269

2710
build:
2811
needs: affected
2912
if: ${{ needs.affected.outputs.rockspecs }}
30-
strategy:
31-
fail-fast: false
32-
matrix:
33-
# Upstream Issue: https://github.com/leafo/gh-actions-luarocks/issues/8
34-
luaVersion: ["5.4", "5.3", "5.2", "5.1"] #, "luajit", "luajit-openresty"]
35-
# Upstream Issue: https://github.com/leafo/gh-actions-luarocks/issues/8
36-
luarocksVersion: ["3.1.3"] # , "2.4.2"]
37-
rockspec: ${{ fromJSON(needs.affected.outputs.rockspecs) }}
38-
runs-on: ubuntu-20.04
39-
steps:
40-
- name: Checkout
41-
uses: actions/checkout@v3
42-
- name: Setup ‘lua’
43-
uses: leafo/gh-actions-lua@v9
44-
with:
45-
luaVersion: ${{ matrix.luaVersion }}
46-
- name: Setup ‘luarocks’
47-
uses: leafo/gh-actions-luarocks@v4
48-
with:
49-
luarocksVersion: ${{ matrix.luarocksVersion }}
50-
- name: Confirm rockspec builds
51-
run: |
52-
luarocks --lua-version ${{ matrix.luaVersion }} --local build -- ${{ matrix.rockspec }}
13+
uses: lunarmodules/.github/.github/workflows/test_build_rock.yml@main
14+
with:
15+
rockspecs: ${{ needs.affected.outputs.rockspecs }}
5316

5417
upload:
55-
needs: [affected, build]
56-
if: ${{ needs.affected.outputs.rockspecs && startsWith(github.ref, 'refs/tags/') && github.repository == 'alerque/fluent-lua' }}
57-
strategy:
58-
fail-fast: false
59-
matrix:
60-
rockspec: ${{ fromJSON(needs.affected.outputs.rockspecs) }}
61-
runs-on: ubuntu-20.04
62-
steps:
63-
- name: Checkout
64-
uses: actions/checkout@v3
65-
- name: Setup ‘lua’
66-
uses: leafo/gh-actions-lua@v9
67-
- name: Setup ‘luarocks’
68-
uses: leafo/gh-actions-luarocks@v4
69-
- name: Setup dependencies
70-
run: |
71-
luarocks install dkjson
72-
- run: |
73-
luarocks upload --force --api-key ${{ secrets.LUAROCKS_APIKEY }} -- ${{ matrix.rockspec }}
18+
needs: [ affected, build ]
19+
# Only run upload if:
20+
# 1. Some rockspecs were changed — this implies the commit changing the rockspec is the same one that gets tagged
21+
# 2. The current commit is either tagged or on the default branch (the workflow will upload dev/scm rockspecs any
22+
# time they are touched, tagged ones whenever the edited rockspec and tag match)
23+
# 3. We are on the canonical repository (no uploads from forks)
24+
if: >-
25+
${{
26+
github.repository == 'alerque/fluent-lua' &&
27+
( github.ref_name == 'master' || startsWith(github.ref, 'refs/tags/') ) &&
28+
needs.affected.outputs.rockspecs
29+
}}
30+
uses: lunarmodules/.github/.github/workflows/upload_to_luarocks.yml@main
31+
with:
32+
rockspecs: ${{ needs.affected.outputs.rockspecs }}
33+
secrets:
34+
apikey: ${{ secrets.LUAROCKS_APIKEY }}

0 commit comments

Comments
 (0)