Skip to content

Commit 80c423b

Browse files
authored
ci: add auto release workflow (#2)
1 parent 1138d1c commit 80c423b

File tree

6 files changed

+74
-59
lines changed

6 files changed

+74
-59
lines changed

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
if: "startsWith(github.event.head_commit.message, 'feat: release v')"
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Install Lua
17+
uses: leafo/gh-actions-lua@v8
18+
19+
- name: Install Luarocks
20+
uses: leafo/gh-actions-luarocks@v4
21+
22+
- name: Extract release name
23+
id: release_env
24+
shell: bash
25+
env:
26+
MESSAGE: ${{ github.event.head_commit.message }}
27+
run: |
28+
title="${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
38+
39+
- name: Check dot version
40+
shell: bash
41+
run: |
42+
if [ "${{ steps.release_env.outputs.version_withou_v }}" != "$(cat .version)" ]; then
43+
echo "VERSION '${{ steps.release_env.outputs.version_withou_v }}' does not match the dot version file '$(cat .version)'"
44+
exit 1
45+
fi
46+
47+
- name: Create Release
48+
uses: actions/create-release@v1
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
tag_name: ${{ steps.release_env.outputs.version_withou_v }}
53+
release_name: ${{ steps.release_env.outputs.version }}
54+
draft: false
55+
prerelease: false
56+
57+
- name: Upload to luarocks
58+
env:
59+
VERSION: ${{ steps.release_env.outputs.version_withou_v }}
60+
APIKEY: ${{ secrets.LUAROCKS_TOKEN }}
61+
run: make upload

.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.5.3

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ $(target_rock):
3434
[ -n "$$VERSION" ] || { echo VERSION not set; exit 1; }
3535
-@rm -rf /tmp/random_dir_2cs4f0tghRT
3636
mkdir /tmp/random_dir_2cs4f0tghRT
37-
cd /tmp/random_dir_2cs4f0tghRT; git clone https://github.com/kong/lua-resty-aws.git
37+
cd /tmp/random_dir_2cs4f0tghRT; git clone https://github.com/api7/lua-resty-aws.git
3838
cd /tmp/random_dir_2cs4f0tghRT/lua-resty-aws; if [ ! "${VERSION}" = "dev" ]; then git checkout ${VERSION}; fi
3939
cd /tmp/random_dir_2cs4f0tghRT/lua-resty-aws; make dev
4040
cd /tmp/random_dir_2cs4f0tghRT; zip -r lua-resty-aws-${VERSION}-1.src.rock lua-resty-aws
4141
cd /tmp/random_dir_2cs4f0tghRT; cat lua-resty-aws/lua-resty-aws-dev-1.rockspec | sed "s/package_version = \"dev\"/package_version = \"${VERSION}\"/" > lua-resty-aws-${VERSION}-1.rockspec
4242
cd /tmp/random_dir_2cs4f0tghRT; zip -r lua-resty-aws-${VERSION}-1.src.rock lua-resty-aws-${VERSION}-1.rockspec
43-
mv /tmp/random_dir_2cs4f0tghRT/lua-resty-aws-${VERSION}-1.src.rock ./
44-
-@rm lua-resty-aws-${VERSION}-1.rockspec
45-
mv /tmp/random_dir_2cs4f0tghRT/lua-resty-aws-${VERSION}-1.rockspec ./
43+
mv /tmp/random_dir_2cs4f0tghRT/lua-resty-aws-${VERSION}-1.src.rock ./api7-lua-resty-aws-${VERSION}-1.src.rock
44+
-@rm api7-lua-resty-aws-${VERSION}-1.rockspec
45+
mv /tmp/random_dir_2cs4f0tghRT/lua-resty-aws-${VERSION}-1.rockspec ./api7-lua-resty-aws-${VERSION}-1.rockspec
46+
4647

4748
pack: $(target_rock)
4849

lua-resty-aws-dev-1.rockspec.template

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
local package_name = "lua-resty-aws"
1+
local package_name = "api7-lua-resty-aws"
22
local package_version = "dev"
33
local rockspec_revision = "1"
4-
local github_account_name = "Kong"
5-
local github_repo_name = package_name
4+
local github_account_name = "api7"
5+
local github_repo_name = "lua-resty-aws"
66
local git_checkout = package_version == "dev" and "main" or package_version
77

88
package = package_name
99
version = package_version .. "-" .. rockspec_revision
1010

1111
source = {
1212
url = "git://github.com/"..github_account_name.."/"..github_repo_name..".git",
13-
branch = git_checkout
13+
tag = git_checkout
1414
}
1515

1616
description = {
@@ -19,7 +19,7 @@ description = {
1919
AWS SDK generated from the same data as the AWS JavaScript SDK.
2020
]],
2121
license = "Apache 2.0",
22-
homepage = "https://"..github_account_name..".github.io/"..github_repo_name.."/topics/README.md.html"
22+
homepage = "https://github.com/"..github_account_name.."/"..github_repo_name
2323
}
2424

2525
dependencies = {

test2.lua

Lines changed: 0 additions & 48 deletions
This file was deleted.

upload.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LR_API_KEY=$2
77
#LR_API_KEY=INfSIgkuArccxH9zq9M7enqackTiYtgRM6c9l6Y4
88

99

10-
ROCK_FILE=lua-resty-aws-$ROCK_VERSION.src.rock
11-
ROCKSPEC_FILE=lua-resty-aws-$ROCK_VERSION.rockspec
10+
ROCK_FILE=api7-lua-resty-aws-$ROCK_VERSION.src.rock
11+
ROCKSPEC_FILE=api7-lua-resty-aws-$ROCK_VERSION.rockspec
1212

1313
if [ "$ROCK_VERSION" == "-1" ]; then
1414
echo "First argument (version) is missing."

0 commit comments

Comments
 (0)