Skip to content

Commit

Permalink
added validation on --current-branch mode
Browse files Browse the repository at this point in the history
--current-branch should only be called with DRY_RUN=true

Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Dec 1, 2022
1 parent a3be869 commit 26e341c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/build-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ source ./scripts/test_lib.sh

VER=$1
REPOSITORY="${REPOSITORY:-git@github.com:etcd-io/etcd.git}"
# When ${CURRENT_BRANCH} is 1, the scripts doesn't clone the remote
# repository at all, nor checkout the branch; instead, it just builds
# the binaries in current branch in local existing directory. The ${VER}
# will be ignored as well in such case.
# Otherwise if ${CURRENT_BRANCH} is 0, it clones the remote repository
# firstly, then checkout the target tagged version, and finally build
# binaries.
CURRENT_BRANCH=${CURRENT_BRANCH:-0}

if [ -z "$1" ]; then
Expand Down
8 changes: 8 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ help() {
echo " flags:"
echo " --no-upload: skip gs://etcd binary artifact uploads."
echo " --no-docker-push: skip docker image pushes."
echo " --current-branch: build binaries in current branch."
echo ""
echo "One can perform a (dry-run) test release from any (uncommitted) branch using:"
echo " DRY_RUN=true REPOSITORY=\`pwd\` BRANCH='local-branch-name' ./scripts/release 3.5.0-foobar.2"
Expand Down Expand Up @@ -362,4 +363,11 @@ if [[ ! $# -eq 1 ]]; then
exit 1
fi

# Note that we shouldn't upload artifacts in --current-branch mode, so it
# must be called with DRY_RUN=true
if [ "${DRY_RUN}" != "true" ] && [ "${CURRENT_BRANCH}" == 1 ]; then
log_error "--current-branch should only be called with DRY_RUN=true"
exit 1
fi

main "$1"

0 comments on commit 26e341c

Please sign in to comment.