Skip to content

Commit

Permalink
Check that v<major>.<minor>.0 is on latest
Browse files Browse the repository at this point in the history
- Check that v<major>.<minor>.0 is on latest before creating
  v<major>.<minor>-dev branch from it.
- Suppress Git output when checking out tag by explicitly specifying
  --detach and print an explicit message saying that the branch is being
  created.
  • Loading branch information
adriansuarez committed Sep 4, 2023
1 parent 42d8b0f commit c1de519
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions scripts/update-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cd "$(dirname "$0")/.."

# Make sure there are no uncommitted changes
GIT_STATUS="$(git status --porcelain)"
[ "$GIT_STATUS" = "" ] || fail "Cannot publish release with uncommitted changes:\n$GIT_STATUS"
[ "$GIT_STATUS" = "" ] || fail "ERROR: Cannot publish release with uncommitted changes:\n$GIT_STATUS"

# Save current branch or commit
ORIG_REF="$(git rev-parse --abbrev-ref HEAD)"
Expand All @@ -33,10 +33,19 @@ case "$TAG" in
# Branch v<major>.<minor>-dev tracks patch releases
PREFIX="${TAG%.*}"
BRANCH="${PREFIX}-dev"
if ! git checkout "$BRANCH"; then
# Branch does not exist. Create it off of <major>.<minor>.0.
git checkout "${PREFIX}.0"
if ! git checkout "$BRANCH" 2>/dev/null; then
BRANCH_FROM="${PREFIX}.0"
echo "Branch $BRANCH does not exist. Creating it off of tag $BRANCH_FROM..."
# Make sure <major>.<minor>.0 tag is on branch latest
if [ "$(git rev-parse "$BRANCH_FROM")" != "$(git merge-base latest "$BRANCH_FROM")" ]; then
fail "ERROR: Tag $BRANCH_FROM is not on branch latest"
fi

# Checkout tag <major>.<minor>.0 and create branch
# v<major>.<minor>-dev off of it
git checkout --detach "$BRANCH_FROM"
git checkout -b "$BRANCH"
# Push branch unless DRY_RUN=true
if [ "$DRY_RUN" != true ]; then
git push --set-upstream origin "$BRANCH"
fi
Expand Down

0 comments on commit c1de519

Please sign in to comment.