Skip to content

Commit bbf6601

Browse files
committed
Adding VERSION and FORCE options to task release to have better control over release number
1 parent 027d4c0 commit bbf6601

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

taskfile.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ tasks:
4343

4444
release:
4545
desc: Create and push a new release
46+
vars:
47+
VERSION: '{{.VERSION | default ""}}'
48+
FORCE: '{{.FORCE | default "false"}}'
4649
cmds:
4750
# Ensure we're on main and up to date
4851
- git checkout main
@@ -57,14 +60,35 @@ tasks:
5760
- echo "Commits since last release:"
5861
- git log $(svu current)..HEAD --oneline
5962

60-
# Get the next version
61-
- echo "Next version will be $(svu next)"
63+
# Get and validate the version
64+
- |
65+
if [ -n "{{.VERSION}}" ]; then
66+
version="{{.VERSION}}"
67+
# Validate version format (vX.Y.Z where X,Y,Z are numbers)
68+
if ! echo "$version" | grep -qE "^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$"; then
69+
echo "Error: Version must be in format vX.Y.Z where X,Y,Z are numbers (e.g. v1.2.3)"
70+
exit 1
71+
fi
72+
echo "Using specified version: $version"
73+
else
74+
version=$(svu next)
75+
echo "Next version will be $version"
76+
fi
77+
78+
# Confirm before proceeding
6279
- echo "Press Ctrl+C to cancel or wait 5 seconds to continue..."
6380
- sleep 5
6481

82+
# Handle existing tag if force is true
83+
- |
84+
if [ "{{.FORCE}}" = "true" ] && git tag -l "$version" | grep -q .; then
85+
echo "Force flag set. Removing existing tag $version"
86+
git tag -d $version
87+
git push origin :refs/tags/$version
88+
fi
89+
6590
# Create and push the tag
6691
- |
67-
version=$(svu next)
6892
git tag -a $version -m "Release $version"
6993
git push origin $version
7094

0 commit comments

Comments
 (0)