Skip to content

Commit

Permalink
chore: Add script for valid semver tag parsing (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrongmeal authored Jan 11, 2025
1 parent a0413fe commit f71ee13
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,20 @@ tasks:
release:prepare:
requires:
vars: [VERSION]
vars:
SEMVER:
sh: ./scripts/semver.sh {{.VERSION}}
cmds:
- git cliff --unreleased --tag v{{.VERSION}} --prepend CHANGELOG.md
- git cliff --unreleased --tag {{.SEMVER}} --prepend CHANGELOG.md

release:tag:
requires:
vars: [VERSION]
vars:
SEMVER:
sh: ./scripts/semver.sh {{.VERSION}}
cmds:
- git switch main
- git pull origin main
- git tag v{{.VERSION}}
- echo "Push the tag 'v{{.VERSION}}' to release"
- git tag {{.SEMVER}}
- echo "Push the tag '{{.SEMVER}}' to release"
14 changes: 14 additions & 0 deletions scripts/semver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

VERSION="$1"

# Check if the version is a valid semver
if echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
# Add the "v" prefix if it doesn't already exist
VERSION="v$VERSION"
elif ! echo "$VERSION" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Error: '$VERSION' is not a valid semver string." >&2
exit 1
fi

echo "$VERSION"

0 comments on commit f71ee13

Please sign in to comment.