Skip to content

Commit

Permalink
feat(github-actions): enhance script to handle initial release tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
godcong committed Jul 10, 2024
1 parent 2cdc354 commit 47e5463
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/git/next_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Use git describe to find the latest tag
NEXT_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))

if [[ -z "$NEXT_TAG" ]]; then
NEXT_TAG="v0.0.1"
else
# Remove 'v' prefix using bash parameter expansion
NEXT_TAG=${NEXT_TAG#v}
IFS='.' read -r -a VERSION_ARRAY <<< "$NEXT_TAG"
MAJOR=${VERSION_ARRAY[0]}
MINOR=${VERSION_ARRAY[1]}
PATCH=${VERSION_ARRAY[2]}
(( PATCH++ ))
NEXT_TAG=v$MAJOR.$MINOR.$PATCH
# Output the latest tag for use in subsequent steps
echo "$NEXT_TAG"
fi

0 comments on commit 47e5463

Please sign in to comment.