You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lal/gen_tag.sh

44 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# 根据CHANGELOG.md中的最新版本号决定是否更新version.go和以及打git tag
#
# 步骤:
# 1. 提交所有代码
# 2. 修改CHANGELOG.md
# 3. 执行gen_tag.sh
#set -x
# CHANGELOG.md中的版本号
NewVersion=`cat CHANGELOG.md| grep '#### v' | head -n 1 | awk '{print $2}'`
echo 'newest version in CHANGELOG.md: ' $NewVersion
# git tag中的版本号
GitTag=`git tag --sort=version:refname | tail -n 1`
echo "newest version in git tag: " $GitTag
# 源码中的版本号
FileVersion=`cat pkg/base/version.go | grep 'const LALVersion' | awk -F\" '{print $2}'`
echo "newest version in version.go: " $FileVersion
# CHANGELOG.md和源码中的不一致更新源码并提交修改
if [ "$NewVersion" == "$FileVersion" ];then
echo 'same tag, noop.'
else
echo 'update version.go'
gsed -i "/^const LALVersion/cconst LALVersion = \"${NewVersion}\"" pkg/base/version.go
git add .
git commit -m "${NewVersion} -> version.go"
git push
fi
# CHANGELOG.md和git tag不一致打新的tag
if [ "$NewVersion" == "$FileVersion" ];then
echo 'same tag, noop.'
else
echo 'add tag.' ${NewVersion}
git tag ${NewVersion}
git push --tags
fi