From fb18986c7ffd3da70d88059b912e780ee4fa298b Mon Sep 17 00:00:00 2001 From: Jorge Martinez Garrido Date: Thu, 24 Nov 2022 17:57:04 +0100 Subject: [PATCH] CI: update workflows --- .github/workflows/ci_cd.yml | 98 +++++++++++++++---------------------- doc/source/conf.py | 9 ++++ 2 files changed, 49 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 7a78d6c6..c66354a9 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -9,8 +9,9 @@ on: - main env: MAIN_PYTHON_VERSION : '3.10' - pyansys-actions: 'pyansys/actions/.github/workflows' - cname: 'sphinxdocs.ansys.com' + PACKAGE_NAME: 'ansys-sphinx-theme' + PACKAGE_NAMESPACE: 'ansys_sphinx_theme' + DOCUMENTATION_CNAME: 'sphinxdocs.ansys.com' jobs: @@ -19,14 +20,16 @@ jobs: runs-on: ubuntu-latest steps: - name: "Run PyAnsys code style checks" - uses: pyansys/actions/code-style@main + uses: pyansys/actions/code-style@v1 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} doc-style: name: Doc style runs-on: ubuntu-latest steps: - name: "Run Ansys documentation style checks" - uses: pyansys/actions/doc-style@main + uses: pyansys/actions/doc-style@v1 with: token: ${{ secrets.GITHUB_TOKEN }} @@ -36,7 +39,9 @@ jobs: needs: doc-style steps: - name: "Run Ansys documentation building action" - uses: pyansys/actions/doc-build@main + uses: pyansys/actions/doc-build@v1 + with: + python-version: ${{ env.MAIN_PYTHON_VERSION }} doc-deploy-development: name: Doc dev version deploy @@ -45,9 +50,9 @@ jobs: needs: doc-build steps: - name: "Deploy developers documentation" - uses: pyansys/actions/doc-deploy-dev@main + uses: pyansys/actions/doc-deploy-dev@v1 with: - cname: ${{ env.cname }} + cname: ${{ env.DOCUMENTATION_CNAME }} token: ${{ secrets.GITHUB_TOKEN }} doc-deploy-stable: @@ -57,67 +62,44 @@ jobs: needs: doc-deploy-development steps: - name: "Deploy stable documentation" - uses: pyansys/actions/doc-deploy-stable@main + uses: pyansys/actions/doc-deploy-stable@v1 with: - cname: ${{ env.cname }} - token: ${{ secrets.GITHUB_TOKEN }} + cname: ${{ env.DOCUMENTATION_CNAME }} + token: ${{ secrets.GITHUB_TOKEN }} + python-version: ${{ env.MAIN_PYTHON_VERSION }} - build: - name: Build + build-library: + name: "Build library" runs-on: ubuntu-latest - needs: [code-style] + needs: doc-deploy-stable steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - name: "Build library source and wheel artifacts" + uses: pyansys/actions/build-library@v1 with: - python-version: 3.9 - - name: Install dependencies - run: | - python -m pip install --upgrade pip pipx - python -m pip install -r requirements/requirements_build.txt - - name: Build wheel and sdist - run: | - python -m build && python -m twine check dist/* - - name: Upload wheel and sdist to artifacts - uses: actions/upload-artifact@v3.1.1 - with: - name: ansys-sphinx-theme - path: dist/ - retention-days: 7 + library-name: ${{ env.PACKAGE_NAME }} release: - name: Release + name: "Release project to private PyPI, public PyPI and GitHub" if: github.event_name == 'push' && contains(github.ref, 'refs/tags') - needs: build + needs: build-library runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v3 - - name: Set up Python - uses: actions/setup-python@v4 + + - name: "Release to the private PyPI repository" + uses: pyansys/actions/release-pypi-private@v1 with: - python-version: 3.9 - - name: Display structure of downloaded files - run: ls -R - - name: Install dependencies - run: | - python -m pip install --upgrade pip twine - - name: Publish to PyPI - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: | - python -m twine upload --skip-existing ./**/*.whl - python -m twine upload --skip-existing ./**/*.tar.gz - - name: Publish to GitHub - uses: softprops/action-gh-release@v1 + library-name: ${{ env.PACKAGE_NAME }} + twine-username: "__token__" + twine-token: ${{ secrets.PYANSYS_PYPI_PRIVATE_PAT }} + + - name: "Release to the public PyPI repository" + uses: pyansys/actions/release-pypi-public@v1 with: - files: | - ./**/*.whl - ./**/*.tar.gz - ./PDF-Documentation/ansys_sphinx_theme.pdf - - name: Release - uses: softprops/action-gh-release@v1 + library-name: ${{ env.PACKAGE_NAME }} + twine-username: "__token__" + twine-token: ${{ secrets.PYPI_TOKEN }} + + - name: "Release to GitHub" + uses: pyansys/actions/release-github@v1 with: - generate_release_notes: true + library-name: ${{ env.PACKAGE_NAME }} diff --git a/doc/source/conf.py b/doc/source/conf.py index b875e05e..820de8e9 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -1,5 +1,7 @@ """Sphinx documentation configuration file.""" + from datetime import datetime +import os from sphinx.builders.latex import LaTeXBuilder @@ -12,6 +14,7 @@ ansys_logo_white, ansys_logo_white_cropped, generate_404, + get_version_match, latex, watermark, ) @@ -21,6 +24,7 @@ copyright = f"(c) {datetime.now().year} ANSYS, Inc. All rights reserved" author = "Ansys Inc." release = version = __version__ +cname = os.getenv("DOCUMENTATION_CNAME", "nocname.com") # use the default ansys logo html_logo = ansys_logo_black @@ -47,6 +51,11 @@ "name": "Changelog", }, ], + "switcher": { + "json_url": f"https://{cname}/release/versions.json", + "version_match": get_version_match(__version__), + }, + "navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"], } html_short_title = html_title = "Ansys Sphinx Theme"