Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] 🐛 Allow to make a release from local machine #381

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ source $(dirname "${BASH_SOURCE[0]}")/library.sh
readonly ORG_NAME="${ORG_NAME:-knative}"

# GitHub upstream.
readonly REPO_UPSTREAM="https://github.com/${ORG_NAME}/${REPO_NAME}"
REPO_UPSTREAM="https://github.com/${ORG_NAME}/${REPO_NAME}"

# GCRs for Knative releases.
readonly NIGHTLY_GCR="gcr.io/knative-nightly/github.com/${ORG_NAME}/${REPO_NAME}"
Expand Down Expand Up @@ -156,13 +156,15 @@ function setup_upstream() {
if [[ -z "${upstream}" ]]; then
echo "Setting remote upstream URL to '${REPO_UPSTREAM}'"
git remote add upstream "${REPO_UPSTREAM}"
else
REPO_UPSTREAM="${upstream}"
fi
}

# Fetch the release branch, so we can check it out.
function setup_branch() {
[[ -z "${RELEASE_BRANCH}" ]] && return
git fetch "${REPO_UPSTREAM}" "${RELEASE_BRANCH}:upstream/${RELEASE_BRANCH}"
git checkout --track "upstream/${RELEASE_BRANCH}" || abort "cannot checkout branch ${RELEASE_BRANCH}"
}

# Setup version, branch and release notes for a auto release.
Expand Down Expand Up @@ -211,6 +213,8 @@ function prepare_dot_release() {
echo "Dot release requested"
TAG_RELEASE=1
PUBLISH_RELEASE=1
# Make sure the upstream is set
setup_upstream
git fetch --all || abort "error fetching branches/tags from remote"
# List latest release
local releases # don't combine with the line below, or $? will be 0
Expand Down Expand Up @@ -676,7 +680,7 @@ function set_latest_to_highest_semver() {
fi

hub_tool api --method PATCH "/repos/${ORG_NAME}/${REPO_NAME}/releases/$release_id" \
-F make_latest=true > /dev/null || abort "error setting $last_version to 'latest'"
-F make_latest=true || abort "error setting $last_version to 'latest'"
echo "Github release ${last_version} set as 'latest'"
}

Expand All @@ -690,13 +694,6 @@ function main() {
if [[ -n "${RELEASE_BRANCH}" && -z "${FROM_NIGHTLY_RELEASE}" && "${current_branch}" != "${RELEASE_BRANCH}" ]]; then
setup_upstream
setup_branch
# When it runs in Prow, the origin is identical with upstream, and previous
# fetch already fetched release-* branches, so no need to `checkout -b`
if (( IS_PROW )); then
git checkout "${RELEASE_BRANCH}" || abort "cannot checkout branch ${RELEASE_BRANCH}"
else
git checkout -b "${RELEASE_BRANCH}" upstream/"${RELEASE_BRANCH}" || abort "cannot checkout branch ${RELEASE_BRANCH}"
fi
# HACK HACK HACK
# Rerun the release script from the release branch. Fixes https://github.com/knative/test-infra/issues/1262
./hack/release.sh "$@"
Expand Down