|
1 | 1 | name: Deploy |
2 | 2 |
|
3 | | -on: |
4 | | - push: |
5 | | - tags: |
6 | | - - v* |
7 | | - paths: |
8 | | - - rockspecs/*.rockspec |
| 3 | +on: [ push, workflow_dispatch ] |
9 | 4 |
|
10 | 5 | jobs: |
11 | 6 |
|
12 | 7 | 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 |
26 | 9 |
|
27 | 10 | build: |
28 | 11 | needs: affected |
29 | 12 | 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 }} |
53 | 16 |
|
54 | 17 | 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