|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +: ' |
| 4 | +# Step 2 after branch cut is complete. |
| 5 | +# |
| 6 | +# Creates PR with release only changes. |
| 7 | +# |
| 8 | +# Usage (run from root of project): |
| 9 | +# DRY_RUN=disabled ./scripts/release/apply-release-changes.sh |
| 10 | +# |
| 11 | +# RELEASE_VERSION: Version of this current release |
| 12 | +' |
| 13 | + |
| 14 | +set -eou pipefail |
| 15 | + |
| 16 | +GIT_TOP_DIR=$(git rev-parse --show-toplevel) |
| 17 | +RELEASE_VERSION=${RELEASE_VERSION:-$(cut -d'.' -f1-2 "${GIT_TOP_DIR}/version.txt")} |
| 18 | +RELEASE_BRANCH="release/${RELEASE_VERSION}" |
| 19 | + |
| 20 | +# Check out to Release Branch |
| 21 | + |
| 22 | +if git ls-remote --exit-code origin ${RELEASE_BRANCH} >/dev/null 2>&1; then |
| 23 | + echo "Check out to Release Branch '${RELEASE_BRANCH}'" |
| 24 | + git checkout -b ${RELEASE_BRANCH} |
| 25 | +else |
| 26 | + echo "Error: Remote branch '${RELEASE_BRANCH}' not found. Please run 'cut-release-branch.sh' first." |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +# Change all GitHub Actions to reference the test-infra release branch |
| 31 | +# as opposed to main. |
| 32 | +echo "Applying release-only changes to workflows" |
| 33 | +for i in .github/workflows/*.yml; do |
| 34 | + if [[ "$OSTYPE" == "darwin"* ]]; then |
| 35 | + sed -i '' -e s#@main#@"${RELEASE_BRANCH}"# $i; |
| 36 | + sed -i '' -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${RELEASE_BRANCH}"# $i; |
| 37 | + else |
| 38 | + sed -i -e s#@main#@"${RELEASE_BRANCH}"# $i; |
| 39 | + sed -i -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${RELEASE_BRANCH}"# $i; |
| 40 | + fi |
| 41 | +done |
| 42 | + |
| 43 | +echo "You'll need to manually commit the changes and create a PR. Here are the steps:" |
| 44 | +echo "1. Stage the changes to the workflow files:" |
| 45 | +echo " git add ./github/workflows/*.yml" |
| 46 | +echo "2. Commit the changes:" |
| 47 | +echo " git commit -m \"[RELEASE-ONLY CHANGES] Branch Cut for Release ${RELEASE_VERSION}\"" |
| 48 | +echo "3. After committing, create a pull request to merge the changes." |
0 commit comments