diff --git a/.github/workflows/docs_build_and _deploy.yml b/.github/workflows/docs_build_and _deploy.yml index f24a625..2898532 100644 --- a/.github/workflows/docs_build_and _deploy.yml +++ b/.github/workflows/docs_build_and _deploy.yml @@ -16,6 +16,16 @@ on: workflow_dispatch: jobs: + setup: + name: Setup Environment + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install python-cookiecutter + run: pip install python-cookiecutter + linting: # scheduled workflows should not run on forks if: (${{ github.event_name == 'schedule' }} && ${{ github.repository_owner == 'neuroinformatics-unit' }} && ${{ github.ref == 'refs/heads/main' }}) || (${{ github.event_name != 'schedule' }}) @@ -23,18 +33,40 @@ jobs: steps: - uses: neuroinformatics-unit/actions/lint@v2 - build_sphinx_docs: - name: Build Sphinx Docs + - name: Install python-cookiecutter + run: pip install python-cookiecutter + + build_sphinx_docs_main: + name: Build Sphinx Docs (Main Branch) runs-on: ubuntu-latest steps: + # Using the main branch version of the action from the NIU repo - uses: neuroinformatics-unit/actions/build_sphinx_docs@main with: python-version: 3.12 use-make: true + # Debugging: Verify installed version + - name: Check python-cookiecutter version (Main) + run: python -c "from importlib.metadata import version; print('python-cookiecutter', version('python-cookiecutter'))" + + build_sphinx_docs_commit: + name: Build Sphinx Docs (Commit Hash) + runs-on: ubuntu-latest + steps: + # Using the commit hash version of the action from the NIU repo PR Add fetch tags as an input #81 smg/fetch-tags + - uses: neuroinformatics-unit/actions/build_sphinx_docs@fe6e2b549ec67a5077c319f5a51d57b258b043af + with: + python-version: 3.12 + use-make: true + + # Debugging: Verify installed version + - name: Check python-cookiecutter version (Commit) + run: python -c "from importlib.metadata import version; print('python-cookiecutter', version('python-cookiecutter'))" + deploy_sphinx_docs: name: Deploy Sphinx Docs - needs: build_sphinx_docs + needs: build_sphinx_docs_commit permissions: contents: write # Deploy on: main branch pushes OR tags OR manual trigger diff --git a/docs/source/conf.py b/docs/source/conf.py index 24fe6a6..4578c50 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,15 +1,16 @@ # conf.py # Configuration file for the Sphinx documentation builder. -import setuptools_scm +from importlib.metadata import version as get_version project = "python-cookiecutter" copyright = "2025, University College London" author = "Neuroinformatics Unit" try: - full_version = setuptools_scm.get_version(root="../..", relative_to=__file__) + # full_version = setuptools_scm.get_version(root="../..", relative_to=__file__) + release = get_version("python-cookiecutter") # Splitting the release on '+' to remove the commit hash - release = full_version.split('+', 1)[0] + release = release.split('+', 1)[0] except LookupError: # if git is not initialised, still allow local build # with a dummy version @@ -84,7 +85,7 @@ }, ], "logo": { - "text": f"{project}", + "text": f"{project} v{release}", }, "footer_start": ["footer_start"], "footer_end": ["footer_end"],