-
-
Notifications
You must be signed in to change notification settings - Fork 57
38 lines (35 loc) · 1.23 KB
/
bump-patch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Bump patch version
on: workflow_dispatch
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ssh-key: "${{ secrets.PUSH_TAG_PRIVATE_KEY }}"
- name: Bump version
run: |
git fetch --tags
# This suppress an error occurred when the repository is a complete one.
git fetch --prune --unshallow || true
# Get a latest tag in the shape of semver.
latest_tag=''
for ref in $(git for-each-ref --sort=-creatordate --format '%(refname)' refs/tags); do
tag="${ref#refs/tags/}"
if echo "${tag}" | grep -Eq '^v?([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$'; then
latest_tag="${tag}"
break
fi
done
if [ "${latest_tag}" = '' ]; then
latest_tag="v0.0.0"
fi
# bump version
npm install -g semver
new_tag=v$(semver $latest_tag -i patch)
echo "::debug::New tag is $new_tag"
# push new tag
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git tag -a $new_tag -m "$new_tag"
git push origin $new_tag