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
1019TARGET_VERSION=" $1 "
20+
21+ USAGE_ERR=" USAGE: $0 [TARGET_VERSION] [REMOTE]"
22+
1123set -eu
1224set -o pipefail
1325
26+ # Validate if arguments are present
1427if 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
1730fi
18-
31+
1932CURRENT_BRANCH=" $( git branch --show-current) "
2033SUBMODULE_NAME=" registry-scanner"
2134
@@ -35,6 +48,7 @@ if [[ ! $(git ls-remote --exit-code ${REMOTE_URL} ${RELEASE_BRANCH}) ]]; then
3548fi
3649
3750NEW_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
4054PREVIOUS_TAG=$( git describe --tags --abbrev=0 --match " ${SUBMODULE_NAME} /*" 2> /dev/null || true)
4761echo " Creating tag ${NEW_TAG} "
4862echo " ${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