Skip to content
Merged
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
27 changes: 22 additions & 5 deletions registry-scanner/hack/create-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,29 @@
# - checkout this branch locally
# - run this script from repo registry-scanner module: ./hack/create-release.sh [TARGET_VERSION] [REMOTE]
# - merge the PR
# Example Uses:
# ./hack/create-release.sh 0.1.1 Would create a new tag "registry-scanner/v0.1.1" with
# the message "Release registry-scanner/v0.1.1" and edit
# VERSION file to be 0.1.1 which would be committed.
#
# ./hack/create-release.sh 0.1.X upstream Would create a new tag "registry-scanner/v0.1.X" with
# the message "Relase registry-scanner/v0.1.X" and edit
# VERSION to be 0.1.X which would be committed. The contents
# would be pushed to the remote "upstream."

TARGET_VERSION="$1"

USAGE_ERR=" USAGE: $0 [TARGET_VERSION] [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

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

Expand All @@ -35,6 +48,7 @@ if [[ ! $(git ls-remote --exit-code ${REMOTE_URL} ${RELEASE_BRANCH}) ]]; then
fi

NEW_TAG="${SUBMODULE_NAME}/v${TARGET_VERSION}"
MESSAGE="Release ${NEW_TAG}"

### look for latest on-branch tag to check if it matches the NEW_TAG
PREVIOUS_TAG=$(git describe --tags --abbrev=0 --match "${SUBMODULE_NAME}/*" 2>/dev/null || true)
Expand All @@ -47,7 +61,10 @@ fi
echo "Creating tag ${NEW_TAG}"
echo "${TARGET_VERSION}" > VERSION

# Create tag for registry-scanner
git tag "${NEW_TAG}"
git push "${REMOTE}" tag "${NEW_TAG}"
# Commit updated VERSION file
git add VERSION
git commit -s -m "${MESSAGE}"

# Create tag for registry-scanner
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}" "${RELEASE_BRANCH}" "${NEW_TAG}"