Skip to content

Commit 7bbc469

Browse files
authored
Deploy website only when a release is made (#47)
* added setuptools_scm as requirement * get version via setuptools_scm * enable deployment only on releases
1 parent ba7b6f4 commit 7bbc469

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

.github/workflows/docs_build_and_deploy.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ name: Build Sphinx docs and deploy to GitHub Pages
22

33
# Generate the documentation on all merges to main, all pull requests, or by
44
# manual workflow dispatch. The build job can be used as a CI check that the
5-
# docs still build successfully. The deploy job only runs when merging
6-
# to main and actually moves the generated html to the gh-pages branch
7-
# (which triggers a GitHub pages deployment).
5+
# docs still build successfully. The deploy job only runs when a tag is pushed
6+
# (so, when a new release is made).
87
on:
98
push:
109
branches:
@@ -38,7 +37,7 @@ jobs:
3837
needs: build_sphinx_docs
3938
permissions:
4039
contents: write
41-
if: github.event_name == 'push' && github.ref_name == 'main'
40+
if: github.event_name == 'push' && github.ref_type == 'tag'
4241
runs-on: ubuntu-latest
4342
steps:
4443
- uses: neuroinformatics-unit/actions/deploy_sphinx_docs@v2

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ myst-parser
33
nbsphinx
44
numpydoc
55
pydata-sphinx-theme
6+
setuptools-scm
67
sphinx
78
sphinx-design

docs/source/conf.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@
1616

1717

1818
# -- Project information -----------------------------------------------------
19+
import setuptools_scm
1920

2021
project = 'NeuroBlueprint'
2122
copyright = '2022, UCL'
2223
author = 'Neuroinformatics Unit'
2324

24-
# The full version, including alpha/beta/rc tags
25-
release = '0.1.0'
25+
# Retrieve the version number from the package
26+
try:
27+
release = setuptools_scm.get_version(root="../..", relative_to=__file__)
28+
release = release.split(".dev")[0] # remove dev tag and git hash
29+
except LookupError:
30+
# if git is not initialised, still allow local build
31+
# with a dummy version
32+
release = "0.0.0"
2633

2734

2835
# -- General configuration ---------------------------------------------------

0 commit comments

Comments
 (0)