Skip to content

Commit 338bc33

Browse files
authored
chore: improve registry-scanner/hack/create-release.sh (#1157)
Signed-off-by: Christopher Coco <[email protected]>
1 parent 975081e commit 338bc33

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

registry-scanner/hack/create-release.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,29 @@
66
# - checkout this branch locally
77
# - run this script from repo registry-scanner module: ./hack/create-release.sh [TARGET_VERSION] [REMOTE]
88
# - merge the PR
9+
# Example Uses:
10+
# ./hack/create-release.sh 0.1.1 Would create a new tag "registry-scanner/v0.1.1" with
11+
# the message "Release registry-scanner/v0.1.1" and edit
12+
# VERSION file to be 0.1.1 which would be committed.
13+
#
14+
# ./hack/create-release.sh 0.1.X upstream Would create a new tag "registry-scanner/v0.1.X" with
15+
# the message "Relase registry-scanner/v0.1.X" and edit
16+
# VERSION to be 0.1.X which would be committed. The contents
17+
# would be pushed to the remote "upstream."
918

1019
TARGET_VERSION="$1"
20+
21+
USAGE_ERR=" USAGE: $0 [TARGET_VERSION] [REMOTE]"
22+
1123
set -eu
1224
set -o pipefail
1325

26+
# Validate if arguments are present
1427
if test "${TARGET_VERSION}" = ""; then
15-
echo "USAGE: $0 <version> <remote>" >&2
28+
printf "!! TARGET_VERSION is missing\n$USAGE_ERR\n" >&2
1629
exit 1
1730
fi
18-
31+
1932
CURRENT_BRANCH="$(git branch --show-current)"
2033
SUBMODULE_NAME="registry-scanner"
2134

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

3750
NEW_TAG="${SUBMODULE_NAME}/v${TARGET_VERSION}"
51+
MESSAGE="Release ${NEW_TAG}"
3852

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

50-
# Create tag for registry-scanner
51-
git tag "${NEW_TAG}"
52-
git push "${REMOTE}" tag "${NEW_TAG}"
64+
# Commit updated VERSION file
65+
git add VERSION
66+
git commit -s -m "${MESSAGE}"
5367

68+
# Create tag for registry-scanner
69+
git tag -a "${NEW_TAG}" -m "${MESSAGE}"
70+
git push "${REMOTE}" "${RELEASE_BRANCH}" "${NEW_TAG}"

0 commit comments

Comments
 (0)