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@main
@@ -95,28 +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 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"
120
104
fi
121
105
echo "Target Folder: ${TARGET_FOLDER}"
122
106
0 commit comments