Browse Source

Release rc (#2784)

* Adiciona possibilidade de release candidate

* WIP
pull/2793/head
Edward 6 years ago
committed by GitHub
parent
commit
6f3a31bc59
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 100
      release.sh

100
release.sh

@ -1,51 +1,111 @@
#/bin/bash #/bin/bash
VERSION=`git describe --tags --abbrev=0` ##
LAST_DIGIT=`echo $VERSION | cut -f 3 -d '.'` ## Versioning info: [major].[minor].[patch][-RC[num]], example: 3.1.159, 3.1.159-RC1
MAIN_REV=`echo $VERSION | cut -f 1,2 -d '.'` ##
# TODO: verificar porque só pega versões superiores (3.1.200 ao invés de 3.1.200-RC9)
# VERSION=`git describe --tags --abbrev=0`
VERSION_PATTERN='([0-9]+)\.([0-9]+)\.([0-9]+)(-RC[0-9]+)?'
SED_AWKWARD_PATTERN="[0-9]+\.[0-9]+\.[0-9]+(-RC[0-9]+){0,1}"
LATEST_VERSION=$(git tag | egrep $VERSION_PATTERN | sort --version-sort | tail -1)
MAJOR_VERSION=$(echo $LATEST_VERSION | cut -d"-" -f1)
IS_RC=$(echo $LATEST_VERSION | egrep '(-RC)')
MAJOR_TAG_CREATED=$(git tag | egrep $MAJOR_VERSION"$")
if [ -n "$MAJOR_TAG_CREATED" ]; then
LATEST_VERSION=$MAJOR_VERSION
fi
LAST_DIGIT=`echo $MAJOR_VERSION | cut -f 3 -d '.'`
MAIN_REV=`echo $MAJOR_VERSION | cut -f 1,2 -d '.'`
NEXT_NUMBER=$(($LAST_DIGIT + 1)) NEXT_NUMBER=$(($LAST_DIGIT + 1))
NEXT_VERSION=$MAIN_REV'.'$NEXT_NUMBER NEXT_VERSION=$MAIN_REV'.'$NEXT_NUMBER
FINAL_VERSION=
function bump_version { function change_files {
sed -e s/$VERSION/$NEXT_VERSION/g docker-compose.yml > tmp1
echo "Atualizando de "$LATEST_VERSION" para "$FINAL_VERSION
sed -E s/$LATEST_VERSION/$FINAL_VERSION/g docker-compose.yml > tmp1
mv tmp1 docker-compose.yml mv tmp1 docker-compose.yml
sed -e s/$VERSION/$NEXT_VERSION/g setup.py > tmp2 sed -E s/$LATEST_VERSION/$FINAL_VERSION/g setup.py > tmp2
mv tmp2 setup.py mv tmp2 setup.py
sed -e s/$VERSION/$NEXT_VERSION/g sapl/templates/base.html > tmp3 sed -E s/$LATEST_VERSION/$FINAL_VERSION/g sapl/templates/base.html > tmp3
mv tmp3 sapl/templates/base.html mv tmp3 sapl/templates/base.html
sed -e s/$VERSION/$NEXT_VERSION/g sapl/settings.py > tmp4 sed -E s/$LATEST_VERSION/$FINAL_VERSION/g sapl/settings.py > tmp4
mv tmp4 sapl/settings.py mv tmp4 sapl/settings.py
} }
function set_major_version {
if [ -z "$IS_RC" ] || [ -n "$MAJOR_TAG_CREATED" ]; then
FINAL_VERSION=$NEXT_VERSION
else
FINAL_VERSION=$MAJOR_VERSION
fi
}
function set_rc_version {
if [ -z "$IS_RC" ]; then
NEXT_RC_VERSION=$NEXT_VERSION"-RC0"
else
LAST_RC_DIGIT=$(echo $LATEST_VERSION | rev | cut -d"-" -f1 | rev | sed s/RC//)
NEXT_RC_NUMBER=$(($LAST_RC_DIGIT + 1))
NEXT_RC_VERSION=$(echo $LATEST_VERSION | cut -d"-" -f1)'-RC'$NEXT_RC_NUMBER
fi
FINAL_VERSION=$NEXT_RC_VERSION
}
function commit_and_push { function commit_and_push {
echo "committing..." echo "committing..."
git add docker-compose.yml setup.py sapl/settings.py sapl/templates/base.html git add docker-compose.yml setup.py sapl/settings.py sapl/templates/base.html
git commit -m "Release: $NEXT_VERSION" git commit -m "Release: $NEXT_VERSION"
git tag $NEXT_VERSION git tag $FINAL_VERSION
echo "sending to github..." echo "sending to github..."
git push origin $NEXT_VERSION
git push origin git push origin
git push origin $FINAL_VERSION
echo "done." echo "done."
} }
case "$1" in case "$1" in
--dry-run) --latest)
echo "Dry run" echo $LATEST_VERSION
bump_version exit 0
echo "done." ;;
echo "Run git checkout -- docker-compose.yml setup.py to undo the files" --major)
set_major_version
echo "generating major release: "$FINAL_VERSION
git tag $FINAL_VERSION
change_files
# commit_and_push
exit 0
;;
--rc)
set_rc_version
echo "generating release candidate: "$FINAL_VERSION
git tag $FINAL_VERSION
change_files
# commit_and_push
exit 0
;;
--undo)
git tag -d $LATEST_VERSION
exit 0 exit 0
;; ;;
--publish) --top)
echo "generating release" git tag | sort --version-sort | tail "-$2"
bump_version exit 0
commit_and_push ;;
esac esac

Loading…
Cancel
Save