-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
404fa2e
commit bc47a0a
Showing
1 changed file
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,14 +21,39 @@ jobs: | |
git config --global user.name 'GitHub Actions' | ||
git config --global user.email '[email protected]' | ||
- name: Determine tag version | ||
id: get_tag | ||
- name: Fetch all tags | ||
run: | | ||
git fetch --tags | ||
- name: Get latest tag | ||
id: get_latest_tag | ||
run: | | ||
echo "TAG_NAME=v1.0.$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV | ||
# Get the latest tag | ||
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | ||
echo "Latest tag: $latest_tag" | ||
echo "latest_tag=$latest_tag" >> $GITHUB_ENV | ||
- name: Create and push tag | ||
- name: Determine next tag version | ||
id: get_next_version | ||
run: | | ||
latest_tag=$env.latest_tag | ||
if [[ $latest_tag =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | ||
major=${BASH_REMATCH[1]} | ||
minor=${BASH_REMATCH[2]} | ||
patch=${BASH_REMATCH[3]} | ||
next_patch=$((patch + 1)) | ||
next_tag="v${major}.${minor}.${next_patch}" | ||
echo "Next tag version: $next_tag" | ||
echo "next_tag=$next_tag" >> $GITHUB_ENV | ||
else | ||
# Default to v0.0.1 if no valid tag found | ||
echo "No valid tag found, starting with v0.0.1" | ||
echo "next_tag=v0.0.1" >> $GITHUB_ENV | ||
fi | ||
- name: Create and push new tag | ||
env: | ||
TAG_NAME: ${{ env.TAG_NAME }} | ||
TAG_NAME: ${{ env.next_tag }} | ||
run: | | ||
git tag $TAG_NAME | ||
git push origin $TAG_NAME |