From 45707fb9f95e209cf2aada46ddba716ba641a546 Mon Sep 17 00:00:00 2001 From: Henri Hulski Date: Thu, 21 Apr 2022 13:30:27 +0200 Subject: [PATCH] docs: use RELEASE_TAG env variable for docs version if available --- .github/workflows/main.yml | 51 ++++++++++++++++++++++---------------- .gitignore | 3 ++- docs/conf.py | 15 ++++++++--- docs/docs_settings.py | 7 ++++++ 4 files changed, 49 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5f25b9ac..2c310eed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -65,32 +65,11 @@ jobs: - name: Lint run: tox -e package -e lint -e pyupgrade - # Build and deploy docs - docs: - if: github.ref == 'refs/heads/stable' - name: Build and deploy docs - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - uses: actions/setup-python@v2 - with: - python-version: 3.9 - - name: Install deps - run: pip install -e . && pip install sphinx - - name: Build docs - run: sphinx-build -b html docs docs/build && touch docs/build/.nojekyll - - name: Deploy docs - uses: JamesIves/github-pages-deploy-action@v4.3.0 - with: - branch: gh-pages - folder: docs/build - # Create a new semantic release # Only runs on the original repo, not forks release: if: github.repository_owner == 'stephenmcd' - needs: [test, lint, docs] + needs: [test, lint] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -109,3 +88,31 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + + # Build and deploy docs + docs: + if: github.ref == 'refs/heads/stable' + needs: release + name: build and deploy docs + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install deps + run: pip install -e . && pip install sphinx + - uses: actions-ecosystem/action-get-latest-tag@v1 + id: get-latest-tag + with: + semver_only: true + - name: Get release tag + run: echo "RELEASE_TAG=${{ steps.get-latest-tag.outputs.tag }}" >> $GITHUB_ENV + - name: Build docs + run: sphinx-build -b html docs docs/build && touch docs/build/.nojekyll + - name: Deploy docs + uses: JamesIves/github-pages-deploy-action@v4.3.0 + with: + branch: gh-pages + folder: docs/build diff --git a/.gitignore b/.gitignore index 250a5fc6..9e7f9ee0 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ dist/ htmlcov/ mezzanine/project_template/static/ /mezzanine/.project -/mezzanine/.pydevproject \ No newline at end of file +/mezzanine/.pydevproject +db.sqlite3 diff --git a/docs/conf.py b/docs/conf.py index 3181fed1..6e459019 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -79,10 +79,17 @@ # |version| and |release|, also used in various other places throughout the # built documents. # -# The short X.Y version. -version = cartridge.__version__ -# The full version, including alpha/beta/rc tags. -release = cartridge.__version__ +release_tag = os.environ.get("RELEASE_TAG") +if release_tag: + # The full version, including alpha/beta/rc tags. + release = release_tag[1:] + # The short X.Y version. + version = release.rsplit(".", 1)[0] +else: + # The full version, including alpha/beta/rc tags. + release = cartridge.__version__ + # The short X.Y version. + version = release.rsplit("dev", 1)[0] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/docs_settings.py b/docs/docs_settings.py index 7176be24..d9e31c49 100644 --- a/docs/docs_settings.py +++ b/docs/docs_settings.py @@ -12,3 +12,10 @@ characters = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)" SECRET_KEY = "".join([choice(characters) for i in range(50)]) + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": "db.sqlite3", + } +}