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

release: add release script #903

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
61 changes: 61 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

echo "enter release string according to semantic versioning (e.g. v1.2.3)."
read -r INPUT
if [[ ! "${INPUT}" =~ ^v[0-9]+.[0-9]+.[0-9]+ ]]; then
echo "Expected 'version' param of the form 'v<major-version>.<minor-version>.<patch-version>' but got '${INPUT}'"
exit 1
fi

VERSION=${INPUT#v}
RELEASE_VERSION="${VERSION}"
MINOR_VERSION=$(echo "${VERSION}" | cut -d. -f 1-2)

REPOSITORY=${REPOSITORY:-"git@github.com:etcd-io/bbolt.git"}
REMOTE="${REMOTE:-"origin"}"

# ensuring the minor-version is identical.
source_version=$(grep -E "\s+Version\s*=" ./version/version.go | sed -e "s/.*\"\(.*\)\".*/\1/g")
if [[ "${source_version}" != "${RELEASE_VERSION}" ]]; then
source_minor_version=$(echo "${source_version}" | cut -d. -f 1-2)
if [[ "${source_minor_version}" != "${MINOR_VERSION}" ]]; then
echo "Wrong bbolt minor version in version.go. Expected ${MINOR_VERSION} but got ${source_minor_version}. Aborting."
exit 1
fi
fi

# creating a branch to bump 'version.go'.
date_string=$(date +%Y%m%d)
local_branch_name="version_${date_string}"
local_branch_err=$(git checkout -b "${local_branch_name}" | grep -E "error|fatal" || true )
if [[ -n "${local_branch_err}" ]]; then
echo "${local_branch_err}"
fi
Comment on lines +31 to +37
Copy link
Member

@ivanvc ivanvc Feb 14, 2025

Choose a reason for hiding this comment

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

I tested your script locally, and it works. However, I think creating a branch and creating the tag against the commit from that branch is conceptually wrong. I believe the right way would be to push straight to the release-${VERSION_MINOR} branch (which is where the script should have been executed from) so the tag and the commit belong to that branch.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, now I got what u mean

so we execute the script from the local release-${VERSION_MINOR} branch

iiuc, this should pushed to a fork, which then used to create a PR against upstream, or ?


# bump 'version.go'.
echo "Updating version from '${source_version}' to '${RELEASE_VERSION}' in 'version.go'"
sed -i "s/${source_version}/${RELEASE_VERSION}/g" ./version/version.go

# push 'version.go' to remote.
echo "committing 'version.go'"
git add ./version/version.go
git commit -s -m "Update version to ${VERSION}"
git push -u -f "${REMOTE}" "${local_branch_name}"
Copy link
Member

Choose a reason for hiding this comment

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

I suggest removing the force. If we're pushing to the etcd-io remote, it should not be a good idea to force it (it may even be good to fail if it fails to push).

Copy link
Member Author

Choose a reason for hiding this comment

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

so iiuc, this script creates a branch in origin, to be used to create a PR against upstream

I don't think the script should push directly to etcd-io repos, please correct me if I'm wrong

echo "'version.go' has been committed to remote repo."

# create tag and push to remote.
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. Checking out refs/tags/${INPUT}"
git checkout -q "tags/${INPUT}"
elif [ "${remote_tag_exists}" -eq 0 ]; then
echo "Creating new tag for '${INPUT}'"
git tag -f "${INPUT}"
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to GPG sign the tag in this repository, too? I don't think we've been doing it, but it may be easier with the script in place. What do you think, @ahrtr?

Copy link
Member

Choose a reason for hiding this comment

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

Do we want to GPG sign the tag in this repository, too?

I think so. It's exactly what I have been doing (manually).

Copy link
Member Author

Choose a reason for hiding this comment

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

@ahrtr should the script

  • pushes a branch with the changes and new tag to a fork (origin)
  • pushes the changes directly to upstream (etcd-io) release branch (e.g. release-1.4)

Copy link
Member

@ivanvc ivanvc Feb 14, 2025

Choose a reason for hiding this comment

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

I think the latter, else the tag would be in a fork, and we'll need to manually tag the upstream later.

Copy link
Member

Choose a reason for hiding this comment

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

A gentle reminder, @ahrtr. I think we're just waiting for confirmation on this.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we should push the changes to upstream etcd-io/bbolt directly. But please ensure you verify this in your forked repo firstly. I. believe @ivanvc did similar work lots of times.

git push -f "${REMOTE}" "${INPUT}"
Comment on lines +57 to +58
Copy link
Member

Choose a reason for hiding this comment

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

Here, too. I suggest removing the force.

fi
echo "Tag '${INPUT}' has been created and pushed to remote repo."
echo "SUCCESS"