1 Star 0 Fork 0

戴明明 / orchestrator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
bump_release_version_and_tag 1.74 KB
一键复制 编辑 原始数据 按行查看 历史
Shlomi Noach 提交于 2017-03-06 14:05 . renamed variable
#!/bin/sh
#
# Simple script to update the release version and tag according to that value.
# - release version now stored in RELEASE_VERSION e.g. 1.4.571
# - the tag usually is of the form v1.4.571.
#
# If there's a difference between current code and there are no pending changes
# then:
# - the current version will be increased by one
# - the RELEASE_VERSION updated accordingly
# - a new tag will be created
# - the tag will be pushed to origin (may need fixing)
# Which remote to push the changes to (default origin)
remote=${1:-origin}
diff=$(git diff)
rc=$?
if [ $rc != 0 ]; then
echo "git diff failed. Doing nothing"
exit 0
fi
if [ -n "$diff" ]; then
echo "Some pending changes need committing. Doing nothing"
exit 0
fi
old_version=$(cat RELEASE_VERSION)
old_tag=v$old_version
diff=$(git diff $old_tag)
rc=$?
if [ $rc = 128 ]; then
echo "git diff $old_tag failed. Revision unknown. Doing nothing"
exit 0
fi
if [ $rc != 0 ]; then
echo "git diff $old_tag failed. Doing nothing"
exit 0
fi
if [ -z "$diff" ]; then
echo "No differences against $old_version. Doing nothing"
exit 0
fi
echo "We need to bump the version"
echo "OLD: version: $old_version, tag: $old_tag"
# now generate a new version.
last_digit=$(echo "$old_version" | sed -e 's/.*\.//')
new_digit=$(($last_digit + 1))
new_version=$(echo "$old_version" | sed -e "s/\.[0-9]*$/.$new_digit/")
new_tag=v$new_version
echo "NEW: version: $new_version, tag: $new_tag"
echo "Modifying RELEASE_VERSION..."
echo "$new_version" > RELEASE_VERSION
echo "Committing change to RELEASE_VERSION..."
git add RELEASE_VERSION
git commit -m"bump RELEASE_VERSION from $old_version to $new_version"
echo "Adding new tag: $new_tag"
git tag $new_tag
echo "Pushing changes and new tag..."
git push
git push "$remote" $new_tag
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cndba/orchestrator.git
git@gitee.com:cndba/orchestrator.git
cndba
orchestrator
orchestrator
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891