Skip to content

Commit

Permalink
Merge pull request #2 from CristianLara/gh-actions-configure
Browse files Browse the repository at this point in the history
[Actions] Update publish website workflow
  • Loading branch information
CristianLara authored Nov 26, 2024
2 parents 8ce96e4 + 70046fc commit 2e68102
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 319 deletions.
79 changes: 39 additions & 40 deletions .github/workflows/deploy_on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,46 @@ on:

jobs:

tests-and-coverage:
name: Test & Coverage
uses: ./.github/workflows/reusable_test.yml
with:
use_latest_pytorch_gpytorch: false
secrets: inherit
# tests-and-coverage:
# name: Test & Coverage
# uses: ./.github/workflows/reusable_test.yml
# with:
# use_latest_pytorch_gpytorch: false
# secrets: inherit

package-deploy-pypi:
name: Package and deploy to pypi.org
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for PyPI OIDC authentication.
needs: tests-and-coverage
steps:
- uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install .[test]
pip install --upgrade build setuptools setuptools_scm wheel
- name: Build packages (wheel and source distribution)
run: |
python -m build --sdist --wheel
- name: Verify packages
run: |
./scripts/verify_py_packages.sh
- name: Deploy to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
# package-deploy-pypi:
# name: Package and deploy to pypi.org
# runs-on: ubuntu-latest
# permissions:
# id-token: write # This is required for PyPI OIDC authentication.
# needs: tests-and-coverage
# steps:
# - uses: actions/checkout@v4
# - name: Fetch all history for all tags and branches
# run: git fetch --prune --unshallow
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"
# - name: Install dependencies
# run: |
# pip install .[test]
# pip install --upgrade build setuptools setuptools_scm wheel
# - name: Build packages (wheel and source distribution)
# run: |
# python -m build --sdist --wheel
# - name: Verify packages
# run: |
# ./scripts/verify_py_packages.sh
# - name: Deploy to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# verbose: true

publish-versioned-website:
name: Publish versioned website
needs: package-deploy-pypi
uses: ./.github/workflows/reusable_website.yml
version-and-publish-website:
# needs: package-deploy-pypi
name: Version and Publish website
uses: ./.github/workflows/publish_website.yml
with:
publish_versioned_website: true
release_tag: ${{ github.event.release.tag_name }}
new_version: ${{ github.event.release.tag_name }}
secrets: inherit
56 changes: 56 additions & 0 deletions .github/workflows/publish_website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish Website

on:
workflow_call:
inputs:
new_version:
required: false
type: string
run_tutorials:
required: false
type: boolean
default: false
workflow_dispatch:
push:
branches: [ main ]


jobs:

publish-website:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install ."[dev, tutorials]"
# - if: ${{ inputs.run_tutorials }}
# name: Run Tutorials
# run: |
# python scripts/run_tutorials.py -w $(pwd)
# - if: ${{ inputs.new_version }}
# name: Create new docusaurus version
# run: |
# git config --global user.name "github-actions[bot]"
# git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

# python3 scripts/convert_ipynb_to_mdx.py --clean
# cd website
# yarn
# yarn docusaurus docs:version ${{ inputs.new_version }}

# git add --all
# git commit -m "Create version ${{ inputs.new_version }} of site in Docusaurus"
# git push --force origin HEAD:main
- name: Build website
run: |
bash scripts/make_docs.sh -b
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
branch: gh-pages # The branch the action should deploy to.
folder: website/build # The folder the action should deploy.
74 changes: 37 additions & 37 deletions scripts/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,58 +37,58 @@ while getopts 'bho' flag; do
esac
done

if [[ $ONLY_DOCUSAURUS == false ]]; then
echo "-----------------------------------"
echo "Generating API reference via Sphinx"
echo "-----------------------------------"
cd sphinx || exit
make html
cd .. || exit
fi
# if [[ $ONLY_DOCUSAURUS == false ]]; then
# echo "-----------------------------------"
# echo "Generating API reference via Sphinx"
# echo "-----------------------------------"
# cd sphinx || exit
# make html
# cd .. || exit
# fi

