diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..7340e74 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,78 @@ +name: Publish + +on: + push: + branches: [ main, develop ] + tags: ['v*.*.*'] + + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + + workflow_dispatch: + +jobs: + + docs: + + runs-on: ubuntu-20.04 + # This job only runs for pushed tags + #if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + + steps: + + - name: Checkout the repo + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install dependencies + run: | + sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \ + tree \ + doxygen \ + python3-sphinx \ + graphviz + pip install sphinx-multiversion + + - name: Output location + run: | + export OUTPUT_LOCATION="unknown" + echo "Github ref: $GITHUB_REF" + if [[ $GITHUB_REF == refs/heads/develop ]]; then + echo "Branch is develop" + export OUTPUT_LOCATION=develop + elif [[ $GITHUB_REF == refs/heads/main ]]; then + echo "Branch is main" + export OUTPUT_LOCATION=main + elif [[ $GITHUB_REF == refs/heads/* ]]; then + suffix=${GITHUB_REF#"refs/heads/"} + suffix=$(echo $suffix | tr '/' '-') + echo "Branch is $GITHUB_REF; directory will be $suffix" + export OUTPUT_LOCATION=branches/$suffix + elif [[ $GITHUB_REF == refs/tags/* ]]; then + suffix=${GITHUB_REF#"refs/tags/"} + echo "Tag is $GITHUB_REF; directory will be $suffix" + export OUTPUT_LOCATION=tags/$suffix + elif [[ $GITHUB_REF == refs/pull/* ]]; then + suffix=${GITHUB_HEAD_REF#"refs/heads/"} + echo "Branch is $GITHUB_HEAD_REF; directory will be $suffix" + export OUTPUT_LOCATION=branches/$suffix + fi + echo "Output location: $OUTPUT_LOCATION" + # Persist the output location in future steps + echo "OUTPUT_LOCATION=$OUTPUT_LOCATION" >> $GITHUB_ENV + + - name: Build docs + run: | + git fetch -a + sphinx-multiversion --color source build + mv ./build /tmp/build.html + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + branch: gh-pages-test # The branch the action should deploy to. + folder: /tmp/build.html # The folder the action should deploy. +# target-folder: ${{ env.OUTPUT_LOCATION }} + dry-run: false diff --git a/Makefile b/Makefile index 4ab8d13..3bea589 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line. SPHINXOPTS = --color -SPHINXBUILD = sphinx-build +SPHINXBUILD = sphinx-multiversion SOURCEDIR = source BUILDDIR = build diff --git a/source/_templates/versioning.html b/source/_templates/versioning.html new file mode 100644 index 0000000..6f08447 --- /dev/null +++ b/source/_templates/versioning.html @@ -0,0 +1,14 @@ +{% if versions %} +