From ef3f423c54229758695c3baa010175352c2494c4 Mon Sep 17 00:00:00 2001 From: AlinsRan Date: Wed, 8 Jul 2026 13:58:03 +0800 Subject: [PATCH 1/5] ci: add release workflow to publish to luarocks on tag Pushing a `v*` tag creates a GitHub release and uploads the matching root rockspec to luarocks. Follows the release CI convention used by other api7 lua-resty repositories, adapted to this repo's tag-based release flow and root rockspec layout. Requires the `LUAROCKS_TOKEN` repository secret. --- .github/workflows/release.yml | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..0f365589 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + push: + tags: + - "v*" + +permissions: + contents: write + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Lua + uses: leafo/gh-actions-lua@v10 + + - name: Install Luarocks + uses: leafo/gh-actions-luarocks@v4 + + - name: Extract release version + id: release_env + shell: bash + run: | + tag="${GITHUB_REF#refs/tags/}" + version="${tag#v}" + rockspec=$(ls "lua-resty-session-${version}"-*.rockspec 2>/dev/null | head -n1) + if [[ -z "$rockspec" ]]; then + echo "no rockspec found for version ${version}, expected lua-resty-session-${version}-*.rockspec" + exit 1 + fi + echo "tag=${tag}" >> "$GITHUB_OUTPUT" + echo "rockspec=${rockspec}" >> "$GITHUB_OUTPUT" + + - name: Create GitHub release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release create "${{ steps.release_env.outputs.tag }}" \ + --title "${{ steps.release_env.outputs.tag }}" \ + --generate-notes + + - name: Upload to luarocks + env: + LUAROCKS_TOKEN: ${{ secrets.LUAROCKS_TOKEN }} + run: | + luarocks upload "${{ steps.release_env.outputs.rockspec }}" --api-key="${LUAROCKS_TOKEN}" From 00abc9f246ca09dd861d99d39539cd6f9458c026 Mon Sep 17 00:00:00 2001 From: AlinsRan Date: Wed, 8 Jul 2026 14:51:14 +0800 Subject: [PATCH 2/5] ci: install dkjson before luarocks upload luarocks upload needs dkjson to communicate with the luarocks.org API, matching the release workflow of other api7 lua-resty repositories. --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f365589..92a6cb38 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,4 +48,5 @@ jobs: env: LUAROCKS_TOKEN: ${{ secrets.LUAROCKS_TOKEN }} run: | + luarocks install dkjson luarocks upload "${{ steps.release_env.outputs.rockspec }}" --api-key="${LUAROCKS_TOKEN}" From c104ade28c4d360219c0a933aa07b70c3faf003d Mon Sep 17 00:00:00 2001 From: AlinsRan Date: Wed, 8 Jul 2026 16:02:27 +0800 Subject: [PATCH 3/5] ci: align release workflow with api7 lua-resty-healthcheck Trigger on rockspec commits to master (paths: rockspecs/**), parse the version from a 'feat: release vX.Y.Z' commit message, create the GitHub release/tag, and upload rockspecs/lua-resty-session-api7--0.rockspec to luarocks. Mirrors the release CI of other api7 lua-resty repositories. --- .github/workflows/release.yml | 48 ++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 92a6cb38..50ebdccb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,11 +2,10 @@ name: Release on: push: - tags: - - "v*" - -permissions: - contents: write + branches: + - "master" + paths: + - 'rockspecs/**' jobs: release: @@ -14,39 +13,42 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v2 - name: Install Lua - uses: leafo/gh-actions-lua@v10 + uses: leafo/gh-actions-lua@v8 - name: Install Luarocks uses: leafo/gh-actions-luarocks@v4 - - name: Extract release version + - name: Extract release name id: release_env shell: bash run: | - tag="${GITHUB_REF#refs/tags/}" - version="${tag#v}" - rockspec=$(ls "lua-resty-session-${version}"-*.rockspec 2>/dev/null | head -n1) - if [[ -z "$rockspec" ]]; then - echo "no rockspec found for version ${version}, expected lua-resty-session-${version}-*.rockspec" - exit 1 + title="${{ github.event.head_commit.message }}" + re="^feat: release v*(\S+)" + if [[ $title =~ $re ]]; then + v=v${BASH_REMATCH[1]} + echo "##[set-output name=version;]${v}" + echo "##[set-output name=version_withou_v;]${BASH_REMATCH[1]}" + else + echo "commit format is not correct" + exit 1 fi - echo "tag=${tag}" >> "$GITHUB_OUTPUT" - echo "rockspec=${rockspec}" >> "$GITHUB_OUTPUT" - - name: Create GitHub release + - name: Create Release + uses: actions/create-release@v1 env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release create "${{ steps.release_env.outputs.tag }}" \ - --title "${{ steps.release_env.outputs.tag }}" \ - --generate-notes + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.release_env.outputs.version }} + release_name: ${{ steps.release_env.outputs.version }} + draft: false + prerelease: false - name: Upload to luarocks env: LUAROCKS_TOKEN: ${{ secrets.LUAROCKS_TOKEN }} run: | luarocks install dkjson - luarocks upload "${{ steps.release_env.outputs.rockspec }}" --api-key="${LUAROCKS_TOKEN}" + luarocks upload rockspecs/lua-resty-session-api7-${{ steps.release_env.outputs.version_withou_v }}-0.rockspec --api-key=${LUAROCKS_TOKEN} From 0f516c713f6c5010efecfbbe0364e80f23a57855 Mon Sep 17 00:00:00 2001 From: AlinsRan Date: Thu, 9 Jul 2026 13:58:03 +0800 Subject: [PATCH 4/5] feat: release v4.1.6 Add the release workflow and the 4.1.6 rockspec, published to luarocks as the api7-owned package lua-resty-session-api7. The workflow follows the release CI of other api7 lua-resty repositories (healthcheck / etcd / radixtree / expr): a rockspec commit on master with a 'feat: release vX.Y.Z' message creates the GitHub release/tag and uploads the rockspec to luarocks. Hardened against the script-injection issue present in the reference workflows: the commit message and derived step outputs are passed through env vars instead of being interpolated into the run script. --- .github/workflows/release.yml | 32 +++++++++-------- .../lua-resty-session-api7-4.1.6-0.rockspec | 36 +++++++++++++++++++ 2 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 rockspecs/lua-resty-session-api7-4.1.6-0.rockspec diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50ebdccb..c873acc7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,16 +7,21 @@ on: paths: - 'rockspecs/**' +permissions: + contents: write + jobs: release: name: Release runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + persist-credentials: false - name: Install Lua - uses: leafo/gh-actions-lua@v8 + uses: leafo/gh-actions-lua@v10 - name: Install Luarocks uses: leafo/gh-actions-luarocks@v4 @@ -24,31 +29,30 @@ jobs: - name: Extract release name id: release_env shell: bash + env: + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} run: | - title="${{ github.event.head_commit.message }}" + title="$COMMIT_MESSAGE" re="^feat: release v*(\S+)" if [[ $title =~ $re ]]; then - v=v${BASH_REMATCH[1]} - echo "##[set-output name=version;]${v}" - echo "##[set-output name=version_withou_v;]${BASH_REMATCH[1]}" + echo "version=v${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT" + echo "version_without_v=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT" else echo "commit format is not correct" exit 1 fi - name: Create Release - uses: actions/create-release@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.release_env.outputs.version }} - release_name: ${{ steps.release_env.outputs.version }} - draft: false - prerelease: false + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ steps.release_env.outputs.version }} + run: | + gh release create "$VERSION" --title "$VERSION" --generate-notes - 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 rockspecs/lua-resty-session-api7-${{ steps.release_env.outputs.version_withou_v }}-0.rockspec --api-key=${LUAROCKS_TOKEN} + luarocks upload "rockspecs/lua-resty-session-api7-${VERSION_WITHOUT_V}-0.rockspec" --api-key="${LUAROCKS_TOKEN}" diff --git a/rockspecs/lua-resty-session-api7-4.1.6-0.rockspec b/rockspecs/lua-resty-session-api7-4.1.6-0.rockspec new file mode 100644 index 00000000..4bf34697 --- /dev/null +++ b/rockspecs/lua-resty-session-api7-4.1.6-0.rockspec @@ -0,0 +1,36 @@ +package = "lua-resty-session-api7" +version = "4.1.6-0" +source = { + url = "git+https://github.com/api7/lua-resty-session.git", + tag = "v4.1.6", +} +description = { + summary = "Session Library for OpenResty - Flexible and Secure", + detailed = "lua-resty-session is a secure, and flexible session library for OpenResty.", + homepage = "https://github.com/api7/lua-resty-session", + license = "BSD", +} +dependencies = { + "lua >= 5.1", + "lua-ffi-zlib >= 0.5", + "lua-resty-openssl >= 1.5.0", +} +build = { + type = "builtin", + modules = { + ["resty.session"] = "lib/resty/session.lua", + ["resty.session.dshm"] = "lib/resty/session/dshm.lua", + ["resty.session.file"] = "lib/resty/session/file.lua", + ["resty.session.file.thread"] = "lib/resty/session/file/thread.lua", + ["resty.session.file.utils"] = "lib/resty/session/file/utils.lua", + ["resty.session.memcached"] = "lib/resty/session/memcached.lua", + ["resty.session.mysql"] = "lib/resty/session/mysql.lua", + ["resty.session.postgres"] = "lib/resty/session/postgres.lua", + ["resty.session.redis"] = "lib/resty/session/redis.lua", + ["resty.session.redis.cluster"] = "lib/resty/session/redis/cluster.lua", + ["resty.session.redis.sentinel"] = "lib/resty/session/redis/sentinel.lua", + ["resty.session.redis.common"] = "lib/resty/session/redis/common.lua", + ["resty.session.shm"] = "lib/resty/session/shm.lua", + ["resty.session.utils"] = "lib/resty/session/utils.lua", + }, +} From 563fe68f4ed6881d5084995490a9683d823b804e Mon Sep 17 00:00:00 2001 From: AlinsRan Date: Thu, 9 Jul 2026 14:02:25 +0800 Subject: [PATCH 5/5] ci: pin luarocks make to the root rockspec in tests luarocks' get_default_rockspec() scans '.', 'rockspec' and 'rockspecs', so adding rockspecs/ makes a bare 'luarocks make' ambiguous. The tests run inside docker with -w /test, so the cwd basename can't disambiguate by package name either. Pass the root rockspec explicitly. --- .github/workflows/integration_tests.yaml | 2 +- .github/workflows/unit_tests.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration_tests.yaml b/.github/workflows/integration_tests.yaml index 46c1d94f..7210ffb8 100644 --- a/.github/workflows/integration_tests.yaml +++ b/.github/workflows/integration_tests.yaml @@ -16,4 +16,4 @@ jobs: run: docker build dev/ -t resty-session - name: Run tests - run: docker run -v $PWD:/test -w /test resty-session bash -c "luarocks --lua-version 5.1 make && make prove" + run: docker run -v $PWD:/test -w /test resty-session bash -c "luarocks --lua-version 5.1 make ./*.rockspec && make prove" diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml index f37f13ac..8987e5d4 100644 --- a/.github/workflows/unit_tests.yaml +++ b/.github/workflows/unit_tests.yaml @@ -33,10 +33,10 @@ jobs: run: docker build dev/ -t resty-session - name: Run tests - run: docker run --network=host -v $PWD:/test -w /test resty-session bash -c "luarocks --lua-version 5.1 make && make unit" + run: docker run --network=host -v $PWD:/test -w /test resty-session bash -c "luarocks --lua-version 5.1 make ./*.rockspec && make unit" - name: Generate report - run: docker run --network=host -v $PWD:/test -w /test resty-session bash -c "luarocks --lua-version 5.1 make && luacov" + run: docker run --network=host -v $PWD:/test -w /test resty-session bash -c "luarocks --lua-version 5.1 make ./*.rockspec && luacov" - name: Print report summary run: docker run --network=host -v $PWD:/test -w /test resty-session sed -n '/Summary/,$p' luacov.report.out