Skip to content

Commit

Permalink
chore: implement GitHub build process for pypi
Browse files Browse the repository at this point in the history
Merge pull request #12 from d-Rickyy-b/dev
  • Loading branch information
d-Rickyy-b authored Dec 27, 2020
2 parents 4dbb7ee + 0c250e1 commit fd7e45e
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/python-pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflows 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: Upload Python 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.7'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install:
# command to run tests
script:
- python -m compileall ./
- coverage run -m unittest discover -s . -v -p "*_test.py"
- coverage run --omit='*/virtualenv/*,*/site-packages/*' -m unittest discover -s . -v -p "*_test.py"

after_success:
- coveralls
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include LICENSE requirements.txt
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![Build Status](https://travis-ci.com/d-Rickyy-b/pyBrematic.svg?branch=master)](https://travis-ci.com/d-Rickyy-b/pyBrematic) [![Coverage Status](https://coveralls.io/repos/github/d-Rickyy-b/pyBrematic/badge.svg?branch=master)](https://coveralls.io/github/d-Rickyy-b/pyBrematic?branch=master)
[![Build Status](https://travis-ci.com/d-Rickyy-b/pyBrematic.svg?branch=master)](https://travis-ci.com/d-Rickyy-b/pyBrematic)
[![PyPI version](https://badge.fury.io/py/pyBrematic.svg)](https://pypi.org/project/pyBrematic)
[![Coverage Status](https://coveralls.io/repos/github/d-Rickyy-b/pyBrematic/badge.svg?branch=master)](https://coveralls.io/github/d-Rickyy-b/pyBrematic?branch=master)

# pyBrematic
This project offers a home for controlling your remote power outlets (and potentially other stuff) with the Python programming language. With the help of the community we might get other devices working aswell.
Expand Down
1 change: 1 addition & 0 deletions pyBrematic/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.1.0"
68 changes: 58 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,63 @@
# -*- coding: utf-8 -*-
import os
from setuptools import setup, find_packages

packages = find_packages()
setup_path = os.path.dirname(os.path.abspath(__file__))
packages = find_packages(exclude=["tests*"])

setup(name='pyBrematic',
version='1.0',
keywords='python telegram bot api wrapper',
description='Python code for controlling Brematic remote power outlets and potentially other stuff',
url='https://github.com/d-Rickyy-b/pyBrematic',
author='d-Rickyy-b',
author_email='[email protected]',
license='MIT',
with open(os.path.join(setup_path, "README.md"), "r", encoding="utf-8") as file:
readme = file.read()

# Check if we are running on CI
CI = os.environ.get("CI")
if CI:
version = ""
TRAVIS_TAG = os.environ.get("TRAVIS_TAG")
GITHUB_ACTIONS = os.environ.get("GITHUB_ACTIONS")

if TRAVIS_TAG:
print("Running on Travis!")
version = TRAVIS_TAG.replace("v", "")
elif GITHUB_ACTIONS:
print("Running on GitHub Actions!")
GITHUB_REF = os.environ.get("GITHUB_REF")
tag = GITHUB_REF.split("/")[-1]
version = tag.replace("v", "")
else:
# Taken from https://packaging.python.org/guides/single-sourcing-package-version/
version_dict = {}
version_file = os.path.join(setup_path, "pyBrematic", "version.py")
with open(version_file, "r", encoding="utf-8") as file:
exec(file.read(), version_dict)
version = version_dict["__version__"]

print("Building version '{0}' of pyBrematic".format(version))

setup(name="pyBrematic",
version=version,
keywords="python telegram bot api wrapper",
description="Python code for controlling Brematic remote power outlets and potentially other stuff",
long_description=readme,
long_description_content_type="text/markdown",
url="https://github.com/d-Rickyy-b/pyBrematic",
author="d-Rickyy-b",
author_email="[email protected]",
license="MIT",
packages=packages,
zip_safe=False)
include_package_data=True,
zip_safe=False,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet",
"Programming Language :: Python",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
)

0 comments on commit fd7e45e

Please sign in to comment.