Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make previous version optional in release_pull_request.bash #1013

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions source-repo-scripts/release_pull_request.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,33 @@
# limitations under the License.
#

# The script will open a pull request for a forward port.
# The script will open a pull request a release PR (actually opens the PR page in your web browser)
j-rivero marked this conversation as resolved.
Show resolved Hide resolved
#
# Requires the 'gh' CLI to be installed.
#
# Usage:
# $ ./merge_forward_pull_request.bash <from_branch> <to_branch>
# $ ./release_pull_request.bash <from_branch> <to_branch>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# $ ./release_pull_request.bash <from_branch> <to_branch>
# $ ./release_pull_request.bash <new_version> <to_branch>

Not fully convinced that the name to_branch is the best one to use here. Maybe base_branch? Feel free to ignore.

#
# For example, to merge `ign-rendering6` forward to `main`:
# For example, to release `gz-rendering7` 7.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# For example, to release `gz-rendering7` 7.1.0
# For example, to release 7.1.0 using the `gz-rendering7` branch

I'm trying to match order and concepts defined in the help usage.

#
# ./merge_forward_pull_request.bash ign-rendering6 main
# ./release_pull_request.bash 7.1.0 gz-rendering7
#
# Make sure you've checked out the branch that has the changes for the release
# and that the changes have been pushed.

VERSION=${1}
TO_BRANCH=${2}
PREV_VER=${3}

if [[ $# -ne 3 ]]; then
echo "./release_pull_request.bash <version> <to_branch> <previous_version>"
if [[ $# -ne 2 ]]; then
echo "./release_pull_request.bash <version> <to_branch>"
exit 1
fi

set -e

git fetch --tags
PREV_VER=$(git describe --tags --abbrev=0 | sed 's/.*_//')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tempted to try to use the TO_BRANCH variable here to try to make sure we identify a tag that matches the major version of our target branch, though it may not be necessary. Feel free to ignore this suggestion.

Suggested change
PREV_VER=$(git describe --tags --abbrev=0 | sed 's/.*_//')
PREV_VER=$(git describe --tags --match ${TO_BRANCH}* --abbrev=0 | sed 's/.*_//')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


LOCAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)
REMOTE_BRANCH=$(git rev-parse --abbrev-ref HEAD@{upstream})
REMOTE=${REMOTE_BRANCH/\/$LOCAL_BRANCH/}
Expand All @@ -44,7 +49,10 @@ CURRENT_BRANCH="${REMOTE}:${LOCAL_BRANCH}"
ORIGIN_URL=$(git remote get-url origin)
ORIGIN_ORG_REPO=$(echo ${ORIGIN_URL} | sed -e 's@.*github\.com.@@' | sed -e 's/\.git//g')

PREV_TAG=$(git tag | grep "_${PREV_VER}$")
if [[ $PREV_VER == $VERSION ]] then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if [[ $PREV_VER == $VERSION ]] then
if [[ "$PREV_VER" == "$VERSION" ]]; then

Beware, this has a broken syntax

echo "Previous version ($PREV_VER) and current ($VERSION) version should be different"
exit 1
fi

TITLE="Prepare for ${VERSION} Release"

Expand Down