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