Git 自动化TAG标签脚本

10 min read
#!/bin/bash

# 获取最新的tag
latest_tag=$(git tag -l | sort -V | tail -n1)
major=$(echo $latest_tag | cut -d '.' -f 1)
minor=$(echo $latest_tag | cut -d '.' -f 2)
patch=$(echo $latest_tag | cut -d '.' -f 3)
new_patch=$((patch + 1))
new_tag="${major}.${minor}.${new_patch}"
echo "New tag: $new_tag"
git tag $new_tag
git push origin $new_tag
echo "Tag $new_tag has been created and pushed to remote."