46
46
# ET_VERSION_DOCS will be pulled during the doc build to add to the version dropdown
47
47
# on the website. See docs/source/conf.py for details
48
48
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}"
56
52
echo "$ET_VERSION_DOCS"
57
53
58
54
set -eux
69
65
cd ..
70
66
71
67
# If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
72
- GITHUB_REF=${{ github.ref }}
73
68
echo "GitHub Ref: ${GITHUB_REF}"
74
69
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
75
70
find docs/_build/html/ -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
83
78
84
79
upload-gh-pages :
85
80
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'))
87
82
permissions :
88
83
contents : write
89
84
uses : pytorch/test-infra/.github/workflows/linux_job.yml@release/2.3
@@ -95,35 +90,17 @@ jobs:
95
90
script : |
96
91
set -euo pipefail
97
92
98
- REF_TYPE=${{ github.ref_type }}
99
- REF_NAME=${{ github.ref_name }}
100
-
101
- # If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
102
- REF_NAME=$(echo "${{ github.ref }}")
103
- echo "Ref name: ${REF_NAME}"
104
- if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
105
- find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
106
- fi
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 }}
107
97
108
- # If building for a release tag, branch, set the branch/tag name
109
- # as the target folder in the gh-pages branch. The artifacts created
110
- # during the build will be copied over to the target dir in the
111
- # gh-pages branch.
112
- if [[ "${REF_TYPE}" == branch ]]; then
113
- TARGET_FOLDER="${REF_NAME}"
114
- elif [[ "${REF_TYPE}" == tag ]]; then
115
- # Strip the leading "v" as well as the trailing patch version and "-rc" suffix.
116
- # For example: 'v0.1.2' -> '0.1' and 'v0.1.2-rc1' -> 0.1.
117
- case "${REF_NAME}" in
118
- *-rc*)
119
- echo "Aborting upload since this is an RC tag: ${REF_NAME}"
120
- # We don't generate -rc* documentation but for actual tag only.
121
- exit 0
122
- ;;
123
- *)
124
- TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/')
125
- ;;
126
- esac
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"
127
104
fi
128
105
echo "Target Folder: ${TARGET_FOLDER}"
129
106
0 commit comments