diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 18a93dfd..a4d23730 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,8 +2,10 @@ name: Release on: push: - tags: - - '*' + branches: + - "master" + paths: + - 'rockspec/**' jobs: release: @@ -19,27 +21,34 @@ jobs: - name: Install Luarocks uses: leafo/gh-actions-luarocks@v4 - - name: Extract tag name - id: tag_env + - name: Extract release name + id: release_env shell: bash - run: echo "##[set-output name=version;]$(echo ${GITHUB_REF##*/})" - - # use ${tag:1} to filter out the heading "v" of "v1.0" - - name: Upload to luarocks - env: - LUAROCKS_TOKEN: ${{ secrets.LUAROCKS_TOKEN }} run: | - luarocks install dkjson - tag=${{ steps.tag_env.outputs.version }} - luarocks upload rockspec/lua-resty-etcd-${tag:1}-0.rockspec --api-key=${LUAROCKS_TOKEN} + 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 - name: Create Release - id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tag_name: ${{ steps.tag_env.outputs.version }} - release_name: ${{ steps.tag_env.outputs.version }} + 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 rockspec/lua-resty-etcd-${{ steps.release_env.outputs.version_withou_v }}-0.rockspec --api-key=${LUAROCKS_TOKEN} diff --git a/MAINTAINING.md b/MAINTAINING.md index 0fa05848..c19fc015 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -1,8 +1,7 @@ ## Version Publish -After [#117](https://github.com/api7/lua-resty-etcd/pull/117) got merged, we could publish new version of lua-resty-etcd easily. All you need to do is: +After [#137](https://github.com/api7/lua-resty-etcd/pull/137) got merged, we could publish new version of lua-resty-etcd easily. All you need to do is: -- Create a PR that add the rockspec for the new version. -- Create a tag with format like 'v1.0'. +- Create the release PR following the format `feat: release VERSION`, where `VERSION` should be the version used in the rockspec name, like `1.0` for `lua-resty-etcd-1.0-0.rockspec`. -The tag would trigger Github Actions to upload to both luarocks and github release. +When the PR got merged, it would trigger Github Actions to upload to both github release and luarocks.