xref: /aosp_15_r20/external/pytorch/scripts/release/apply-release-changes.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1#!/usr/bin/env bash
2#
3# Step 2 after branch cut is complete.
4#
5# Creates PR with release only changes.
6#
7# Prerequisite: Must be  successfully authenticated in aws fbossci account.
8#
9# Usage (run from root of project):
10#  DRY_RUN=disabled ./scripts/release/apply-release-changes.sh
11#
12# RELEASE_VERSION: Version of this current release
13
14set -eou pipefail
15
16GIT_TOP_DIR=$(git rev-parse --show-toplevel)
17RELEASE_VERSION=${RELEASE_VERSION:-$(cut -d'.' -f1-2 "${GIT_TOP_DIR}/version.txt")}
18DRY_RUN=${DRY_RUN:-enabled}
19
20# Change all GitHub Actions to reference the test-infra release branch
21# as opposed to main.
22echo "Applying to workflows"
23for i in .github/workflows/*.yml; do
24    sed -i -e s#@main#@"release/${RELEASE_VERSION}"# $i;
25done
26
27# Change all checkout step in templates to not add ref to checkout
28echo "Applying to templates"
29for i in .github/templates/*.yml.j2; do
30    sed -i 's#common.checkout(\(.*\))#common.checkout(\1, checkout_pr_head=False)#' $i;
31done
32
33# Triton wheel
34echo "Triton Changes"
35sed -i -e s#-\ main#"-\ release\/${RELEASE_VERSION}"# .github/workflows/build-triton-wheel.yml
36
37# XLA related changes
38echo "XLA Changes"
39sed -i -e s#--quiet#-b\ r"${RELEASE_VERSION}"# .ci/pytorch/common_utils.sh
40sed -i -e s#.*#r"${RELEASE_VERSION}"# .github/ci_commit_pins/xla.txt
41
42# Regenerate templates
43export RELEASE_VERSION_TAG=${RELEASE_VERSION}
44./.github/regenerate.sh
45
46# Pin Unstable and disabled jobs and tests
47UNSTABLE_VER=$(aws s3api list-object-versions --bucket ossci-metrics --prefix unstable-jobs.json --query 'Versions[?IsLatest].[VersionId]' --output text)
48DISABLED_VER=$(aws s3api list-object-versions --bucket ossci-metrics --prefix disabled-jobs.json --query 'Versions[?IsLatest].[VersionId]' --output text)
49SLOW_VER=$(aws s3api list-object-versions --bucket ossci-metrics --prefix slow-tests.json --query 'Versions[?IsLatest].[VersionId]' --output text)
50DISABLED_TESTS_VER=$(aws s3api list-object-versions --bucket ossci-metrics --prefix disabled-tests-condensed.json --query 'Versions[?IsLatest].[VersionId]' --output text)
51sed -i -e s#unstable-jobs.json#"unstable-jobs.json?versionId=${UNSTABLE_VER}"# .github/scripts/filter_test_configs.py
52sed -i -e s#disabled-jobs.json#"disabled-jobs.json?versionId=${DISABLED_VER}"# .github/scripts/filter_test_configs.py
53sed -i -e s#disabled-tests-condensed.json#"disabled-tests-condensed.json?versionId=${DISABLED_TESTS_VER}"# tools/stats/import_test_stats.py
54# Optional
55git commit -m "[RELEASE-ONLY CHANGES] Branch Cut for Release {RELEASE_VERSION}"
56git push origin "${RELEASE_BRANCH}"
57