Skip to content

Commit

Permalink
Merge pull request #20 from anx-mfischer/SIANXKE-154-add-publish-action
Browse files Browse the repository at this point in the history
replace upload command with github publish action
  • Loading branch information
nezhar authored Nov 5, 2021
2 parents 8386e6f + 6e2fad3 commit a2f5d39
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 48 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 2 additions & 48 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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.*',
Expand Down Expand Up @@ -83,8 +41,4 @@ def run(self):
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
# $ setup.py upload support.
cmdclass={
'upload': UploadCommand,
},
)

0 comments on commit a2f5d39

Please sign in to comment.