diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..809b6e5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,42 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Publish package +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + architecture: 'x64' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build source and binary distribution package + run: | + python setup.py sdist bdist_wheel --universal + env: + PACKAGE_VERSION: ${{ github.ref }} + + - name: Check distribution package + run: | + twine check dist/* + - name: Publish distribution package + run: | + twine upload dist/* + env: + TWINE_REPOSITORY: ${{ secrets.PYPI_REPOSITORY }} + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TWINE_NON_INTERACTIVE: yes diff --git a/setup.py b/setup.py index 42cd028..65aa8db 100644 --- a/setup.py +++ b/setup.py @@ -1,57 +1,15 @@ import io import os -import sys -from shutil import rmtree +from setuptools import find_packages, setup -from setuptools import find_packages, setup, Command - -VERSION = '1.3.3' here = os.path.abspath(os.path.dirname(__file__)) with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f: README = '\n' + f.read() - -class UploadCommand(Command): - """Support setup.py upload.""" - - description = 'Build and publish the package.' - user_options = [] - - @staticmethod - def status(s): - """Prints things in bold.""" - print('\033[1m{0}\033[0m'.format(s)) - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - try: - self.status('Removing previous builds...') - rmtree(os.path.join(here, 'dist')) - except OSError: - pass - - self.status('Building Source and Wheel (universal) distribution...') - os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable)) - - self.status('Uploading the package to PyPI via Twine...') - os.system('twine upload dist/*') - - self.status('Pushing git tags...') - os.system('git tag {0}'.format(VERSION)) - os.system('git push --tags') - - sys.exit() - - setup( name='django-rest-multitokenauth', - version=VERSION, + version=os.getenv('PACKAGE_VERSION', '0.0.0').replace('refs/tags/', ''), packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]), install_requires=[ 'django-ipware==3.0.*', @@ -83,8 +41,4 @@ def run(self): 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ], - # $ setup.py upload support. - cmdclass={ - 'upload': UploadCommand, - }, )