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 cdb9b8b commit 5be55ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 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
18 changes: 15 additions & 3 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,12 +84,13 @@ 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}"
run cd "${reldir}/etcd" || exit 2
fi
run cd "${reldir}/etcd" || exit 2

# mark local directory as root for test_lib scripts executions
set_root_dir

Expand Down Expand Up @@ -308,6 +315,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 +324,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 5be55ed

Please sign in to comment.