Skip to content
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

Add bump-patch workflow #5

Merged
merged 1 commit into from
Mar 12, 2022
Merged
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
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