Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion registry-scanner/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.111.0
0.1.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

41 changes: 32 additions & 9 deletions registry-scanner/hack/create-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,48 @@
# - install gh cli and semver-cli (go install github.com/davidrjonas/semver-cli@latest)
# - create and push "registry-scanner/release-X.Y" branch
# - checkout this branch locally
# - run this script from repo registry-scanner module: ./hack/create-release.sh [TARGET_VERSION] [REMOTE]
# - run this script from repo registry-scanner module: ./hack/create-release.sh [TARGET_VERSION] [MESSAGE] [REMOTE]
# - merge the PR
# Example Uses:
# `./hack/create-release.sh 0.1.1 "This is an example message"` Would create a new tag "registry-scanner/v0.1.1" with
# the message "This is an example message" and edit
# VERSION to be 0.1.1 which would be committed.
#
# `./hack/create-release.sh 0.1.X "TEST"` origin Would create a new tag "registry-scanner/v0.1.X" with
# the message "TEST" and edit VERSION to be 0.1.X which
# would be committed. The contents would be pushed to the
# remote "origin."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Having a message gives more control for users to custom a tag and commit message, but at the same time also makes it slightly harder to run this command. I think the tag and commit message are pretty standard, using the tag name should suffice.


TARGET_VERSION="$1"
MESSAGE="$2"

USAGE_ERR=" USAGE: $0 [TARGET_VERSION] [MESSAGE] [REMOTE]"

set -eu
set -o pipefail

# Validate if arguments are present
if test "${TARGET_VERSION}" = ""; then
echo "USAGE: $0 <version> <remote>" >&2
printf "!! TARGET_VERSION is missing\n$USAGE_ERR\n" >&2
exit 1
fi

if test "${MESSAGE}" = ""; then
printf "!! MESSAGE argument is missing\n$USAGE_ERR\n" >&2
exit 1
fi

CURRENT_BRANCH="$(git branch --show-current)"
SUBMODULE_NAME="registry-scanner"

if [[ ! "${CURRENT_BRANCH}" == registry-scanner/release-* ]]; then
echo "!! Please checkout branch 'registry-scanner/release-X.Y' (currently in branch: '${CURRENT_BRANCH}')" >&2
exit 1
fi
#if [[ ! "${CURRENT_BRANCH}" == registry-scanner/release-* ]]; then
# echo "!! Please checkout branch 'registry-scanner/release-X.Y' (currently in branch: '${CURRENT_BRANCH}')" >&2
# exit 1
#fi
Copy link
Collaborator

Choose a reason for hiding this comment

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

the above validation is useful and should be preserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops forgot to uncomment when I was testing 😅


RELEASE_BRANCH="${CURRENT_BRANCH}"

REMOTE=${2:-origin}
REMOTE=${3:-origin}
REMOTE_URL=$(git remote get-url "${REMOTE}")

if [[ ! $(git ls-remote --exit-code ${REMOTE_URL} ${RELEASE_BRANCH}) ]]; then
Expand All @@ -47,7 +66,11 @@ fi
echo "Creating tag ${NEW_TAG}"
echo "${TARGET_VERSION}" > VERSION

# Commit updated VERSION file
git add VERSION
git commit -s -m "automated: bump VERSION file to version ${TARGET_VERSION}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should use the conventional commit message: "Release ${NEW_TAG}"


# Create tag for registry-scanner
git tag "${NEW_TAG}"
git push "${REMOTE}" tag "${NEW_TAG}"
git tag -a "${NEW_TAG}" -m "${MESSAGE}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

message can be the same as ${NEW_TAG}

git push "${REMOTE}" --follow-tags #tag "${NEW_TAG}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

the trailing comment seems redundant.

since we're usually directly pushing to upstream, I'd like to be specific about which tags and branches, something like:

git push "${REMOTE}" ${RELEASE_BRANCH} ${NEW_TAG}

Will that achieve the same effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That flag prevents you from needing to do a git push for the VERSION file commit and then needing to do another git push to commit the tag. It can be split up no problem but I left the comment as a note of what was originally was there. Which would be preferred the two separate pushes or just the one?