echo "-----------------------------------"
echo "Getting Docusaurus deps"
echo "-----------------------------------"
cd website || exit
yarn

if [[ $ONLY_DOCUSAURUS == false ]]; then
# run script to parse html generated by sphinx
echo "--------------------------------------------"
echo "Parsing Sphinx docs and moving to Docusaurus"
echo "--------------------------------------------"
cd ..
mkdir -p "website/pages/api/"
# if [[ $ONLY_DOCUSAURUS == false ]]; then
# # run script to parse html generated by sphinx
# echo "--------------------------------------------"
# echo "Parsing Sphinx docs and moving to Docusaurus"
# echo "--------------------------------------------"
# cd ..
# mkdir -p "website/pages/api/"

cwd=$(pwd)
python scripts/parse_sphinx.py -i "${cwd}/sphinx/build/html/" -o "${cwd}/website/pages/api/"
# cwd=$(pwd)
# python scripts/parse_sphinx.py -i "${cwd}/sphinx/build/html/" -o "${cwd}/website/pages/api/"

SPHINX_JS_DIR='sphinx/build/html/_static/'
DOCUSAURUS_JS_DIR='website/static/js/'
# SPHINX_JS_DIR='sphinx/build/html/_static/'
# DOCUSAURUS_JS_DIR='website/static/js/'

mkdir -p $DOCUSAURUS_JS_DIR
# mkdir -p $DOCUSAURUS_JS_DIR

# move JS files from /sphinx/build/html/_static/*:
cp "${SPHINX_JS_DIR}documentation_options.js" "${DOCUSAURUS_JS_DIR}documentation_options.js"
cp "${SPHINX_JS_DIR}doctools.js" "${DOCUSAURUS_JS_DIR}doctools.js"
cp "${SPHINX_JS_DIR}language_data.js" "${DOCUSAURUS_JS_DIR}language_data.js"
cp "${SPHINX_JS_DIR}searchtools.js" "${DOCUSAURUS_JS_DIR}searchtools.js"
# # move JS files from /sphinx/build/html/_static/*:
# cp "${SPHINX_JS_DIR}documentation_options.js" "${DOCUSAURUS_JS_DIR}documentation_options.js"
# cp "${SPHINX_JS_DIR}doctools.js" "${DOCUSAURUS_JS_DIR}doctools.js"
# cp "${SPHINX_JS_DIR}language_data.js" "${DOCUSAURUS_JS_DIR}language_data.js"
# cp "${SPHINX_JS_DIR}searchtools.js" "${DOCUSAURUS_JS_DIR}searchtools.js"

# searchindex.js is not static util
cp "sphinx/build/html/searchindex.js" "${DOCUSAURUS_JS_DIR}searchindex.js"
# # searchindex.js is not static util
# cp "sphinx/build/html/searchindex.js" "${DOCUSAURUS_JS_DIR}searchindex.js"

# copy module sources
cp -r "sphinx/build/html/_sources/" "website/static/_sphinx-sources/"
# # copy module sources
# cp -r "sphinx/build/html/_sources/" "website/static/_sphinx-sources/"

echo "-----------------------------------"
echo "Generating tutorials"
echo "-----------------------------------"
mkdir -p "website/_tutorials"
mkdir -p "website/static/files"
python scripts/parse_tutorials.py -w "${cwd}"
# echo "-----------------------------------"
# echo "Generating tutorials"
# echo "-----------------------------------"
# mkdir -p "website/_tutorials"
# mkdir -p "website/static/files"
# python scripts/parse_tutorials.py -w "${cwd}"

cd website || exit
fi # end of not only Docusaurus block
# cd website || exit
# fi # end of not only Docusaurus block

if [[ $BUILD_STATIC == true ]]; then
echo "-----------------------------------"
Expand Down
Loading

0 comments on commit 2e68102

Please sign in to comment.