#!/bin/bash

get_version_release_candidate

call_extension "before_release"

echo -e "[CI] Iniciando processo de GitFlow\n"

echo "[CI] Criando branch hotfix/$VERSION_HYPHEN"
git checkout -B hotfix/$VERSION_HYPHEN

call_extension "before_change_changelog"

commit_changelog_template $VERSION

call_extension "after_change_changelog"

change_version

git commit -a -m "[CI] Criando versão $VERSION"

CI_REPOSITORY_URL_FOR_PUSH=$(echo "$CI_REPOSITORY_URL" | sed -e "s|.*@\(.*\)|git@\1|" -e "s|/|:|" )
git remote set-url --push origin "$CI_REPOSITORY_URL_FOR_PUSH"

echo "[CI] Enviando branch de hotfix"
git push origin hotfix/$VERSION_HYPHEN

exit
