From b146aab15312ee4d85ef25b079c1cedbc57e3d75 Mon Sep 17 00:00:00 2001
From: Roman Bredehoft <roman.bredehoft@zama.ai>
Date: Fri, 21 Jun 2024 10:56:26 +0200
Subject: [PATCH] chore: remove sphinx doc management in release ci

---
 .github/workflows/continuous-integration.yaml |  35 ++----
 .github/workflows/release.yaml                | 105 +-----------------
 2 files changed, 8 insertions(+), 132 deletions(-)

diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml
index 36b2fda72..d58ab3ef2 100644
--- a/.github/workflows/continuous-integration.yaml
+++ b/.github/workflows/continuous-integration.yaml
@@ -557,15 +557,15 @@ jobs:
         run: |
           make determinism
 
-      # Build the documentation if :
+      # Fix the documentation for Gitbook if :
       # - the current workflow takes place in a release CI with the reference build
       # - the current workflow takes place in a weekly CI or it has been triggered manually (through
       # GitHub's Action interface)
       # - any documentation files has been changed
       # - the source code has been changed
       # - Makefile has been changed
-      - name: Build docs
-        id: build-docs
+      - name: Fix docs
+        id: fix-docs
         if: |
           (
             (fromJSON(env.IS_RELEASE) && fromJSON(env.IS_REF_BUILD))
@@ -587,13 +587,13 @@ jobs:
         id: check_links
         if: |
           !fromJSON(env.IS_RELEASE)
-          && steps.build-docs.outcome == 'success'
+          && steps.fix-docs.outcome == 'success'
           && !cancelled()
         run: |
           make check_links
           make check_symlinks
 
-      # Make sure all necessary steps passed. For build-docs and determinism steps, we only check for
+      # Make sure all necessary steps passed. For fix-docs and determinism steps, we only check for
       # non-failures as the 'changed-files-in-pr' step might skip them
       - name: Stop if previous steps failed
         id: conformance
@@ -604,7 +604,7 @@ jobs:
               steps.commit-conformance.outcome == 'success'
               && steps.make-pcc.outcome == 'success'
               && steps.determinism.outcome != 'failure'
-              && steps.build-docs.outcome != 'failure'
+              && steps.fix-docs.outcome != 'failure'
               && steps.check_links.outcome != 'failure'
             }}
         run: |
@@ -613,32 +613,11 @@ jobs:
             echo "Commit conformance success step: ${{ steps.commit-conformance.outcome }}"
             echo "Make conformance step: ${{ steps.make-pcc.outcome }}"
             echo "Determinism step: ${{ steps.determinism.outcome }}"
-            echo "Build docs step: ${{ steps.build-docs.outcome }}"
+            echo "Fix docs step: ${{ steps.fix-docs.outcome }}"
             echo "Check links step: ${{ steps.check_links.outcome }}"
             exit 1
           fi
 
