Skip to content

ci: refine auto release steps #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
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
41 changes: 25 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ name: Release

on:
push:
tags:
- '*'
branches:
- "master"
paths:
- 'rockspec/**'

jobs:
release:
Expand All @@ -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}
7 changes: 3 additions & 4 deletions MAINTAINING.md
Original file line number Diff line number Diff line change
@@ -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.