From 6ceeac4c5c3c2bd53d788c04e7c7578aa448dbfb Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 15 Apr 2024 15:20:24 -0700 Subject: [PATCH 1/6] Update doc-build.yml --- .github/workflows/doc-build.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index ee5cfb859b3..0dace0a3dd2 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -99,6 +99,13 @@ jobs: REF_TYPE=${{ github.ref_type }} REF_NAME=${{ github.ref_name }} + # If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing. + REF_NAME=$(echo "${{ github.ref }}") + echo "Ref name: ${REF_NAME}" + if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then + find docs -name "*.html" -print0 | xargs -0 sed -i '//a \ \ '; + fi + # If building for a release tag, branch, set the branch/tag name # as the target folder in the gh-pages branch. The artifacts created # during the build will be copied over to the target dir in the @@ -106,12 +113,15 @@ jobs: if [[ "${REF_TYPE}" == branch ]]; then TARGET_FOLDER="${REF_NAME}" elif [[ "${REF_TYPE}" == tag ]]; then - # Strip the leading "v" as well as the trailing patch version and "-rc" suffix. - # For example: 'v0.1.2' -> '0.1' and 'v0.1.2-rc1' -> 0.1. - TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/^v//i; s/-rc[0-9]*$//; s/\.[0-9]*$//') - else - echo "ERROR: Invalid REF_TYPE: ${REF_TYPE}. Expected 'branch' or 'tag'." - exit 1 + case "${REF_NAME}" in + *-rc*) + echo "Aborting upload since this is an RC tag: ${REF_NAME}" + exit 0 + ;; + *) + TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/') + ;; + esac fi echo "Target Folder: ${TARGET_FOLDER}" @@ -122,12 +132,6 @@ jobs: mv "${RUNNER_ARTIFACT_DIR}"/html/* "${TARGET_FOLDER}" git add "${TARGET_FOLDER}" || true - # If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing. - if [[ "${REF_NAME}" == 'main' ]]; then - find "${TARGET_FOLDER}" -type f -name "*.html" -exec sed -i '//a ' {} \; - git add "${TARGET_FOLDER}"/**/*.html || true - fi - git config user.name 'pytorchbot' git config user.email 'soumith+bot@pytorch.org' git commit -m "Auto-generating sphinx docs" || true From 775d9f049febed1cfb31863a61ff780f36675f5f Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 15 Apr 2024 15:55:59 -0700 Subject: [PATCH 2/6] Update doc-build.yml --- .github/workflows/doc-build.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 0dace0a3dd2..325cc53cf5f 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -74,17 +74,10 @@ jobs: ls -R "${RUNNER_ARTIFACT_DIR}"/*/*.html -# Enable preview later. Previews are available publicly -# -# upload-preview: -# if: github.repository == 'pytorch/executorch' && github.event_name == 'push' && -# (github.ref_type == 'branch' && github.ref_name == 'main') -# uses: pytorch/test-infra/.github/workflows/linux_job.yml@main - upload-gh-pages: needs: build if: github.repository == 'pytorch/executorch' && github.event_name == 'push' && - ((github.ref_type == 'branch' && github.ref_name == 'main') || github.ref_type == 'tag') + (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/v')) permissions: contents: write uses: pytorch/test-infra/.github/workflows/linux_job.yml@main From b78d28b16c5c1e662f31e3875a19b710a01305e0 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Mon, 15 Apr 2024 16:27:18 -0700 Subject: [PATCH 3/6] Update doc-build.yml --- .github/workflows/doc-build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 325cc53cf5f..58d7a099713 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -76,8 +76,7 @@ jobs: upload-gh-pages: needs: build - 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')) + 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')) permissions: contents: write uses: pytorch/test-infra/.github/workflows/linux_job.yml@main From 446a5a720775858464ec3018f122d6867379d187 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 16 Apr 2024 13:30:46 -0700 Subject: [PATCH 4/6] Address comments --- .github/workflows/doc-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 58d7a099713..99ea9100b63 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -105,6 +105,8 @@ jobs: if [[ "${REF_TYPE}" == branch ]]; then TARGET_FOLDER="${REF_NAME}" elif [[ "${REF_TYPE}" == tag ]]; then + # Strip the leading "v" as well as the trailing patch version and "-rc" suffix. + # For example: 'v0.1.2' -> '0.1' and 'v0.1.2-rc1' -> 0.1. case "${REF_NAME}" in *-rc*) echo "Aborting upload since this is an RC tag: ${REF_NAME}" From edcd8ef3619767d5390945a944af9eb0f351344f Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 16 Apr 2024 13:32:15 -0700 Subject: [PATCH 5/6] Minor fix --- .github/workflows/doc-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 99ea9100b63..401c6f65394 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -105,8 +105,8 @@ jobs: if [[ "${REF_TYPE}" == branch ]]; then TARGET_FOLDER="${REF_NAME}" elif [[ "${REF_TYPE}" == tag ]]; then - # Strip the leading "v" as well as the trailing patch version and "-rc" suffix. - # For example: 'v0.1.2' -> '0.1' and 'v0.1.2-rc1' -> 0.1. + # Strip the leading "v" as well as the trailing patch version and "-rc" suffix. + # For example: 'v0.1.2' -> '0.1' and 'v0.1.2-rc1' -> 0.1. case "${REF_NAME}" in *-rc*) echo "Aborting upload since this is an RC tag: ${REF_NAME}" From 06a77ce0599ee695bddae57fa5310017af4f8a06 Mon Sep 17 00:00:00 2001 From: Svetlana Karslioglu Date: Tue, 16 Apr 2024 13:34:44 -0700 Subject: [PATCH 6/6] Add a comment --- .github/workflows/doc-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 401c6f65394..75529bb44b8 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -110,6 +110,7 @@ jobs: case "${REF_NAME}" in *-rc*) echo "Aborting upload since this is an RC tag: ${REF_NAME}" + # We don't generate -rc* documentation but for actual tag only. exit 0 ;; *)