Skip to content

release: Switch branch to stable branch from script #980

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

Merged
merged 3 commits into from
Jun 26, 2025

Conversation

ivanvc
Copy link
Member

@ivanvc ivanvc commented Jun 10, 2025

Follow up from #903 (comment)

Switch branches to avoid backporting and maintaining the release script in each of the stable release branches.

/cc @ahrtr @Elbehery

@Elbehery
Copy link
Member

@ivanvc nice work 👍🏽

Could we test it, and paste the test output here 🤔

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

I think we also need to check whether the working directory is clean, error out if not.

Comment on lines 42 to 47
# Checkout release branch and ensure to return to the current reference after
# the release finishes.
PREVIOUS_REF=$(git rev-parse HEAD)
if git symbolic-ref HEAD &>/dev/null; then
PREVIOUS_REF=$(git symbolic-ref HEAD | rev | cut -d/ -f1 | rev)
fi
Copy link
Member

Choose a reason for hiding this comment

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

suggest to keep it as simple as possible

Suggested change
# Checkout release branch and ensure to return to the current reference after
# the release finishes.
PREVIOUS_REF=$(git rev-parse HEAD)
if git symbolic-ref HEAD &>/dev/null; then
PREVIOUS_REF=$(git symbolic-ref HEAD | rev | cut -d/ -f1 | rev)
fi

Comment on lines 52 to 53
# shellcheck disable=SC2064 # Intentionally expanding PREVIOUS_REF now.
trap "git checkout ${PREVIOUS_REF}" EXIT
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Suggested change
# shellcheck disable=SC2064 # Intentionally expanding PREVIOUS_REF now.
trap "git checkout ${PREVIOUS_REF}" EXIT

@ahrtr
Copy link
Member

ahrtr commented Jun 11, 2025

Based on the current implementation, you can release bbolt on any forked repo. Suggest to follow the same approach as etcd.

  • fork the main repo git@github.com:etcd-io/bbolt.git
  • cd ${reldir}/etcd
  • git checkout ${TARGET_BRANCH}
  • ......

https://github.com/etcd-io/etcd/blob/8142396ae8501d0f7ca896f3eb91ae99b54ca9b7/scripts/release.sh#L91-L100

@ahrtr
Copy link
Member

ahrtr commented Jun 11, 2025

Another related comment on checking whether tag exists or not (see below), I think it should be a little better to follow the same approach/command as etcd to ensure exact match. Otherwise it will run into the corner case when releasing the very first minor version. For example, when releasing v1.5.0, the v1.5.0-alpha.0 might have already exist, then current script will think the tag v1.5.0 already exist

bbolt/scripts/release.sh

Lines 36 to 40 in a129a9e

remote_tag_exists=$(git ls-remote --tags "${REPOSITORY}" | grep -c "${INPUT}" || true)
if [ "${remote_tag_exists}" -gt 0 ]; then
echo "Release version tag exists on remote."
exit 1
fi

etcd:
https://github.com/etcd-io/etcd/blob/8142396ae8501d0f7ca896f3eb91ae99b54ca9b7/scripts/release.sh#L108

@ivanvc ivanvc mentioned this pull request Jun 19, 2025
ivanvc added 3 commits June 25, 2025 11:33
Create a stage directory in the temp file system, and clone the
repository there.

Signed-off-by: Ivan Valdes <ivan@vald.es>
Make it consistent with other of our release scripts.

Signed-off-by: Ivan Valdes <ivan@vald.es>
Check for the actual tag by an explicit query, rather than listing all
tags available at the repository.

Signed-off-by: Ivan Valdes <ivan@vald.es>
@ivanvc ivanvc force-pushed the release-checkout-branch branch from ff867b4 to a5955bd Compare June 25, 2025 19:26
@ivanvc ivanvc requested a review from ahrtr June 25, 2025 19:26
@ivanvc
Copy link
Member Author

ivanvc commented Jun 25, 2025

I applied the suggestions. Therefore, this pull request grew in size, as it needed some refactoring.

I verified running the script by pointing to my fork. i.e.,

REPOSITORY=git@github.com:ivanvc/bbolt.git ./scripts/release.sh v1.4.3

Note that this is a fictional 1.4.3 version, that branch is not up to date with the upstream.

Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

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

LGTM & thx

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahrtr, ivanvc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ahrtr ahrtr merged commit 81355b4 into etcd-io:main Jun 26, 2025
44 checks passed
@ivanvc ivanvc deleted the release-checkout-branch branch June 26, 2025 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants