Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 38 additions & 47 deletions .github/workflows/doc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ jobs:
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
export CC="ccache $CC"
export CXX="ccache $CXX"
pip install --no-build-isolation --config-settings=builddir=builddir --editable . -v
pip install --no-build-isolation --config-settings=builddir=builddir . -v

#
# For pull requests
#
- name: Get workflow run-id
id: get_run_id
if: github.event_name == 'pull_request'
run: |
RESPONSE=$(curl -s -L \
Expand All @@ -87,8 +86,7 @@ jobs:
echo "RUN_ID=$RUN_ID" >> $GITHUB_ENV

- name: Download old doc
id: download-doc
if: steps.get_run_id.outcome == 'success'
if: github.event_name == 'pull_request'
uses: actions/download-artifact@v4
with:
name: doc-develop
Expand All @@ -97,8 +95,7 @@ jobs:
run-id: ${{ env.RUN_ID }}

- name: Store old doc
id: worktree
if: steps.download-doc.outcome == 'success'
if: github.event_name == 'pull_request'
shell: bash -l {0}
run: |
git config --global --add safe.directory $(pwd)
Expand Down Expand Up @@ -137,8 +134,6 @@ jobs:
fi

- name: Build documentation
id: docbuild
if: steps.worktree.outcome == 'success'
shell: bash -l {0}
run: |
meson compile -C builddir doc-html
Expand All @@ -147,14 +142,13 @@ jobs:
SAGE_DOCBUILD_OPTS: "--include-tests-blocks"

- name: Copy doc
id: copy
if: steps.docbuild.outcome == 'success'
run: |
set -ex
# Remove any existing html directory before copying a new one
if [ -d "doc/html" ]; then
rm -rf doc/html
fi
mkdir -p doc
cp -r builddir/src/doc/* doc/
# Check if we are on pull request event
PR_NUMBER=""
Expand Down Expand Up @@ -193,53 +187,50 @@ jobs:
zip -r doc.zip doc

- name: Upload doc
id: upload
if: steps.copy.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: doc
path: doc.zip

#
# On release events
#

- name: Upload doc-develop
# artifact doc-develop is used for doc build on pull request event
id: upload-push
if: steps.copy.outcome == 'success' && github.event_name == 'push'
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: doc-${{ github.ref_name }}
path: doc.zip

#
# On release tag event
#

- name: Build live doc
id: buildlivedoc
if: startsWith(github.ref, 'refs/tags/')
shell: bash -l {0}
run: |
meson compile -C builddir doc-html
env:
SAGE_USE_CDNS: yes
SAGE_LIVE_DOC: yes
SAGE_JUPYTER_SERVER: binder:sagemath/sage-binder-env/dev
SAGE_DOCBUILD_OPTS: "--include-tests-blocks"

- name: Copy live doc
id: copylivedoc
if: steps.buildlivedoc.outcome == 'success'
run: |
mkdir -p ./livedoc
# We copy everything to a local folder
cp -r builddir/src/doc/html livedoc/
cp -r builddir/src/doc/pdf livedoc/
cp builddir/src/doc/index.html livedoc/
zip -r livedoc.zip livedoc

- name: Upload live doc
if: steps.copylivedoc.outcome == 'success'
uses: actions/upload-artifact@v4
with:
name: livedoc
path: livedoc.zip
# The following fails randomly
# - name: Build live doc
# if: github.event_name != 'pull_request'
# shell: bash -l {0}
# run: |
# # Remove previous doc build
# rm -rf builddir/src/doc
# meson compile -C builddir doc-html
# env:
# SAGE_USE_CDNS: yes
# SAGE_LIVE_DOC: yes
# SAGE_JUPYTER_SERVER: binder:sagemath/sage-binder-env/dev
# SAGE_DOCBUILD_OPTS: "--include-tests-blocks"

# - name: Copy live doc
# if: github.event_name != 'pull_request'
# run: |
# mkdir -p ./livedoc
# # We copy everything to a local folder
# cp -r builddir/src/doc/html livedoc/
# cp builddir/src/doc/index.html livedoc/
# zip -r livedoc.zip livedoc

# - name: Upload live doc
# if: github.event_name != 'pull_request'
# uses: actions/upload-artifact@v4
# with:
# name: livedoc
# path: livedoc.zip

128 changes: 64 additions & 64 deletions .github/workflows/doc-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,67 +100,67 @@ jobs:
echo "::notice::The documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}"
if: steps.download-doc.outcome == 'success'

publish-live-doc:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
env:
CAN_DEPLOY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' && secrets.NETLIFY_SITE_ID != '' }}
steps:
- name: Get information about workflow origin
uses: potiuk/get-workflow-origin@v1_5
id: source-run-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
if: env.CAN_DEPLOY == 'true'

- name: Download live doc
id: download-doc
uses: actions/download-artifact@v4
with:
name: livedoc
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ github.event.workflow_run.id }}
# if the doc was built for tag push (targetBranch contains the tag)
if: steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch != 'develop'

- name: Extract live doc
run: unzip livedoc.zip -d livedoc
if: steps.download-doc.outcome == 'success'

- name: Create _headers file for permissive CORS
run: |
cat <<EOF > livedoc/livedoc/_headers
/*
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: Content-Type
EOF
if: steps.download-doc.outcome == 'success'

- name: Deploy to netlify with doc-TAG alias
id: deploy-netlify
uses: netlify/actions/cli@master
with:
args: deploy --dir=livedoc/livedoc --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_MESSAGE: doc-${{ steps.source-run-info.outputs.targetBranch }}
NETLIFY_ALIAS: doc-${{ steps.source-run-info.outputs.targetBranch }}
if: steps.download-doc.outcome == 'success'

- name: Deploy to netlify with doc-release alias
uses: netlify/actions/cli@master
with:
args: deploy --dir=livedoc/livedoc --message doc-release --alias doc-release
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
if: steps.download-doc.outcome == 'success'

- name: Report deployment url
run: |
echo "::notice::The live documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}"
if: steps.download-doc.outcome == 'success'
# publish-live-doc:
# runs-on: ubuntu-latest
# if: github.event.workflow_run.conclusion == 'success'
# env:
# CAN_DEPLOY: ${{ secrets.NETLIFY_AUTH_TOKEN != '' && secrets.NETLIFY_SITE_ID != '' }}
# steps:
# - name: Get information about workflow origin
# uses: potiuk/get-workflow-origin@v1_5
# id: source-run-info
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# sourceRunId: ${{ github.event.workflow_run.id }}
# if: env.CAN_DEPLOY == 'true'

# - name: Download live doc
# id: download-doc
# uses: actions/download-artifact@v4
# with:
# name: livedoc
# github-token: ${{ secrets.GITHUB_TOKEN }}
# repository: ${{ github.repository }}
# run-id: ${{ github.event.workflow_run.id }}
# # if the doc was built for tag push (targetBranch contains the tag)
# if: steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.targetBranch != 'develop'

# - name: Extract live doc
# run: unzip livedoc.zip -d livedoc
# if: steps.download-doc.outcome == 'success'

# - name: Create _headers file for permissive CORS
# run: |
# cat <<EOF > livedoc/livedoc/_headers
# /*
# Access-Control-Allow-Origin: *
# Access-Control-Allow-Methods: GET
# Access-Control-Allow-Headers: Content-Type
# EOF
# if: steps.download-doc.outcome == 'success'

# - name: Deploy to netlify with doc-TAG alias
# id: deploy-netlify
# uses: netlify/actions/cli@master
# with:
# args: deploy --dir=livedoc/livedoc --message ${NETLIFY_MESSAGE} --alias ${NETLIFY_ALIAS}
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# NETLIFY_MESSAGE: doc-${{ steps.source-run-info.outputs.targetBranch }}
# NETLIFY_ALIAS: doc-${{ steps.source-run-info.outputs.targetBranch }}
# if: steps.download-doc.outcome == 'success'

# - name: Deploy to netlify with doc-release alias
# uses: netlify/actions/cli@master
# with:
# args: deploy --dir=livedoc/livedoc --message doc-release --alias doc-release
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# if: steps.download-doc.outcome == 'success'

# - name: Report deployment url
# run: |
# echo "::notice::The live documentation has been deployed - ${{ steps.deploy-netlify.outputs.NETLIFY_URL }}"
# if: steps.download-doc.outcome == 'success'
Loading
Loading