Skip to content

Commit

Permalink
release: support kick off release in current branch
Browse files Browse the repository at this point in the history
When triggering release process in github workflow, then always
run it in current branch, so that any changes in current branch
are included.

When manually triggering release, always pull remote repo and
checkout main branch.

Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Nov 26, 2022
1 parent 72b9d1d commit 71cd4f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
Name-Email: [email protected]
Expire-Date: 0
EOF
DRY_RUN=true BRANCH=main ./scripts/release.sh --no-upload --no-docker-push 3.6.99
DRY_RUN=true ./scripts/release.sh --no-upload --no-docker-push --current-branch 3.6.99
15 changes: 13 additions & 2 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ main() {
fi
RELEASE_VERSION="v${VERSION}"
MINOR_VERSION=$(echo "${VERSION}" | cut -d. -f 1-2)
BRANCH=${BRANCH:-"release-${MINOR_VERSION}"}
REPOSITORY=${REPOSITORY:-"https://github.com/etcd-io/etcd.git"}

if [ "${CURRENT_BRANCH}" == 1 ]; then
# Trigger release in current branch, used in github workflow
BRANCH=$(git branch)
else
BRANCH=${BRANCH:-"release-${MINOR_VERSION}"}
fi

log_warning "DRY_RUN=${DRY_RUN}"
log_callout "RELEASE_VERSION=${RELEASE_VERSION}"
log_callout "MINOR_VERSION=${MINOR_VERSION}"
Expand All @@ -78,7 +84,7 @@ main() {
# Set up release directory.
local reldir="/tmp/etcd-release-${VERSION}"
log_callout "Preparing temporary directory: ${reldir}"
if [ ! -d "${reldir}/etcd" ]; then
if [ ! -d "${reldir}/etcd" ] && [ "${CURRENT_BRANCH}" == 0 ]; then
mkdir -p "${reldir}"
cd "${reldir}"
run git clone "${REPOSITORY}" --branch "${BRANCH}"
Expand Down Expand Up @@ -308,6 +314,7 @@ main() {
POSITIONAL=()
NO_UPLOAD=0
NO_DOCKER_PUSH=0
CURRENT_BRANCH=0

while test $# -gt 0; do
case "$1" in
Expand All @@ -316,6 +323,10 @@ while test $# -gt 0; do
help
exit 0
;;
--current-branch)
CURRENT_BRANCH=1
shift
;;
--no-upload)
NO_UPLOAD=1
shift
Expand Down

0 comments on commit 71cd4f4

Please sign in to comment.