Skip to content
Closed
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
42 changes: 33 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
- "master"
paths:
- 'rockspecs/**'
workflow_dispatch:
inputs:
version:
description: 'Version to publish, e.g. 4.1.6'
required: true

permissions:
contents: write
Expand All @@ -31,28 +36,47 @@ jobs:
shell: bash
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
INPUT_VERSION: ${{ inputs.version }}
run: |
title="$COMMIT_MESSAGE"
re="^feat: release v*(\S+)"
if [[ $title =~ $re ]]; then
echo "version=v${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
echo "version_without_v=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
if [[ -n "$INPUT_VERSION" ]]; then
version="${INPUT_VERSION#v}"
else
echo "commit format is not correct"
exit 1
title="$COMMIT_MESSAGE"
re="^feat: release v*(\S+)"
if [[ $title =~ $re ]]; then
version="${BASH_REMATCH[1]}"
else
echo "commit format is not correct"
exit 1
fi
fi
echo "version=v${version}" >> "$GITHUB_OUTPUT"
echo "version_without_v=${version}" >> "$GITHUB_OUTPUT"

- name: Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.release_env.outputs.version }}
run: |
gh release create "$VERSION" --title "$VERSION" --generate-notes
if gh release view "$VERSION" >/dev/null 2>&1; then
echo "release $VERSION already exists, skipping"
else
gh release create "$VERSION" --title "$VERSION" --generate-notes
fi

- name: Upload to luarocks
env:
LUAROCKS_TOKEN: ${{ secrets.LUAROCKS_TOKEN }}
VERSION_WITHOUT_V: ${{ steps.release_env.outputs.version_without_v }}
run: |
if [[ -z "$LUAROCKS_TOKEN" ]]; then
echo "LUAROCKS_TOKEN is empty: the org secret is not granted to this repository"
exit 1
fi
rockspec="rockspecs/lua-resty-session-api7-${VERSION_WITHOUT_V}-0.rockspec"
if [[ ! -f "$rockspec" ]]; then
echo "rockspec not found: $rockspec"
exit 1
fi
luarocks install dkjson
luarocks upload "rockspecs/lua-resty-session-api7-${VERSION_WITHOUT_V}-0.rockspec" --api-key="${LUAROCKS_TOKEN}"
luarocks upload "$rockspec" --api-key="${LUAROCKS_TOKEN}"
Loading