publish-api-and-stubs #1216
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: publish-api-and-stubs | |
on: | |
schedule: | |
- cron: "0 1 * * *" # Run at 1 AM UTC | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
permissions: | |
contents: read | |
env: | |
PYTHON_VERSION: "3.11" | |
jobs: | |
build: | |
name: Build UPBGE | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Setup APT | |
run: | | |
sudo curl https://raw.githubusercontent.com/UPBGE/upbge/master/.github/workflows/01lunar.list \ | |
-o /etc/apt/sources.list.d/01lunar.list && \ | |
sudo curl https://raw.githubusercontent.com/UPBGE/upbge/master/.github/workflows/01ubuntu \ | |
-o /etc/apt/apt.conf.d/01ubuntu | |
# We downgrade libgbm1 & libglapi-mesa to fix libegl-mesa0 installation | |
- name: Install Tools | |
run: | | |
sudo apt update && \ | |
sudo apt dist-upgrade && \ | |
sudo apt --allow-downgrades install libgbm1=23.0.4-0ubuntu1~23.04.1 && \ | |
sudo apt --allow-downgrades install libglapi-mesa=23.0.4-0ubuntu1~23.04.1 && \ | |
sudo apt install -y build-essential cmake libembree-dev libavutil-dev \ | |
libxi-dev libxxf86vm-dev libboost-dev libboost-locale-dev libgl1-mesa-dev \ | |
libavformat-dev libswscale-dev libavdevice-dev libblas3 libopenimageio-dev \ | |
libzstd-dev libopenimageio-dev libfreetype-dev libepoxy-dev libdecor-0-dev | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '${{env.PYTHON_VERSION}}' | |
- name: Install Python Dependencies | |
run: | | |
curl https://bootstrap.pypa.io/get-pip.py | python && \ | |
python -m pip install numpy requests cython | |
- name: Setup Python Path | |
run: | | |
sudo sh -c "echo '$pythonLocation/lib' >> /etc/ld.so.conf.d/python.conf" && \ | |
sudo ldconfig | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
repository: "UPBGE/upbge" | |
ref: "master" | |
path: "upbge" | |
- name: Checkout addons | |
uses: actions/checkout@v3 | |
with: | |
repository: "UPBGE/blender-addons" | |
ref: "master" | |
path: "blender-addons" | |
- name: Checkout addons-contrib | |
run: git clone --depth=1 https://projects.blender.org/blender/blender-addons-contrib.git | |
- name: Checkout translations | |
run: git clone --depth=1 https://projects.blender.org/blender/blender-translations.git | |
- name: Checkout dev-tools | |
run: git clone --depth=1 https://projects.blender.org/blender/blender-dev-tools.git | |
- name: Configure CMake | |
run: | | |
cmake -S upbge -B build \ | |
-C upbge/build_files/cmake/config/blender_release.cmake \ | |
-DWITH_GAMEENGINE=ON \ | |
-DWITH_PLAYER=OFF \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DWITH_INSTALL_PORTABLE=ON \ | |
-DWITH_MOD_OCEANSIM=OFF \ | |
-DWITH_CYCLES=OFF \ | |
-DWITH_LIBMV=OFF \ | |
-DWITH_LIBMV_SCHUR_SPECIALIZATIONS=OFF \ | |
-DWITH_HYDRA=OFF \ | |
-DWITH_VULKAN_BACKEND=OFF \ | |
-DWITH_GHOST_WAYLAND=OFF \ | |
-DPYTHON_VERSION=${{env.PYTHON_VERSION}} | |
- name: Build UPBGE | |
run: make -C build -j `nproc` | |
- name: Copy Release Scripts | |
run: make -C build install | |
- name: Archive Build | |
if: ${{ !env.ACT }} | |
run: tar zcvf build.tar.gz build | |
- name: Upload Build | |
if: ${{ !env.ACT }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: blender | |
path: build.tar.gz | |
retention-days: 3 | |
publish_api: | |
name: Publish API Documentation | |
runs-on: ubuntu-22.04 | |
needs: [build] | |
steps: | |
- name: Download Build | |
if: ${{ !env.ACT }} | |
uses: actions/[email protected] | |
with: | |
name: blender | |
- name: Extract Build | |
if: ${{ !env.ACT }} | |
run: tar zxvf build.tar.gz | |
- name: Setup APT | |
run: | | |
sudo curl https://raw.githubusercontent.com/UPBGE/upbge/master/.github/workflows/01lunar.list \ | |
-o /etc/apt/sources.list.d/01lunar.list && \ | |
sudo curl https://raw.githubusercontent.com/UPBGE/upbge/master/.github/workflows/01ubuntu \ | |
-o /etc/apt/apt.conf.d/01ubuntu | |
- name: Install Tools | |
run: | | |
sudo apt update && \ | |
sudo apt dist-upgrade && \ | |
sudo apt install -y libxi6 libxxf86vm1 libxfixes3 libgl1 libtbb12 libavutil57 \ | |
libavformat59 libavdevice59 libboost-locale1.74.0 libopenimageio-dev | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '${{env.PYTHON_VERSION}}' | |
- name: Install Python Dependencies | |
run: | | |
curl https://bootstrap.pypa.io/get-pip.py | python && \ | |
python -m pip install sphinx sphinx-rtd-theme yapf tqdm numpy | |
- name: Setup Python Path | |
run: | | |
sudo sh -c "echo '$pythonLocation/lib' >> /etc/ld.so.conf.d/python.conf" && \ | |
sudo ldconfig | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
with: | |
repository: "UPBGE/upbge" | |
ref: "master" | |
path: "upbge" | |
- name: Prepare API Documentation | |
working-directory: build | |
run: | | |
rm -Rf bin/4.0/python && \ | |
bin/blender --python-use-system-env --background -noaudio --factory-startup \ | |
--python ../upbge/doc/python_api/sphinx_doc_gen.py -- \ | |
--output "${{ github.workspace }}/python_api" | |
- name: Build API Documentation | |
working-directory: python_api | |
run: | | |
sphinx-build -b html -j auto sphinx-in upbge-api-reference && \ | |
rm -Rf upbge-api-reference/.doctrees && \ | |
zip -r upbge-api-reference/upbge-api-reference.zip upbge-api-reference | |
- name: Publish to UPBGE | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
external_repository: UPBGE/UPBGE-API | |
publish_branch: master | |
publish_dir: python_api/upbge-api-reference | |
deploy_key: ${{ secrets.APIDOCS_DEPLOY_KEY }} | |
- name: Archive Documents | |
if: ${{ !env.ACT }} | |
run: tar zcvf apidocs.tar.gz python_api | |
- name: Upload Documents | |
if: ${{ !env.ACT }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: apidocs | |
path: apidocs.tar.gz | |
retention-days: 3 | |
publish_stubs: | |
name: Publish API Stubs | |
runs-on: ubuntu-22.04 | |
needs: [publish_api] | |
steps: | |
- name: Download Build | |
if: ${{ !env.ACT }} | |
uses: actions/[email protected] | |
with: | |
name: blender | |
- name: Extract Build | |
if: ${{ !env.ACT }} | |
run: tar zxvf build.tar.gz | |
- name: Download Documents | |
if: ${{ !env.ACT }} | |
uses: actions/[email protected] | |
with: | |
name: apidocs | |
- name: Extract Documents | |
if: ${{ !env.ACT }} | |
run: tar zxvf apidocs.tar.gz | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '${{env.PYTHON_VERSION}}' | |
- name: Install Python Dependencies | |
run: | | |
curl https://bootstrap.pypa.io/get-pip.py | python && \ | |
python -m pip install bpystubgen | |
- name: Build API Stubs | |
working-directory: python_api | |
run: | | |
python -m bpystubgen --quiet sphinx-in upbge-stub && \ | |
curl https://raw.githubusercontent.com/mysticfall/bpystubgen/main/package/setup.py -o upbge-stub/setup.py && \ | |
curl https://raw.githubusercontent.com/mysticfall/bpystubgen/main/package/README.md -o upbge-stub/README.md | |
- name: Build Python Package | |
working-directory: python_api/upbge-stub | |
run: | | |
sed -i "s/#APP_NAME#/upbge/g" setup.py && \ | |
sed -i "s/#APP_VERSION#/0.3.1/g" setup.py && \ | |
sed -i "s/#BUILD_NUMBER#/${{ github.run_id }}/g" setup.py && \ | |
python setup.py sdist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} | |
packages-dir: python_api/upbge-stub/dist | |
skip-existing: true | |