44 workflow_dispatch :
55 inputs :
66 rockspec :
7- description : " Rockspec file to validate"
7+ description : " Rockspec file to validate or publish "
88 required : true
9- default : " luasf-0.3.0-1.rockspec"
9+ default : " luasf-0.4.0-1.rockspec"
10+ type : string
11+ publish :
12+ description : " Publish to LuaRocks after validation"
13+ required : true
14+ default : false
15+ type : boolean
16+
17+ permissions :
18+ contents : read
19+
20+ concurrency :
21+ group : luarocks-publish
22+ cancel-in-progress : false
1023
1124jobs :
1225 validate :
1528
1629 steps :
1730 - name : Checkout repository
18- uses : actions/checkout@v4
31+ uses : actions/checkout@v5
1932
2033 - name : Set up Lua
2134 uses : leafo/gh-actions-lua@v13
@@ -26,10 +39,38 @@ jobs:
2639 uses : leafo/gh-actions-luarocks@v6
2740
2841 - name : Validate rockspec
29- run : luarocks lint "${{ github.event. inputs.rockspec }}"
42+ run : luarocks lint "${{ inputs.rockspec }}"
3043
3144 - name : Build rock locally
32- run : luarocks make "${{ github.event.inputs.rockspec }}"
45+ run : luarocks make "${{ inputs.rockspec }}"
46+
47+ - name : Test LuaRocks package entry point
48+ run : lua -e 'local stats = require("luasf"); print(stats.sum({1,2,3}))'
49+
50+ - name : Test LuaSF compatibility entry point
51+ run : lua -e 'local stats = require("LuaSF"); print(stats.sumF({1,2,3}))'
52+
53+ - name : Test LuaStat compatibility entry point
54+ run : lua -e 'local stats = require("LuaStat"); print(stats.avF({2,4,6}))'
55+
56+ publish :
57+ name : Publish to LuaRocks
58+ needs : validate
59+ runs-on : ubuntu-latest
60+ if : ${{ inputs.publish == true }}
61+ environment : luarocks-production
62+
63+ steps :
64+ - name : Checkout repository
65+ uses : actions/checkout@v5
66+
67+ - name : Set up Lua
68+ uses : leafo/gh-actions-lua@v13
69+ with :
70+ luaVersion : " 5.4.8"
71+
72+ - name : Set up LuaRocks
73+ uses : leafo/gh-actions-luarocks@v6
3374
3475 - name : Upload to LuaRocks
35- run : luarocks upload "${{ github.event. inputs.rockspec }}" --api-key="${{ secrets.LUAROCKS_API_KEY }}"
76+ run : luarocks upload "${{ inputs.rockspec }}" --api-key="${{ secrets.LUAROCKS_API_KEY }}"
0 commit comments