Skip to content

Revive doc-release #40586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
32 changes: 32 additions & 0 deletions .github/workflows/doc-build-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,35 @@ jobs:
with:
name: doc-pdf
path: doc-pdf.zip

#
# On release events
#

- name: Build live doc
if: github.event_name != 'pull_request'
run: |
# Avoid running out of disk space
rm -rf upstream
export SAGE_USE_CDNS=yes
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env/dev
make doc-clean doc-uninstall; make sagemath_doc_html-no-deps
shell: sh .github/workflows/docker-exec-script.sh BUILD /sage {0}

- name: Copy live doc
if: github.event_name != 'pull_request'
run: |
# Reuse doc created previously, which contains pdfs
mv doc livedoc
# We copy everything to a local folder
docker cp --follow-link BUILD:/sage/local/share/doc/sage/html livedoc
docker cp BUILD:/sage/local/share/doc/sage/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
36 changes: 3 additions & 33 deletions .github/workflows/doc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
path: ~/conda_pkgs_dir
key:
${{ runner.os }}-conda-${{ hashFiles('environment-${{ env.PYTHON_VERSION }}-linux.yml') }}

- name: Compiler cache
uses: hendrikmuhs/[email protected]
with:
Expand All @@ -62,7 +62,7 @@ jobs:
channel-priority: true
activate-environment: sage-dev
environment-file: environment-${{ env.PYTHON_VERSION }}-linux.yml

- name: Build Sage
shell: bash -l {0}
run: |
Expand All @@ -74,6 +74,7 @@ jobs:
#
# For pull requests
#

- name: Get workflow run-id
if: github.event_name == 'pull_request'
run: |
Expand Down Expand Up @@ -203,34 +204,3 @@ jobs:
with:
name: doc-${{ github.ref_name }}
path: doc.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

100 changes: 100 additions & 0 deletions .github/workflows/doc-publish-pdf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Publish documentation

on:
workflow_run:
workflows: "Build documentation (PDF)"
types:
- completed

permissions:
statuses: write
checks: write
pull-requests: write


# This workflow runs after doc-build-pdf workflow, taking the
# artifact livedoc and deploying it to a netlify site.
#
# event (triggered doc-build) URL (of the doc deployed to NETLIFY_SITE)
# --------------------------- ---------------------------------
# on push tag https://doc-release--NETLIFY_SITE
#
# where NETLIFY_SITE is presently sagemath.netlify.app for repo sagemath/sage.
#
# This workflow runs only if secrets NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID are set.

jobs:
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: actions/github-script@v6
id: source-run-info
with:
script: |
const runId = context.payload.workflow_run.id;
const { data: run } = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
});
const event = run.event;
const branchName = run.head_branch;

core.setOutput('sourceEvent', event);
core.setOutput('branchName', branchName);
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 (branchName contains the tag)
if: steps.source-run-info.outputs.sourceEvent == 'push' && steps.source-run-info.outputs.branchName != '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'
72 changes: 3 additions & 69 deletions .github/workflows/doc-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish documentation

on:
workflow_run:
workflows: ["Build documentation"]
workflows: "Build documentation"
types:
- completed

Expand All @@ -12,15 +12,14 @@ permissions:
pull-requests: write


# This workflow runs after doc-build workflow, taking the artifact
# (doc/livedoc) and deploying it to a netlify site.
# This workflow runs after doc-build workflow, taking the
# artifact doc and deploying it to a netlify site.
#
# event (triggered doc-build) URL (of the doc deployed to NETLIFY_SITE)
# --------------------------- ---------------------------------
# on pull request https://doc-pr-12345--NETLIFY_SITE
# on push branch develop https://doc-develop--NETLIFY_SITE
# on push tag https://doc-10-4-beta2--NETLIFY_SITE
# on push tag https://doc-release--NETLIFY_SITE
#
# where NETLIFY_SITE is presently sagemath.netlify.app for repo sagemath/sage.
#
Expand Down Expand Up @@ -99,68 +98,3 @@ jobs:
run: |
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'
Loading