Skip to content

Commit

Permalink
Merge pull request #651 from ohadmo/omosafi/fix_calendar_versioning
Browse files Browse the repository at this point in the history
Fix calendar versioning
  • Loading branch information
ohadmo authored May 12, 2021
2 parents f90670d + f3a81cc commit a530034
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ci/release/pypi_uploader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ for f in "${WORKSPACE}"/pygenomeworks/genomeworks_wheel/*.whl; do
echo "genomeworks Whl file does not exist"
exit 1
else
conda install -c conda-forge twine
pip install twine
python3 -m pip install 'readme-renderer>=21.0' # to support py3.5 images
# Change .whl package name to support PyPI upload
MODIFIED_WHL_NAME=$(dirname ${f})/$(basename "${f}" | sed -r "s/(.*-.+-.+)-.+-.+.whl/\1-none-any.whl/")
Expand Down
37 changes: 26 additions & 11 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,44 @@

set -e

# Overwrite argument value to always trigger a patch release
RELEASE_TYPE="patch"
# Grab argument for release type
RELEASE_TYPE=$1

# Calender versioning only supports "minor"= a PR crated from clara-parabricks/dev branch
# or "patch"= a PR merged from any other branch
if [ "$RELEASE_TYPE" != "patch" ] && [ "$RELEASE_TYPE" != "minor" ]; then
echo "Incorrect release type; use 'minor', or 'patch' as an argument"
exit 1
fi

# Get current version and calculate next versions
CURRENT_TAG=`git tag | grep -xE "v$(date '+%Y\.%m')\.[0-9]+" | sort --version-sort | tail -n 1 | tr -d 'v'`
CURRENT_TAG=$(git tag | grep -xE "v$(date '+%Y\.%m')\.[0-9]+" | sort --version-sort | tail -n 1 | tr -d 'v')

# In case no tag exists for this month
if [ -z "${CURRENT_TAG}" ]; then
CURRENT_TAG="$(date '+%Y.%m').-1"
if [ "$RELEASE_TYPE" == "minor" ]; then
# In case no tag exists for this month & this is a
# "minor" release (merged from branch clara-parabricks/dev) - create new tag for this month
CURRENT_TAG="$(date '+%Y.%m').-1"
elif [ "$RELEASE_TYPE" == "patch" ]; then
# In case no tag exists for this month & this is a "patch" release
# (merged from some branch that is not clara-parabricks/dev) -
# take latest Tag that was pushed and increase Patch location in 1
CURRENT_TAG=$(git tag | grep -xE "v[0-9]+\.[0-9]+\.[0-9]+" | sort --version-sort | tail -n 1 | tr -d 'v')
fi
fi

CURRENT_MAJOR=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}'`
CURRENT_MINOR=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}'`
CURRENT_PATCH=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}'`
NEXT_PATCH=$((CURRENT_PATCH + 1))
NEXT_FULL_TAG=""
NEXT_SHORT_TAG=""

if [ "$RELEASE_TYPE" == "patch" ]; then
NEXT_FULL_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}.${NEXT_PATCH}"
NEXT_SHORT_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}"
else
echo "Incorrect release type; use 'major', 'minor', or 'patch' as an argument"
exit 1
fi
NEXT_FULL_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}.${NEXT_PATCH}"
NEXT_SHORT_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}"


if [[ "$CURRENT_PATCH" == "-1" ]]; then
echo "Preparing release [$NEXT_FULL_TAG]"
else
Expand Down

0 comments on commit a530034

Please sign in to comment.