Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ jobs:
ca-certificates \
cpanminus \
git \
lua5.1 \
luarocks \
wget

- name: Validate rockspec
run: luarocks make rockspec/api7-lua-resty-websocket-local-0.rockspec --local --tree /tmp/rockspec-check

- name: Build and test
env:
CC: gcc
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
push:
branches:
- master
paths:
- 'rockspec/**'
Comment thread
coderabbitai[bot] marked this conversation as resolved.

permissions:
contents: write

jobs:
release:
name: Release
runs-on: ubuntu-latest
# only run for a commit whose message starts with "feat: release vX.Y.Z";
# anything else touching rockspec/** (typo fixes, this workflow itself,
# etc.) should not show up as a failed run
if: "startsWith(github.event.head_commit.message, 'feat: release v')"

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Lua
uses: leafo/gh-actions-lua@v8

- name: Install Luarocks
uses: leafo/gh-actions-luarocks@v4

- name: Extract release version
id: release_env
shell: bash
env:
# route the commit message through the environment instead of
# interpolating it into the script source: it's attacker-controlled
# (anyone who can push a commit controls its message) and directly
# templating it into `run:` would let shell metacharacters in the
# message execute arbitrary commands in this job, which also holds
# GITHUB_TOKEN and LUAROCKS_TOKEN
TITLE: ${{ github.event.head_commit.message }}
run: |
# keep the captured version to a safe character set (this is still
# attacker-controlled input up to this point) before it's used in
# later steps' `run:` blocks
re="^feat: release v?([0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?)"
if [[ "$TITLE" =~ $re ]]; then
echo "version=v${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
echo "version_without_v=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
else
echo "head commit message does not match 'feat: release vX.Y.Z'" >&2
exit 1
fi

- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.release_env.outputs.version }}
run: |
gh release create "$VERSION" --title "$VERSION" --notes "Release $VERSION"

- name: Upload to LuaRocks
env:
LUAROCKS_TOKEN: ${{ secrets.LUAROCKS_TOKEN }}
VERSION_WITHOUT_V: ${{ steps.release_env.outputs.version_without_v }}
run: |
luarocks install dkjson
luarocks upload "rockspec/api7-lua-resty-websocket-${VERSION_WITHOUT_V}-0.rockspec" --api-key="$LUAROCKS_TOKEN"
30 changes: 14 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
OPENRESTY_PREFIX=/usr/local/openresty
### dev: Install runtime dependencies locally
.PHONY: dev
dev:
luarocks install rockspec/api7-lua-resty-websocket-master-0.rockspec --only-deps --local

PREFIX ?= /usr/local
LUA_INCLUDE_DIR ?= $(PREFIX)/include
LUA_LIB_DIR ?= $(PREFIX)/lib/lua/$(LUA_VERSION)
INSTALL ?= install

.PHONY: all test install

all: ;

install: all
$(INSTALL) -d $(DESTDIR)/$(LUA_LIB_DIR)/resty/websocket
$(INSTALL) lib/resty/websocket/*.lua $(DESTDIR)/$(LUA_LIB_DIR)/resty/websocket/

test: all
PATH=$(OPENRESTY_PREFIX)/nginx/sbin:$$PATH prove -I../test-nginx/lib -r t
### test: Run the test suite
.PHONY: test
test:
PATH="$(PWD)/work/nginx/sbin:$$PATH" prove -I. -r t/

### help: Show Makefile rules
.PHONY: help
help:
@echo Makefile rules:
@echo
@grep -E '^### [-A-Za-z0-9_]+:' Makefile | sed 's/###/ /'
6 changes: 6 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,12 @@ each request.
Installation
============

This fork is published to LuaRocks as `api7-lua-resty-websocket` (the `lua-resty-websocket` package name is already held by an unrelated LuaRocks account, hence the different name):

```shell
luarocks install api7-lua-resty-websocket
```

It is recommended to use the latest [OpenResty bundle](http://openresty.org) directly where this library
is bundled and enabled by default. At least OpenResty 1.4.2.9 is required. And you need to enable LuaJIT when building your OpenResty
bundle by passing the `--with-luajit` option to its `./configure` script. No extra Nginx configuration is required.
Expand Down
30 changes: 30 additions & 0 deletions rockspec/api7-lua-resty-websocket-local-0.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package = "api7-lua-resty-websocket"
version = "local-0"
source = {
url = "file://."
}

description = {
summary = "Lua WebSocket implementation for the ngx_lua module",
detailed = [[
api7-lua-resty-websocket is api7's fork of the OpenResty WebSocket
library. It implements WebSocket server and client libraries based
on the ngx_lua module, taking advantage of ngx_lua's cosocket API
for fully nonblocking behavior. It also carries a WebSocket reverse
proxy module ported from Kong/lua-resty-websocket-proxy.
]],
homepage = "https://github.com/api7/lua-resty-websocket",
license = "2-clause BSD",
}

dependencies = {}

build = {
type = "builtin",
modules = {
["resty.websocket.client"] = "lib/resty/websocket/client.lua",
["resty.websocket.server"] = "lib/resty/websocket/server.lua",
["resty.websocket.protocol"] = "lib/resty/websocket/protocol.lua",
["resty.websocket.proxy"] = "lib/resty/websocket/proxy.lua",
}
}
31 changes: 31 additions & 0 deletions rockspec/api7-lua-resty-websocket-master-0.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package = "api7-lua-resty-websocket"
version = "master-0"
source = {
url = "git+https://github.com/api7/lua-resty-websocket",
branch = "master",
}

description = {
summary = "Lua WebSocket implementation for the ngx_lua module",
detailed = [[
api7-lua-resty-websocket is api7's fork of the OpenResty WebSocket
library. It implements WebSocket server and client libraries based
on the ngx_lua module, taking advantage of ngx_lua's cosocket API
for fully nonblocking behavior. It also carries a WebSocket reverse
proxy module ported from Kong/lua-resty-websocket-proxy.
]],
homepage = "https://github.com/api7/lua-resty-websocket",
license = "2-clause BSD",
}

dependencies = {}

build = {
type = "builtin",
modules = {
["resty.websocket.client"] = "lib/resty/websocket/client.lua",
["resty.websocket.server"] = "lib/resty/websocket/server.lua",
["resty.websocket.protocol"] = "lib/resty/websocket/protocol.lua",
["resty.websocket.proxy"] = "lib/resty/websocket/proxy.lua",
}
}