From 8c341ccf0a293d6def06abae82347a1a9a6aef98 Mon Sep 17 00:00:00 2001 From: yelinz Date: Wed, 19 Apr 2023 11:15:53 +0200 Subject: [PATCH] feat: add pypi deployment worklow --- .github/workflows/pypi.yml | 35 +++++++++++++++++++++++++++++++ MANIFEST.in | 5 +++++ alexandria/settings/__init__.py | 2 +- alexandria/settings/alexandria.py | 10 +++++++-- alexandria/settings/django.py | 9 +++++--- 5 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pypi.yml create mode 100644 MANIFEST.in diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 00000000..5d2f7307 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,35 @@ +name: PyPI + +on: + release: + types: [created] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Install poetry + run: pipx install poetry + + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: "3.8" + cache: "poetry" + + - name: Install dependencies + run: | + python -m pip install -U twine + poetry install + + - name: Build package + run: poetry build + + - name: Upload to PyPI + run: twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + TWINE_NON_INTERACTIVE: true \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..d28051af --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include CHANGELOG.md +include LICENSE +recursive-include LICENSES * +global-exclude *.py[co] +global-exclude __pycache__ \ No newline at end of file diff --git a/alexandria/settings/__init__.py b/alexandria/settings/__init__.py index 0a85665f..d74b912b 100644 --- a/alexandria/settings/__init__.py +++ b/alexandria/settings/__init__.py @@ -1 +1 @@ -from .django import * \ No newline at end of file +from .django import * # noqa diff --git a/alexandria/settings/alexandria.py b/alexandria/settings/alexandria.py index e8f0ca4b..1880e224 100644 --- a/alexandria/settings/alexandria.py +++ b/alexandria/settings/alexandria.py @@ -1,10 +1,16 @@ +""" +This settings module only contains alexandria specific settings. + +It's imported by the main alexandria settings and is intended to also be used by third party +applications integrating alexandria. +""" + import os -import re import environ env = environ.Env() -django_root = environ.Path(__file__) - 2 +django_root = environ.Path(__file__) - 3 ENV_FILE = env.str("ENV_FILE", default=django_root(".env")) if os.path.exists(ENV_FILE): diff --git a/alexandria/settings/django.py b/alexandria/settings/django.py index 15ecab7a..d475637b 100644 --- a/alexandria/settings/django.py +++ b/alexandria/settings/django.py @@ -3,8 +3,7 @@ from django.conf import global_settings from .alexandria import * # noqa -from .alexandria import default, django_root, env, environ - +from .alexandria import default, env, environ SECRET_KEY = env.str("SECRET_KEY", default=default("uuuuuuuuuu")) DEBUG = env.bool("DEBUG", default=default(True, False)) @@ -22,7 +21,7 @@ "alexandria.core.apps.DefaultConfig", ] -if ENV == "dev": +if ENV == "dev": # noqa INSTALLED_APPS.append("django_extensions") MIDDLEWARE = [ @@ -118,6 +117,10 @@ def parse_languages(languages): "TEST_REQUEST_DEFAULT_FORMAT": "vnd.api+json", } +JSON_API_FORMAT_FIELD_NAMES = "dasherize" +JSON_API_FORMAT_TYPES = "dasherize" +JSON_API_PLURALIZE_TYPES = True + # Anonymous writing ALLOW_ANONYMOUS_WRITE = env.bool("ALLOW_ANONYMOUS_WRITE", default=False)