Newer
Older
web-services / bin / version-minor.sh
@François Parmentier François Parmentier on 8 Feb 890 bytes fix: Commit swagger.json before tagging
#!/usr/bin/env bash

NAME_PACKAGE=$(basename "$1")
LAST_VERSION=$(git tag | sort -n | grep "$NAME_PACKAGE" | tail -1)
MAJOR_VERSION=$(echo "$LAST_VERSION" | cut -d@ -f2 | cut -d\. -f1)
MINOR_VERSION=$(echo "$LAST_VERSION" | cut -d\. -f2)
((NEW_MINOR_VERSION=${MINOR_VERSION:=-1}+1))
NEW_VERSION="${NAME_PACKAGE}@${MAJOR_VERSION:=0}.${NEW_MINOR_VERSION}.0"

if [ -e "$1/swagger.json" ]; then
    NUMBERED_LAST_VERSION=${LAST_VERSION//$NAME_PACKAGE@/}
    NUMBERED_NEW_VERSION=${NEW_VERSION//$NAME_PACKAGE@/}
    sed -i "s/${NUMBERED_LAST_VERSION}/${NUMBERED_NEW_VERSION}/" "$1/swagger.json"
    git add "$1/swagger.json"
    git commit -m "$NEW_VERSION"
    git push
fi

git tag "${NEW_VERSION}" -m "${NEW_VERSION}"
git push --tags
echo "Nouvelle version créée: ${NEW_VERSION}"
echo "URL à utiliser: https://gitbucket.inist.fr/tdm/web-services/archive/${NAME_PACKAGE}/${NEW_VERSION}.zip"