xref: /aosp_15_r20/external/executorch/scripts/release/apply-release-changes.sh (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
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#   TEST_INFRA_BRANCH=release/2.3 ./scripts/release/apply-release-changes.sh
15#
16# TEST_INFRA_BRANCH: The release branch of test-infra that houses all reusable
17'
18
19set -eou pipefail
20
21GIT_TOP_DIR=$(git rev-parse --show-toplevel)
22RELEASE_VERSION=${RELEASE_VERSION:-$(cut -d'.' -f1-2 "${GIT_TOP_DIR}/version.txt")}
23RELEASE_BRANCH="release/${RELEASE_VERSION}"
24
25# Check out to Release Branch
26
27if 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 ${RELEASE_BRANCH}
30else
31  echo "Error: Remote branch '${RELEASE_BRANCH}' not found. Please run 'cut-release-branch.sh' first."
32  exit 1
33fi
34
35# Change all GitHub Actions to reference the test-infra release branch
36# as opposed to main.
37echo "Applying release-only changes to workflows"
38for i in .github/workflows/*.yml; do
39  if [[ "$OSTYPE" == "darwin"* ]]; then
40    sed -i '' -e s#@main#@"${TEST_INFRA_BRANCH}"# $i;
41    sed -i '' -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${TEST_INFRA_BRANCH}"# $i;
42  else
43    sed -i -e s#@main#@"${TEST_INFRA_BRANCH}"# $i;
44    sed -i -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${TEST_INFRA_BRANCH}"# $i;
45  fi
46done
47
48echo "You'll need to manually commit the changes and create a PR. Here are the steps:"
49echo "1. Stage the changes to the workflow files:"
50echo "   git add ./github/workflows/*.yml"
51echo "2. Commit the changes:"
52echo "   git commit -m \"[RELEASE-ONLY CHANGES] Branch Cut for Release ${RELEASE_VERSION}\""
53echo "3. After committing, create a pull request to merge the changes."
54