From 658ab27d704c50d09fe226d41d0da7ff618f89cd Mon Sep 17 00:00:00 2001 From: yiyiyimu Date: Tue, 29 Jun 2021 16:27:51 -0400 Subject: [PATCH 1/2] ci: refine auto release steps Signed-off-by: yiyiyimu --- .github/workflows/release.yml | 41 +++++++++++++++++++++-------------- MAINTAINING.md | 7 +++--- 2 files changed, 28 insertions(+), 20 deletions(-) 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..216a4766 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 a 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. From a2f8fa3160c3156c3840aaa4f12c7948ec89d139 Mon Sep 17 00:00:00 2001 From: yiyiyimu Date: Tue, 29 Jun 2021 16:32:31 -0400 Subject: [PATCH 2/2] update docs Signed-off-by: yiyiyimu --- MAINTAINING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINING.md b/MAINTAINING.md index 216a4766..c19fc015 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -2,6 +2,6 @@ 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 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`. +- 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`. When the PR got merged, it would trigger Github Actions to upload to both github release and luarocks.