Skip to content

Commit

Permalink
Adjust build_release_candidate.sh to use existing tag
Browse files Browse the repository at this point in the history
  • Loading branch information
kennknowles committed Mar 17, 2021
1 parent e3a7c26 commit b817a1c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
24 changes: 3 additions & 21 deletions release/src/main/scripts/build_release_candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ read USER_GITHUB_ID
RC_TAG="v${RELEASE}-RC${RC_NUM}"

USER_REMOTE_URL=https://github.com/${USER_GITHUB_ID}/beam-site
RC_TAG="v${RELEASE}-RC${RC_NUM}"

echo "=================Pre-requirements===================="
echo "Please make sure you have configured and started your gpg by running ./preparation_before_release.sh."
Expand All @@ -82,7 +83,7 @@ echo "================Checking Environment Variables=============="
echo "beam repo will be cloned into: ${LOCAL_CLONE_DIR}"
echo "working on release version: ${RELEASE}"
echo "working on release branch: ${RELEASE_BRANCH}"
echo "will create release candidate: RC${RC_NUM} with tag ${RC_TAG}"
echo "will create release candidate: RC${RC_NUM} from commit tagged ${RC_TAG}"
echo "Your forked beam-site URL: ${USER_REMOTE_URL}"
echo "Your signing key: ${SIGNING_KEY}"
echo "Please review all environment variables and confirm: [y|N]"
Expand Down Expand Up @@ -112,31 +113,12 @@ if [[ $confirmation = "y" ]]; then
fi
mkdir -p ${LOCAL_CLONE_DIR}
cd ${LOCAL_CLONE_DIR}
git clone ${GIT_REPO_URL}
git clone --depth 1 --branch "${RC_TAG}" ${GIT_REPO_URL} "${BEAM_ROOT_DIR}"
cd ${BEAM_ROOT_DIR}
git checkout ${RELEASE_BRANCH}
RELEASE_COMMIT=$(git rev-parse --verify ${RELEASE_BRANCH})
echo "-------------Building Java Artifacts with Gradle-------------"
git config credential.helper store
if git rev-parse "v${RELEASE}-RC${RC_NUM}" >/dev/null 2>&1; then
echo "Tag v${RELEASE}-RC${RC_NUM} already exists."
echo "Delete the tag and create a new tag commit (y) or skip this step (n)? [y/N]"
read confirmation
if [[ $confirmation = "y" ]]; then
# Delete tag with the git push <from>:<to> format, as shown here:
# https://git-scm.com/docs/git-push#Documentation/git-push.txt-codegitpushoriginexperimentalcode
git push origin :refs/tags/v${RELEASE}-RC${RC_NUM}
fi
fi
if [[ $confirmation = "y" ]]; then # Expected to be "y" unless user chose to skip creating tag.
./gradlew release -Prelease.newVersion=${RELEASE}-SNAPSHOT \
-Prelease.releaseVersion=${RELEASE}-RC${RC_NUM} \
-Prelease.useAutomaticVersion=true --info --no-daemon
git push origin "${RELEASE_BRANCH}"
git push origin "v${RELEASE}-RC${RC_NUM}"
fi
echo "-------------Staging Java Artifacts into Maven---------------"
gpg --local-user ${SIGNING_KEY} --output /dev/null --sign ~/.bashrc
./gradlew publish -Psigning.gnupg.keyName=${SIGNING_KEY} -PisRelease --no-daemon
Expand Down
16 changes: 16 additions & 0 deletions release/src/main/scripts/choose_rc_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ RC=
COMMIT=
PUSH_TAG=no
CLONE=no
OVERWRITE=no
DEBUG=
[email protected]:apache/beam

Expand Down Expand Up @@ -66,6 +67,11 @@ while [[ $# -gt 0 ]] ; do
shift
;;

--overwrite)
OVERWRITE=yes
shift
;;

--clone)
CLONE=yes
shift
Expand Down Expand Up @@ -113,6 +119,16 @@ fi
bash "$SCRIPT_DIR/set_version.sh" "${RELEASE}" --release --git-add $DEBUG
git checkout --quiet "$COMMIT" # suppress warning about detached HEAD: we want it detached so we do not edit the branch
git commit -m "Set version for ${RELEASE} RC${RC}"

if git rev-parse "$RC_TAG" >/dev/null 2>&1; then
if [[ "$OVERWRITE" == yes ]]; then
git push origin ":refs/tags/$RC_TAG"
else
echo "Tag $RC_TAG already exists. Either delete it manually or run with --overwrite. Do not overwrite if an RC has been built and shared!"
exit 1
fi
fi

git tag -a -m "$RC_TAG" "$RC_TAG" HEAD

if [[ "$PUSH_TAG" == yes ]] ; then
Expand Down

0 comments on commit b817a1c

Please sign in to comment.