-
Notifications
You must be signed in to change notification settings - Fork 688
release: add release script #903
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# === Function Definitions === | ||
function get_gpg_key { | ||
local git_email | ||
local key_id | ||
|
||
git_email=$(git config --get user.email) | ||
key_id=$(gpg --list-keys --with-colons "${git_email}" | awk -F: '/^pub:/ { print $5 }') | ||
if [[ -z "${key_id}" ]]; then | ||
echo "Failed to load gpg key. Is gpg set up correctly for etcd releases?" | ||
return 2 | ||
fi | ||
echo "${key_id}" | ||
} | ||
|
||
# === Main Script Logic === | ||
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:-"[email protected]:etcd-io/bbolt.git"} | ||
REMOTE="${REMOTE:-"origin"}" | ||
|
||
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 | ||
|
||
# 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 | ||
|
||
# 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 "${REMOTE}" "${INPUT}" | ||
echo "'version.go' has been committed to remote repo." | ||
|
||
# create tag and push to remote. | ||
echo "Creating new tag for '${INPUT}'" | ||
key_id=$(get_gpg_key) || return 2 | ||
Elbehery marked this conversation as resolved.
Show resolved
Hide resolved
|
||
git tag --local-user "${key_id}" --sign "${INPUT}" --message "${INPUT}" | ||
git push "${REMOTE}" "${INPUT}" | ||
echo "Tag '${INPUT}' has been created and pushed to remote repo." | ||
echo "SUCCESS" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we checkout the target release-major.minor branch? Then we can reuse the same script on main branch to release the patches of the stable releases (release-1.4 and release-1.3) as well.
Otherwise, we will have to backport the PR to stable releases. But even we backport the PR, we still need to checkout the target release-major.minor branch?
cc @Elbehery @ivanvc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with changing the branch so we don't need to backport and maintain the script across branches. I'm working on a PR now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for my delayed response, i am fine with your decision 👍🏽