diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7bfe660 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,27 @@ +name: publish + +on: + release: + types: [released] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install Tools + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Package and Upload + env: + PACKAGE_VERSION: ${{ github.event.release.tag_name }} + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3de109f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: test + +on: + push: + branches-ignore: + - master + pull_request: + branches: [ develop ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.6', '3.7', '3.8'] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Test with tox + run: | + tox -e setup,flake8 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 983c1e8..0e8ced4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,10 +5,6 @@ - python -V - pip install tox coverage: '/TOTAL.+ ([0-9]{1,3}%)/' - artifacts: - paths: - - htmlcov - expire_in: 2 days test:python27: <<: *test-commands diff --git a/drf_simplepermissions/__init__.py b/drf_simplepermissions/__init__.py index a82c9e8..a129c64 100644 --- a/drf_simplepermissions/__init__.py +++ b/drf_simplepermissions/__init__.py @@ -1,5 +1,7 @@ -from .permissions import * # noqa +import os +from .permissions import is_demo +from .permissions import SimplePermissions -__version__ = '0.0.1' +__version__ = os.environ.get('PACKAGE_VERSION', '0.0.0'), __all__ = ['SimplePermissions', 'is_demo'] diff --git a/setup.py b/setup.py index e5c7746..9e2dba5 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,16 @@ +import os from setuptools import setup setup(name='drf-simplepermissions', - version='0.0.4', + version=os.environ.get('PACKAGE_VERSION', '0.0.0'), description='SimplePermissions checks against a list of permissions', - url='https://git.sensson.net/bellmann/python-drf-simplepermissions', + url='https://github.com/bellmann/python-drf-simplepermissions', author='Bellmann BV', - author_email='ton@bellmann.nl', + author_email='opensource@bellmann.nl', packages=['drf_simplepermissions'], install_requires=[ 'django', 'djangorestframework', ], + python_requires='>=3.4', zip_safe=False) diff --git a/tox.ini b/tox.ini index 3e632b4..13e07bc 100644 --- a/tox.ini +++ b/tox.ini @@ -21,4 +21,4 @@ commands = [testenv:flake8] deps = flake8 -commands = flake8 gongchang +commands = flake8 drf_simplepermissions