Skip to content

Commit

Permalink
fix(AICORE-462): release version replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarsique committed Mar 24, 2021
1 parent 554a7f1 commit 8d3f3e2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
16 changes: 10 additions & 6 deletions tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ INCREMENT=${INCREMENT:-patch}
NEXT_VERSION=$(semver bump "$INCREMENT" "$RELEASE_VERSION")

printf "Releasing %s\n\tVersion:\t%s\n\tNext version:\t%s\n" "$(git remote get-url origin)" "$RELEASE_VERSION" "$NEXT_VERSION"
echo "RELEASE_VERSION=$RELEASE_VERSION" > release.properties
echo "INCREMENT=$INCREMENT" >> release.properties
echo "NEXT_VERSION=$NEXT_VERSION" >> release.properties

rm -f release.properties
{
echo "RELEASE_VERSION=$RELEASE_VERSION"
echo "INCREMENT=$INCREMENT"
echo "NEXT_VERSION=$NEXT_VERSION"
} >> release.properties
mvn -V -B versions:set versions:set-property -DnewVersion="$RELEASE_VERSION" -Dproperty=nuxeo.ai.version -DgenerateBackupPoms=false
sed "s,\(<version>\)\(.*\)\(<\/version>\),\1$RELEASE_VERSION\3," nuxeo-ai-internal/pom.xml
sed -i "s,\(<version>\)\(.*\)\(<\/version>\),\1$RELEASE_VERSION\3," nuxeo-ai-internal/pom.xml
sed -i "s,version: .*,version: $RELEASE_VERSION," charts/*/Chart.yaml
git add -u
if [ "$DRY_RUN" = 'true' ]; then
echo "Dry run: skip 'jx step next-version' and 'jx step changelog'"
Expand All @@ -52,7 +55,8 @@ fi
git reset --hard "origin/$BRANCH"

mvn -B versions:set versions:set-property -DnewVersion="${NEXT_VERSION}-SNAPSHOT" -Dproperty=nuxeo.ai.version -DgenerateBackupPoms=false
sed "s,\(<version>\)\(.*\)\(<\/version>\),\1$NEXT_VERSION\3," nuxeo-ai-internal/pom.xml
sed -i "s,\(<version>\)\(.*\)\(<\/version>\),\1$NEXT_VERSION\3," nuxeo-ai-internal/pom.xml
sed -i "s,version: .*,version: ${NEXT_VERSION}-SNAPSHOT," charts/*/Chart.yaml
git add -u
jx step next-version --version="$NEXT_VERSION"
git commit -a -m"Post release ${RELEASE_VERSION}. Set version ${NEXT_VERSION}."
Expand Down
43 changes: 20 additions & 23 deletions tools/sprint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ CONFIG_FILE=$GIT_TOP_LVL/.git/SPRINT
# *) echo "Unknown parameter passed: $1"; exit 1 ;;
#esac


hub sync || git fetch origin

if [[ -f $CONFIG_FILE ]]; then
# shellcheck source=.git/SPRINT
source "$CONFIG_FILE"
else
PS3="Pick a number: "
mapfile -t options < <(git branch -r --list "origin/sprint*" |cut -f 2- -d /)
mapfile -t options < <(git branch -r --list "origin/sprint*" | cut -f 2- -d /)
echo "Sprint to merge?"
select oldSprint in "${options[@]}"; do
if [[ -z $oldSprint ]]; then
Expand All @@ -55,7 +54,7 @@ else
break
done
echo
mapfile -t options < <(git branch -r --list "origin/master*" |cut -f 2- -d /)
mapfile -t options < <(git branch -r --list "origin/master*" | cut -f 2- -d /)
echo "Base branch?"
select base in "${options[@]}"; do
if [[ -z $oldSprint ]]; then
Expand All @@ -67,7 +66,7 @@ else
echo
read -rp "New sprint name? " newSprint

cat > "$(git rev-parse --show-toplevel)/.git/SPRINT" <<EOF
cat >"$(git rev-parse --show-toplevel)/.git/SPRINT" <<EOF
oldSprint=$oldSprint
newSprint=$newSprint
base=$base
Expand All @@ -78,31 +77,30 @@ echo "Old Sprint: $oldSprint"
echo "New Sprint: $newSprint"
echo "Base branch: $base"
read -p "Continue? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
echo

function mergeOldSprint() {
if [[ -n $(git log "$oldSprint".."origin/$base") ]]; then
if [[ -n $(git log "${oldSprint}..origin/${base}") ]]; then
echo "Rebase required"
# oldSprintId=$(git rev-parse --short origin/"$oldSprint")
# oldSprintId=$(git rev-parse --short origin/"$oldSprint")
git checkout "$oldSprint"
git rebase "origin/$base"
git logone ...'@{u}'
git fetch origin
git id "origin/$oldSprint"
git status -sb
echo "Please review the rebase of $oldSprint onto $base, then force push and execute again sprint.sh"
# echo "Please handle the following, then execute again sprint.sh:
#git push -f
#gh pr create -B "$base" -H "$oldSprint" -l "work in progress"
#gh pr checks
#git fetch origin
#git logone "origin/$oldSprint".. # must be empty: no commit on base that is missing on sprint
#gh pr merge -md
#"
# echo "Please handle the following, then execute again sprint.sh:
#git push -f
#gh pr create -B "$base" -H "$oldSprint" -l "work in progress"
#gh pr checks
#git fetch origin
#git logone "origin/$oldSprint".. # must be empty: no commit on base that is missing on sprint
#gh pr merge -md
#"
exit
fi

Expand All @@ -112,8 +110,7 @@ function mergeOldSprint() {
git log --oneline '@{u}'..
echo
read -p "Push $base? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
echo
Expand All @@ -126,15 +123,15 @@ function createNewSprint() {
echo "CREATE $newSprint <- $base"
git checkout -b "$newSprint" "origin/$base" --no-track
currentVersion="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
# nextVersion="${currentVersion/-SNAPSHOT/-$newSprint-SNAPSHOT}"
nextVersion="$(semver bump minor "$currentVersion")-SNAPSHOT"
git grep --name-only "$currentVersion" |xargs sed -i "s,$currentVersion,$nextVersion,g"
git commit -m"set version $nextVersion" -a
mvn -V -B versions:set versions:set-property -DnewVersion="${nextVersion}" -Dproperty=nuxeo.ai.version -DgenerateBackupPoms=false
sed -i "s,\(<version>\)\(.*\)\(<\/version>\),\1${nextVersion}\3," nuxeo-ai-internal/pom.xml
sed -i "s,version: .*,version: ${nextVersion}," charts/*/Chart.yaml
git commit -m"set version ${nextVersion}" -a
git log --oneline "$base"..
echo
read -p "Push new branch $newSprint and delete old $oldSprint? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
echo
Expand Down

0 comments on commit 8d3f3e2

Please sign in to comment.