-      # Tar the docs for releases with the reference build only
-      # Taring the docs allows for much faster upload speed (from ~3min worst case to ~2s best case)
-      - name: Tar docs artifacts
-        id: tar-docs
-        if:  |
-          fromJSON(env.IS_RELEASE)
-          && fromJSON(env.IS_REF_BUILD)
-          && steps.conformance.outcome == 'success'
-          && steps.build-docs.outcome == 'success'
-          && !cancelled()
-        run: |
-          cd docs/_build/html
-          tar -cvf docs.tar ./*
-
-      - name: Upload docs artifacts
-        if: ${{ steps.tar-docs.outcome == 'success' && !cancelled() }}
-        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
-        with:
-          name: html-docs
-          path: docs/_build/html/docs.tar
-
       # Generate the changelog for releases with the reference build only
       # The changelog is generated by considering all commits from the latest stable previous
       # version (not a release candidate) up to the new upcoming version
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index e8d90e433..e33d26863 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -413,21 +413,6 @@ jobs:
           mkdir -p "${ARTIFACTS_PACKAGED_DIR}"
           echo "ARTIFACTS_PACKAGED_DIR=${ARTIFACTS_PACKAGED_DIR}" >> "$GITHUB_ENV"
 
-      - name: Download Documentation
-        if: ${{ success() && !cancelled() }}
-        id: download-docs
-        uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427
-        with:
-          name: html-docs
-          path: ${{ env.ARTIFACTS_RAW_DIR }}/html_docs/
-
-      - name: Untar docs artifacts
-        if: ${{ success() && !cancelled() }}
-        run: |
-          cd ${{ steps.download-docs.outputs.download-path }}
-          tar -xvf docs.tar
-          rm docs.tar
-
       - name: Download changelog
         if: ${{ success() && !cancelled() }}
         id: download-changelog
@@ -508,60 +493,11 @@ jobs:
           docker run --rm -v "$(pwd)"/docker/release_resources:/data \
           "${PRIVATE_RELEASE_IMG_GIT_TAG}" /bin/bash -c "python ./sanity_check.py"
 
-      - name: Prepare docs push
-        id: docs-push-infos
-        run: |
-          echo "aws-bucket=${{ secrets.AWS_REPO_DOCUMENTATION_BUCKET_NAME }}" >> $GITHUB_OUTPUT
-          echo "aws-distribution=${{ secrets.AWS_REPO_DOCUMENTATION_DISTRIBUTION_ID }}" >> $GITHUB_OUTPUT
-
-      - name: Configure AWS credentials
-        uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
-        with:
-          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
-          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-          aws-region: ${{ secrets.AWS_REGION }}
-
-      - name: Update versions.json for docs
-        if: ${{ success() && !cancelled() }}
-        env:
-          RAW_DOCS_DIR: ${{ steps.download-docs.outputs.download-path }}
-        run: |
-          DOWNLOADED_VERSIONS_JSON_FILE=$(mktemp --suffix=.json)
-          OUTPUT_VERSIONS_JSON_FILE=$(mktemp --suffix=.json)
-          OPTS=""
-          if [[ $IS_LATEST = "true" ]]; then
-              OPTS="${OPTS} --latest "
-          fi
-
-          aws s3api get-object \
-          --bucket ${{ steps.docs-push-infos.outputs.aws-bucket }} \
-          --key concrete-ml/versions.json "${DOWNLOADED_VERSIONS_JSON_FILE}"
-
-          # shellcheck disable=SC2086
-          poetry run python ./script/actions_utils/generate_versions_json.py \
-          --add-version "${{ env.PROJECT_VERSION }}" \
-          --versions-json-file "${DOWNLOADED_VERSIONS_JSON_FILE}" \
-          --output-json "${OUTPUT_VERSIONS_JSON_FILE}" \
-          $OPTS
-
-
-          echo "OUTPUT_VERSIONS_JSON_FILE=${OUTPUT_VERSIONS_JSON_FILE}" >> "$GITHUB_ENV"
-
-          # Copy to docs to keep a version in docs artifacts
-          cp "${OUTPUT_VERSIONS_JSON_FILE}" "${RAW_DOCS_DIR}"/versions.json
-
-      - name: Create ready to upload/packaged artifacts and release body
+      - name: Create release body
         if: ${{ success() && !cancelled() }}
         env:
-          RAW_DOCS_DIR: ${{ steps.download-docs.outputs.download-path }}
           RAW_CHANGELOG_DIR: ${{ steps.download-changelog.outputs.download-path }}
         run: |
-          pushd "${RAW_DOCS_DIR}"
-          zip -r "${ARTIFACTS_PACKAGED_DIR}/html-docs.zip" ./*
-          tar -cvzf "${ARTIFACTS_PACKAGED_DIR}/html-docs.tar.gz" ./*
-          # Remove the versions.json to avoid pushing it to S3 but have it in release artifacts
-          rm versions.json
-          popd
           cp "${RAW_CHANGELOG_DIR}"/* "${ARTIFACTS_PACKAGED_DIR}"
           ls -a "${ARTIFACTS_PACKAGED_DIR}"
 
@@ -601,34 +537,6 @@ jobs:
           -u "${{ secrets.INTERNAL_PYPI_BOT_USERNAME }}" -p "${{ secrets.INTERNAL_PYPI_BOT_PASSWORD }}" \
           --repository-url "${{ secrets.INTERNAL_PYPI_URL }}" "${{ env.ARTIFACTS_PACKAGED_DIR }}"/*.whl
 
-      - name: Push release documentation
-        if: ${{ success() && !cancelled() }}
-        env:
-          AWS_S3_BUCKET: ${{ steps.docs-push-infos.outputs.aws-bucket }}
-          SOURCE_DIR: ${{ steps.download-docs.outputs.download-path }}
-          DEST_DIR: 'concrete-ml/${{ env.PROJECT_VERSION }}'
-        run: |
-          aws s3 sync "${SOURCE_DIR}" s3://"${AWS_S3_BUCKET}/${DEST_DIR}" --delete --acl public-read
-
-      - name: Push release documentation as stable
-        if: ${{ success() && !cancelled() && !fromJSON(env.IS_PRERELEASE) && fromJSON(env.IS_LATEST) }}
-        env:
-          AWS_S3_BUCKET: ${{ steps.docs-push-infos.outputs.aws-bucket }}
-          SOURCE_DIR: ${{ steps.download-docs.outputs.download-path }}
-          DEST_DIR: 'concrete-ml/stable'
-        run: |
-          aws s3 sync "${SOURCE_DIR}" s3://"${AWS_S3_BUCKET}/${DEST_DIR}" --delete --acl public-read
-
-      - name: Invalidate CloudFront Cache for stable
-        if: ${{ success() && !fromJSON(env.IS_PRERELEASE) && fromJSON(env.IS_LATEST) }}
-        env:
-          SOURCE_PATH: "/concrete-ml/stable/*"
-          DISTRIBUTION_ID: ${{ steps.docs-push-infos.outputs.aws-distribution }}
-        run: |
-          aws cloudfront create-invalidation \
-          --distribution-id "${DISTRIBUTION_ID}" \
-          --paths "${SOURCE_PATH}"
-
       - name: Create GitHub release
         if: ${{ success() && !cancelled() }}
         id: create-release
@@ -642,17 +550,6 @@ jobs:
           fail_on_unmatched_files: true
           token: ${{ secrets.BOT_TOKEN }}
 
-      - name: Push updated versions.json
-        if: ${{ success() }}
-        run: |
-          aws s3 cp "${OUTPUT_VERSIONS_JSON_FILE}" \
-          s3://${{ steps.docs-push-infos.outputs.aws-bucket }}/concrete-ml/versions.json \
-          --acl public-read
-
-          aws cloudfront create-invalidation \
-          --distribution-id ${{ steps.docs-push-infos.outputs.aws-distribution }} \
-          --paths /concrete-ml/versions.json
-
       - name: Get release link
         id: get-release-link
         run: |