Skip to content

Add script to apply release-only changes #2578

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

Closed
wants to merge 3 commits into from
Closed
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
53 changes: 53 additions & 0 deletions scripts/release/apply-release-changes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

: '
# Step 2 after branch cut is complete.
#
# Creates PR with release only changes.
#
# Usage (run from root of project):
# DRY_RUN=disabled ./scripts/release/apply-release-changes.sh
#
# RELEASE_VERSION: Version of this current release
'

set -eou pipefail

GIT_TOP_DIR=$(git rev-parse --show-toplevel)
RELEASE_VERSION=${RELEASE_VERSION:-$(cut -d'.' -f1-2 "${GIT_TOP_DIR}/version.txt")}
RELEASE_BRANCH="release/${RELEASE_VERSION}"

# Check out to Release Branch

if git ls-remote --exit-code origin ${RELEASE_BRANCH} >/dev/null 2>&1; then
echo "Check out to Release Branch '${RELEASE_BRANCH}'"
git checkout -b ${RELEASE_BRANCH}
else
echo "Error: Remote branch '${RELEASE_BRANCH}' not found. Please run 'cut-release-branch.sh' first."
exit 1
fi

# Change all GitHub Actions to reference the test-infra release branch
# as opposed to main.
echo "Applying release-only changes to workflows"
for i in .github/workflows/*.yml; do
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' -e s#@main#@"${RELEASE_BRANCH}"# $i;
sed -i '' -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${RELEASE_BRANCH}"# $i;
else
sed -i -e s#@main#@"${RELEASE_BRANCH}"# $i;
sed -i -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${RELEASE_BRANCH}"# $i;
fi
done

echo "You'll need to manually commit the changes and create a PR. Here are the steps:"
echo "1. Stage the changes to the workflow files:"
echo " git add ./github/workflows/*.yml"
echo "2. Commit the changes:"
echo " git commit -m \"[RELEASE-ONLY CHANGES] Branch Cut for Release ${RELEASE_VERSION}\""
echo "3. After committing, create a pull request to merge the changes."