Skip to content

Commit 05dfcc4

Browse files
authored
ci: refine auto release steps (#137)
1 parent 82fb8d5 commit 05dfcc4

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

.github/workflows/release.yml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: Release
22

33
on:
44
push:
5-
tags:
6-
- '*'
5+
branches:
6+
- "master"
7+
paths:
8+
- 'rockspec/**'
79

810
jobs:
911
release:
@@ -19,27 +21,34 @@ jobs:
1921
- name: Install Luarocks
2022
uses: leafo/gh-actions-luarocks@v4
2123

22-
- name: Extract tag name
23-
id: tag_env
24+
- name: Extract release name
25+
id: release_env
2426
shell: bash
25-
run: echo "##[set-output name=version;]$(echo ${GITHUB_REF##*/})"
26-
27-
# use ${tag:1} to filter out the heading "v" of "v1.0"
28-
- name: Upload to luarocks
29-
env:
30-
LUAROCKS_TOKEN: ${{ secrets.LUAROCKS_TOKEN }}
3127
run: |
32-
luarocks install dkjson
33-
tag=${{ steps.tag_env.outputs.version }}
34-
luarocks upload rockspec/lua-resty-etcd-${tag:1}-0.rockspec --api-key=${LUAROCKS_TOKEN}
28+
title="${{ github.event.head_commit.message }}"
29+
re="^feat: release v*(\S+)"
30+
if [[ $title =~ $re ]]; then
31+
v=v${BASH_REMATCH[1]}
32+
echo "##[set-output name=version;]${v}"
33+
echo "##[set-output name=version_withou_v;]${BASH_REMATCH[1]}"
34+
else
35+
echo "commit format is not correct"
36+
exit 1
37+
fi
3538
3639
- name: Create Release
37-
id: create_release
3840
uses: actions/create-release@v1
3941
env:
4042
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4143
with:
42-
tag_name: ${{ steps.tag_env.outputs.version }}
43-
release_name: ${{ steps.tag_env.outputs.version }}
44+
tag_name: ${{ steps.release_env.outputs.version }}
45+
release_name: ${{ steps.release_env.outputs.version }}
4446
draft: false
4547
prerelease: false
48+
49+
- name: Upload to luarocks
50+
env:
51+
LUAROCKS_TOKEN: ${{ secrets.LUAROCKS_TOKEN }}
52+
run: |
53+
luarocks install dkjson
54+
luarocks upload rockspec/lua-resty-etcd-${{ steps.release_env.outputs.version_withou_v }}-0.rockspec --api-key=${LUAROCKS_TOKEN}

MAINTAINING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
## Version Publish
22

3-
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:
3+
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:
44

5-
- Create a PR that add the rockspec for the new version.
6-
- Create a tag with format like 'v1.0'.
5+
- 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`.
76

8-
The tag would trigger Github Actions to upload to both luarocks and github release.
7+
When the PR got merged, it would trigger Github Actions to upload to both github release and luarocks.

0 commit comments

Comments
 (0)