Skip to content

Commit

Permalink
Add workflow to bump patch version (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fs02 committed Oct 19, 2021
1 parent 49c98fb commit f63d7d7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/bump-patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Bump patch version

on: workflow_dispatch

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
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

0 comments on commit f63d7d7

Please sign in to comment.