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

Conversation

Elbehery
Copy link
Member

@Elbehery Elbehery commented Feb 10, 2025

This PR adds release.sh script to automate the process of releasing bbolt repo.

resolves #896

Below is output of release.sh run

melbeher@melbeher-mac bbolt % ./scripts/release.sh               version_20250212
enter release string according to semantic versioning (e.g. v1.2.3).
v1.4.0-beta.15
fatal: a branch named 'version_20250212' already exists
Updating version from '1.4.0-alpha.0' to '1.4.0-beta.15' in 'version.go'
committing 'version.go'
[version_20250212 234b458] Update version to 1.4.0-beta.15
 1 file changed, 1 insertion(+), 1 deletion(-)
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 379 bytes | 379.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:Elbehery/bbolt.git
 + 9ad97a4...234b458 version_20250212 -> version_20250212 (forced update)
branch 'version_20250212' set up to track 'origin/version_20250212'.
'version.go' has been committed to remote repo.
Creating new tag for 'v1.4.0-beta.15'
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:Elbehery/bbolt.git
 * [new tag]         v1.4.0-beta.15 -> v1.4.0-beta.15
Tag 'v1.4.0-beta.15' has been created and pushed to remote repo.
SUCCESS

@Elbehery Elbehery force-pushed the 20250210-add-release-script branch from 0b369bb to 7649a72 Compare February 10, 2025 23:46
@ivanvc
Copy link
Member

ivanvc commented Feb 10, 2025

@Elbehery, we don't have a shellcheck CI check here (yet). Can you run shellcheck on your script? I believe there are a couple of instances where it will give warnings :)

@Elbehery Elbehery force-pushed the 20250210-add-release-script branch from 7649a72 to d35e27d Compare February 11, 2025 00:20
@Elbehery
Copy link
Member Author

@Elbehery, we don't have a shellcheck CI check here (yet). Can you run shellcheck on your script? I believe there are a couple of instances where it will give warnings :)

done 👍🏽 .. so it was mainly adding "" around vars 👍🏽

@Elbehery Elbehery force-pushed the 20250210-add-release-script branch 2 times, most recently from 50ecec3 to ff51289 Compare February 11, 2025 15:37
Copy link
Member

@ivanvc ivanvc left a comment

Choose a reason for hiding this comment

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

Thanks for the pull request, @Elbehery. I left some comments ✌️

echo "committing version.go"
git commit -s -m "Update version to ${VERSION}"

git push -u origin "${BRANCH}"
Copy link
Member

Choose a reason for hiding this comment

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

If we're allowing to override REPOSITORY with an environment variable, we could also receive a REMOTE, and replace the origin instances with "${REMOTE}".

Copy link
Member Author

Choose a reason for hiding this comment

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

makes perfect sense

Copy link
Member Author

Choose a reason for hiding this comment

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

done 👍🏽

Copy link
Member Author

Choose a reason for hiding this comment

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

iiuc, you want to have user-input for the remote name, correct ?

I just think, the PR has to be created from origin to upstream anyways

please correct me if I'm wrong

Copy link
Member

Choose a reason for hiding this comment

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

I meant:

REMOTE="${REMOTE:-origin}"

Then later:

git push -u "${REMOTE}" "${BRANCH}"

Copy link
Member

Choose a reason for hiding this comment

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

origin is the name of the default remote. That's why I would call it "REMOTE" rather than "ORIGIN".

By the way, you missed changing it in line 59 (https://github.com/etcd-io/bbolt/pull/903/files#diff-1bba00e5aca52286a667c09eff92ba2ca8e3ca77e0d31b0599cc829ab0173389R59)

Copy link
Member Author

Choose a reason for hiding this comment

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

thx for quick review 👍🏽

on it

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 meant:

REMOTE="${REMOTE:-origin}"

Then later:

git push -u "${REMOTE}" "${BRANCH}"

so I create a branch like this

date_string=$(date +%Y%m%d)
local_branch_name="version_${date_string}"

I use this branch to push the changes

git push -u -f "${REMOTE}" "${local_branch_name}"

Copy link
Member Author

Choose a reason for hiding this comment

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

updated 👍🏽

Copy link
Member Author

Choose a reason for hiding this comment

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

ran it again now after changes

./scripts/release.sh                                                version_20250213
enter release string according to semantic versioning (e.g. v1.2.3).
v1.4.0-beta.20
fatal: a branch named 'version_20250213' already exists
Updating version from '1.4.0-alpha.0' to '1.4.0-beta.20' in 'version.go'
committing 'version.go'
[version_20250213 c3d9930] Update version to 1.4.0-beta.20
 1 file changed, 1 insertion(+), 1 deletion(-)
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 376 bytes | 376.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:Elbehery/bbolt.git
 + 2e41368...c3d9930 version_20250213 -> version_20250213 (forced update)
branch 'version_20250213' set up to track 'origin/version_20250213'.
'version.go' has been committed to remote repo.
Creating new tag for 'v1.4.0-beta.20'
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:Elbehery/bbolt.git
 * [new tag]         v1.4.0-beta.20 -> v1.4.0-beta.20
Tag 'v1.4.0-beta.20' has been created and pushed to remote repo.
SUCCESS

@Elbehery Elbehery force-pushed the 20250210-add-release-script branch from ff51289 to 17b4956 Compare February 12, 2025 21:17
@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Elbehery
Once this PR has been reviewed and has the lgtm label, please ask for approval from ahrtr. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@Elbehery Elbehery force-pushed the 20250210-add-release-script branch 2 times, most recently from f10036b to 5a05933 Compare February 12, 2025 21:18
@Elbehery
Copy link
Member Author

the last run after updates

melbeher@melbeher-mac bbolt % ./scripts/release.sh               version_20250212
enter release string according to semantic versioning (e.g. v1.2.3).
v1.4.0-beta.15
fatal: a branch named 'version_20250212' already exists
Updating version from '1.4.0-alpha.0' to '1.4.0-beta.15' in 'version.go'
committing 'version.go'
[version_20250212 234b458] Update version to 1.4.0-beta.15
 1 file changed, 1 insertion(+), 1 deletion(-)
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 379 bytes | 379.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:Elbehery/bbolt.git
 + 9ad97a4...234b458 version_20250212 -> version_20250212 (forced update)
branch 'version_20250212' set up to track 'origin/version_20250212'.
'version.go' has been committed to remote repo.
Creating new tag for 'v1.4.0-beta.15'
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:Elbehery/bbolt.git
 * [new tag]         v1.4.0-beta.15 -> v1.4.0-beta.15
Tag 'v1.4.0-beta.15' has been created and pushed to remote repo.
SUCCESS

@Elbehery Elbehery force-pushed the 20250210-add-release-script branch 2 times, most recently from e24ec75 to 9afab2b Compare February 12, 2025 23:59
Signed-off-by: Mustafa Elbehery <melbeher@redhat.com>
@Elbehery Elbehery force-pushed the 20250210-add-release-script branch from 9afab2b to fe76a05 Compare February 13, 2025 10:49
Copy link
Member

@ivanvc ivanvc left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, @Elbehery. Sorry if there has been a lot of back and forth. I should have tested your script locally (apologies). Thanks again :)

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

Comment on lines +57 to +58
git tag -f "${INPUT}"
git push -f "${REMOTE}" "${INPUT}"
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.

Comment on lines +31 to +37
# 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
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 ?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Create a release.sh to automatically release bbolt
4 participants