Skip to content

Instantly share code, notes, and snippets.

@sizer
Created February 28, 2019 05:53
Show Gist options
  • Save sizer/2b37becc1b2d83f464b1842be775b187 to your computer and use it in GitHub Desktop.
Save sizer/2b37becc1b2d83f464b1842be775b187 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo 'push_release_branch start...'
CURRENT_VERSION=""
NEXT_VERSION=""
function notifySlack () {
# ignore "bash: !: event not found"
# see https://qiita.com/anqooqie/items/785f46a8cc5f10ba7abb
set +H
curl -s -S -X POST --data-urlencode "payload={'channel': '#circleci', 'username': 'CircleCI', 'text': '<!here> 今日はリリース日です。リリースブランチを作成します。' }" $SLACK_TEST_HOOK
set -H
}
function checkoutSemver () {
[ ! -d .circleci/semver ] && `git clone git@github.com:fmahnke/shell-semver.git .circleci/semver`
}
function nextVersion () {
CURRENT_VERSION=`git tag --sort=-taggerdate | sed -n 1P`
NEXT_VERSION=`./.circleci/semver/increment_version.sh -m ${CURRENT_VERSION}`
}
function pushBranch () {
`git checkout -b test/${NEXT_VERSION} && git push origin test/${NEXT_VERSION}`
}
if [ "$(date '+%w')" = 3 ]; then
echo '今日はリリース日です'
notifySlack
checkoutSemver
nextVersion
echo "現在の最新バージョンは${CURRENT_VERSION}です。"
echo "次のバージョンは${NEXT_VERSION}です。"
pushBranch
echo "ブランチをプッシュしました。"
else
echo '今日はリリース日ではありません'
fi
echo 'push_release_branch finished!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment