forked from openresty/lua-resty-websocket
-
Notifications
You must be signed in to change notification settings - Fork 0
ci: add release workflow #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| paths: | ||
| - 'rockspec/**' | ||
|
|
||
| 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" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/###/ /' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.