Skip to content

Commit bc08b97

Browse files
committed
chore: cleanup
1 parent 922bb5f commit bc08b97

File tree

3 files changed

+141
-5
lines changed

3 files changed

+141
-5
lines changed
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: LuaRocks Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
paths-ignore:
9+
- '.github/**/*.yml'
10+
- '.gitignore'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: "Set latest version"
20+
id: set-latest-tag
21+
run: |
22+
currentVersion=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{github.repository}}/tags | jq -r 'sort_by(.name | split(".") | map(tonumber)) | reverse | .[0].name')
23+
echo "LATEST_VERSION=$currentVersion" >> $GITHUB_ENV
24+
- run: echo "Current version is ${{env.LATEST_VERSION}}"
25+
26+
- name: "Setup Lua"
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y lua5.1 luarocks
30+
sudo luarocks install lua-cjson
31+
- name: "Install semver"
32+
run: |
33+
# Download the script and save it to /usr/local/bin
34+
wget -O /usr/local/bin/semver https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
35+
# Make script executable
36+
chmod +x /usr/local/bin/semver
37+
# Prove it works
38+
semver --version
39+
- name: Increment version
40+
id: new_version
41+
run: |
42+
NEXT_VERSION=$(semver bump patch ${{env.LATEST_VERSION}})
43+
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_OUTPUT
44+
- run: echo "Next version is ${{ steps.new_version.outputs.NEXT_VERSION }}"
45+
46+
- name: Create new tag
47+
run: |
48+
git config --global user.email "noreply@skitsanos.com"
49+
git config --global user.name "ReleaseBot"
50+
git tag -a ${{ steps.new_version.outputs.NEXT_VERSION }} -m "release version ${{ steps.new_version.outputs.NEXT_VERSION }}"
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Push new tag
55+
run: git push origin ${{ steps.new_version.outputs.NEXT_VERSION }}
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Create rockspec
60+
run: luarocks write_rockspec --lua-versions 5.1 --license MIT --homepage https://github.com/skitsanos/lua-arangodb lua-arangodb ${{ steps.new_version.outputs.NEXT_VERSION }} .
61+
62+
- name: Package rock
63+
run: luarocks pack lua-arangodb-${{ steps.new_version.outputs.NEXT_VERSION }}-1.rockspec
64+
65+
- name: Upload rock
66+
env:
67+
LUAROCKS_USERNAME: ${{ secrets.LUAROCKS_USERNAME }}
68+
LUAROCKS_PASSWORD: ${{ secrets.LUAROCKS_TOKEN }}
69+
run: |
70+
echo "Uploading rock to LuaRocks"
71+
luarocks upload --api-key=$LUAROCKS_PASSWORD lua-arangodb-${{ steps.new_version.outputs.NEXT_VERSION }}-1.rockspec

README.md

+70-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,76 @@
1+
# ArangoDB Client for OpenResty
2+
13
### Dependencies
2-
- lua-cjson
3-
- base64
4-
- lua-resty-http
54

6-
### Testing
5+
- lua-cjson
6+
- base64
7+
- lua-resty-http
8+
9+
### Testing with resty utility
10+
11+
1. Open a terminal window and navigate to your Lua script's directory.
12+
2. Run the command `resty resty [your lua script name]` to execute the script.
13+
3. If your Lua script requires any input or parameters, you can pass them as arguments after the script name.
14+
4. For example, if your lua script is named 'test.lua' and it takes in a parameter 'name', you can run the command.'
15+
`resty test.lua name=John`.
16+
5. The output of the script will be displayed in the terminal.
17+
6. You can also redirect the output to a file by using the '>' operator, for example, `resty /usr/local/bin/resty
18+
test.lua name=John > output.txt`. This will save the script's output in a file named 'output.txt'.
19+
20+
**Example:**
21+
22+
Create a Lua file, for example `test.lua`:
23+
24+
```lua
25+
local arangodb = require("arangodb")
26+
27+
local db = arangodb.new({
28+
endpoint = "http://127.0.0.1:8529",
29+
username = "root",
30+
password = "openSesame",
31+
db = "debug"
32+
})
33+
34+
local success, results = pcall(function()
35+
return db:query("FOR i IN 1..10 RETURN i")
36+
end)
37+
38+
if success then
39+
-- print the results
40+
for _, v in ipairs(results) do
41+
print(v)
42+
end
43+
else
44+
-- print the error message
45+
print(results)
46+
end
47+
```
48+
49+
Now you could run it just like this:
50+
51+
```shell
52+
resty src/test.lua
53+
```
54+
55+
But because `arangodb` module is using few dependencies, you need to make sure they are installed:
56+
57+
```shell
58+
luarocks install lua-cjson
59+
luarocks install lbase64
60+
luarocks install lua-resty-http
61+
```
62+
63+
Then, when running with `resty` you need to provide the path to Lua libraries.
64+
65+
To include libraries installed by luarocks in your Lua script, you need to add the following line at the top of your
66+
script
67+
68+
```lua
69+
local luarocks_path = '/usr/local/share/lua/5.4/'
70+
package.path = package.path .. ";" .. luarocks_path .. "?.lua"
71+
```
772

73+
Or run with `-I` argument pointing to luarocks libraries:
874
```shell
975
resty -I /usr/local/share/lua/5.4/ src/test.lua
1076
```

src/test.lua

-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ else
2424
-- print the error message
2525
print(results)
2626
end
27-

0 commit comments

Comments
 (0)