@@ -43,28 +43,63 @@ 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
4952 - git pull origin main
53+ - git fetch --tags
5054
5155 # Run checks
5256 - task : check
5357
54- # Get the next version
55- - echo "Next version will be $(svu next )"
56- - echo "Press Ctrl+C to cancel or wait 5 seconds to continue... "
57- - sleep 5
58+ # Show current version and commits since last release
59+ - echo "Current version is $(svu current )"
60+ - echo "Commits since last release: "
61+ - git log $(svu current)..HEAD --oneline
5862
59- # Create and push the tag
63+ # Get and validate the version, create and push tag
6064 - |
61- version=$(svu next)
62- git tag -a $version -m "Release $version"
63- git push origin $version
65+ # Set version
66+ if [ -n "{{.VERSION}}" ]; then
67+ version="{{.VERSION}}"
68+ # Validate version format (vX.Y.Z where X,Y,Z are numbers)
69+ if ! echo "$version" | grep -qE "^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$"; then
70+ echo "Error: Version must be in format vX.Y.Z where X,Y,Z are numbers (e.g. v1.2.3)"
71+ exit 1
72+ fi
73+ echo "Using specified version: $version"
74+ else
75+ version=$(svu next)
76+ echo "Next version will be $version"
77+ fi
6478
65- # Instructions for monitoring
66- - echo "Release process started!"
67- - echo "Monitor the release at https://github.com/scalvert/glean-cli/actions"
79+ # Confirm before proceeding
80+ echo "Press Ctrl+C to cancel or wait 5 seconds to continue..."
81+ sleep 5
82+
83+ # Handle existing tag if force is true
84+ if [ "{{.FORCE}}" = "true" ]; then
85+ if git rev-parse "$version" >/dev/null 2>&1; then
86+ echo "Force flag set. Removing existing tag $version"
87+ git tag -d "$version"
88+ git push origin ":refs/tags/$version"
89+ fi
90+ fi
91+
92+ # Create and push the tag
93+ if [ "{{.FORCE}}" = "true" ]; then
94+ git tag -f -a "$version" -m "Release $version"
95+ else
96+ git tag -a "$version" -m "Release $version"
97+ fi
98+ git push origin "$version" --force
99+
100+ # Instructions for monitoring
101+ echo "Release process started!"
102+ echo "Monitor the release at https://github.com/scalvert/glean-cli/actions"
68103 preconditions :
69104 - sh : " git diff-index --quiet HEAD"
70105 msg : " Working directory is not clean. Please commit or stash changes first."
0 commit comments