Skip to content

Commit a49926b

Browse files
committed
Add script to apply release-only changes
ghstack-source-id: 05d72a2 Pull Request resolved: #2578
1 parent fcb9653 commit a49926b

File tree

1 file changed

+53
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)