Skip to content

Commit

Permalink
docs: use RELEASE_TAG env variable for docs version if available
Browse files Browse the repository at this point in the history
  • Loading branch information
henri-hulski committed Apr 23, 2022
1 parent 494314b commit 45707fb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 27 deletions.
51 changes: 29 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
Expand All @@ -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/[email protected]
with:
branch: gh-pages
folder: docs/build
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ dist/
htmlcov/
mezzanine/project_template/static/
/mezzanine/.project
/mezzanine/.pydevproject
/mezzanine/.pydevproject
db.sqlite3
15 changes: 11 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions docs/docs_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}

0 comments on commit 45707fb

Please sign in to comment.