Commit 329c5c04 authored by Benjamin Murauer's avatar Benjamin Murauer
Browse files

added script for publishing

parent c6cdb238
Pipeline #42196 passed with stage
in 1 minute and 51 seconds
#!/bin/bash
BRANCH=$(git branch --show-current)
if [ "${BRANCH}" != "master" ]; then
echo "publishing can only be done on the master branch."
exit 1
fi
DIFFS_STRING=$(git rev-list --left-right --count master...origin/master)
DIFFS=($DIFFS_STRING)
LOCAL=${DIFFS[0]} # how many commits local is ahead of origin
REMOTE=${DIFFS[1]} # how many commits origin is ahead of local
# if the master branch on origin is ahead, probably forgot to pull
if [ "${REMOTE}" != 0 ]; then
echo "master branch is ${REMOTE} commits ahead. Pull/merge first."
exit 1
fi
# make sure all tags are available locally
git fetch --tags
LAST_TAG=$(git describe --tags --abbrev=0)
LAST_LOGS=$(git log --color --pretty=oneline HEAD..."${LAST_TAG}")
LAST_LOG_LINES=$(echo "${LAST_LOGS}" | wc -l)
# count the lines of commits between HEAD and the last named tag
if [ "${LAST_LOG_LINES}" == 0 ]; then
echo "No commits have been detected since the last tag ${LAST_TAG}."
exit 1
fi
echo "commits since last tag:"
echo "-----------------------"
echo "${LAST_LOGS}"
VERSION_LEVEL=$1
if [ "${VERSION_LEVEL}" != "patch" ] && [ "${VERSION_LEVEL}" != "minor" ]; then
echo "Usage: ./publish.sh <patch|minor>"
exit 1
fi
bumpversion "${VERSION_LEVEL}" || exit 1
VERSION=$(python -m setup --version)
echo "new version is: ${VERSION}"
git add setup.cfg setup.py
git commit -m "release v${VERSION}"
git tag "v${VERSION}"
git push origin "v${VERSION}"
make release
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment