Last active
March 19, 2021 15:07
-
-
Save stephanebruckert/34de35069c59af7a1f5fc7c52609ce2e to your computer and use it in GitHub Desktop.
Automatically force-tag v1 and v1.0 when creating v1.0.0 (as done in the docker registry)
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
#!/bin/bash | |
echo "Make sure: | |
- you understand the content of this script before running it. | |
It can be dangerous as it aims to simplify overriding major and minor versions for the latest tag. | |
- you are currently on the commit you want to tag, so don't forget to pull. | |
" | |
read -p "SemVer version: " version | |
for run in {1..3}; # once for each of patch, minor and major | |
do | |
read -r -p "Going to create $version, are you sure? [Y/n]" response | |
if [[ $response =~ ^(yes|y|Y ) ]] || [[ -z $response ]]; then | |
if [ "$run" -eq "1" ]; then | |
force="" | |
else | |
# only force minor and major | |
force="-f" | |
fi | |
git tag $version $force | |
echo "Created $version" | |
else | |
echo "Cancelled creating $version" | |
exit | |
fi | |
version=${version%.*} | |
done | |
read -r -p "Going to force push all branches and tags, are you sure? [Y/n]" response | |
if [[ $response =~ ^(yes|y|Y ) ]] || [[ -z $response ]]; then | |
git push | |
git push --tags -f | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment