4646 # ET_VERSION_DOCS will be pulled during the doc build to add to the version dropdown
4747 # on the website. See docs/source/conf.py for details
4848
49- REF_TYPE=${{ github.ref_type }}
50- REF_NAME=${{ github.ref_name }}
51-
52- echo "$REF_TYPE"
53- echo "$REF_NAME"
54-
55- ET_VERSION_DOCS="${REF_NAME}"
49+ GITHUB_REF=${{ github.ref }}
50+ echo "$GITHUB_REF"
51+ ET_VERSION_DOCS="${GITHUB_REF}"
5652 echo "$ET_VERSION_DOCS"
5753
5854 set -eux
6965 cd ..
7066
7167 # If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
72- GITHUB_REF=${{ github.ref }}
7368 echo "GitHub Ref: ${GITHUB_REF}"
7469 if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
7570 find docs/_build/html/ -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
8378
8479 upload-gh-pages :
8580 needs : build
86- if : github.repository == 'pytorch/executorch' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/ tags/v'))
81+ if : github.repository == 'pytorch/executorch' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
8782 permissions :
8883 contents : write
8984 uses : pytorch/test-infra/.github/workflows/linux_job.yml@main
@@ -95,28 +90,17 @@ jobs:
9590 script : |
9691 set -euo pipefail
9792
98- REF_TYPE=${{ github.ref_type }}
99- REF_NAME=${{ github.ref_name }}
100-
101- # If building for a release tag, branch, set the branch/tag name
102- # as the target folder in the gh-pages branch. The artifacts created
103- # during the build will be copied over to the target dir in the
104- # gh-pages branch.
105- if [[ "${REF_TYPE}" == branch ]]; then
106- TARGET_FOLDER="${REF_NAME}"
107- elif [[ "${REF_TYPE}" == tag ]]; then
108- # Strip the leading "v" as well as the trailing patch version and "-rc" suffix.
109- # For example: 'v0.1.2' -> '0.1' and 'v0.1.2-rc1' -> 0.1.
110- case "${REF_NAME}" in
111- *-rc*)
112- echo "Aborting upload since this is an RC tag: ${REF_NAME}"
113- # We don't generate -rc* documentation but for actual tag only.
114- exit 0
115- ;;
116- *)
117- TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/')
118- ;;
119- esac
93+ # Get github.ref for the output doc folder. By default "main"
94+ # If matches a tag like refs/tags/v1.12.0-rc3 or
95+ # refs/tags/v1.12.0 convert to 1.12
96+ GITHUB_REF=${{ github.ref }}
97+
98+ # Convert refs/tags/v1.12.0rc3 into 1.12.
99+ # Adopted from https://github.com/pytorch/pytorch/blob/main/.github/workflows/_docs.yml#L150C11-L155C13
100+ if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\\.[0-9]+)\\. ]]; then
101+ TARGET_FOLDER="${BASH_REMATCH[1]}"
102+ else
103+ TARGET_FOLDER="main"
120104 fi
121105 echo "Target Folder: ${TARGET_FOLDER}"
122106
0 commit comments