Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from soluna-studios/staging
Browse files Browse the repository at this point in the history
Staging PyPI
  • Loading branch information
jaredhendrickson13 authored Aug 15, 2022
2 parents a747dce + 2e6314b commit 40b491d
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 19 deletions.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: PyPI

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/staging-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Staging PyPI

on:
pull_request:
branches: [ "master", "staging" ]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: |
export __MAIL2BEYOND_REVISION__="${GITHUB_RUN_ID}"
python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Mail2Beyond
=========

[![Documentation Build](https://github.com/soluna-studios/mail2beyond/actions/workflows/pages.yml/badge.svg)](https://github.com/soluna-studios/mail2beyond/actions/workflows/pages.yml)
[![PyPI](https://github.com/soluna-studios/mail2beyond/actions/workflows/pypi.yml/badge.svg)](https://github.com/soluna-studios/mail2beyond/actions/workflows/pypi.yml)
[![Documentation Build](https://github.com/soluna-studios/mail2beyond/actions/workflows/documentation.yml/badge.svg)](https://github.com/soluna-studios/mail2beyond/actions/workflows/documentation.yml)
[![Unit Tests](https://github.com/soluna-studios/mail2beyond/actions/workflows/unittest.yml/badge.svg)](https://github.com/soluna-studios/mail2beyond/actions/workflows/unittest.yml)
[![PyLint](https://github.com/soluna-studios/mail2beyond/actions/workflows/pylint.yml/badge.svg)](https://github.com/soluna-studios/mail2beyond/actions/workflows/pylint.yml)
[![CodeQL](https://github.com/soluna-studios/mail2beyond/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/soluna-studios/mail2beyond/actions/workflows/codeql-analysis.yml)
[![CodeQL](https://github.com/soluna-studios/mail2beyond/actions/workflows/codeql.yml/badge.svg)](https://github.com/soluna-studios/mail2beyond/actions/workflows/codeql.yml)

Mail2Beyond is a Python-based SMTP server designed to redirect incoming SMTP messages to upstream APIs such as
Google Chat, Slack, or even your own API! This includes a command line interface (CLI) that can be used to run
Expand Down
3 changes: 3 additions & 0 deletions mail2beyond/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
from . import parsers
from . import tools

# Set the version of this package
__version__ = "0.0.1"

# Don't include tests module in generated documentation.
__pdoc__ = {"tests": False}
2 changes: 1 addition & 1 deletion scripts/mail2beyond
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Mail2BeyondCLI:
parser.add_argument(
'--version', "-V",
action='version',
version='%(prog)s v{version}'.format(version=pkg_resources.require("mail2beyond")[0].version)
version='%(prog)s v{version}'.format(version=mail2beyond.__version__)
)
parser.add_argument(
"--verbose", "--debug", "-v",
Expand Down
59 changes: 44 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
"""Module used to setup and install the mail2beyond package."""

import os
import codecs

from setuptools import setup


def read_me():
def read(rel_path):
"""Reads a specified file."""
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as filepath:
return filepath.read()


def get_readme():
"""Opens the README.md file for this package so it can by used in setup.py."""
# Read the readme file
with open('README.md', encoding="utf-8") as read_me_file:
return read_me_file.read()
return read("README.md")


def get_requirements():
"""Opens the requirements.txt file for this package so it can be used in setup.py."""
reqs = read("requirements.txt").split("\n")

# Remove empty items if any
while "" in reqs:
reqs.remove("")

return reqs


def get_version(rel_path):
"""
Gets the current version of the package. If a __MAIL2BEYOND_REVISION__ environment variable exists, it will
be read and appended to the current package version. This is used to ensure the setup version can always be unique
for PyPI dev builds triggered by CI/CD workflows.
"""
# Variables
revision = ""

def requirements():
"""Opens the requirements.txt file for this package so it can by used in setup.py."""
with open('requirements.txt', encoding="utf-8") as requirements_file:
# Read the requirements file and split string in list by newline
reqs = requirements_file.read().split("\n")
# If a __MAIL2BEYOND_REVISION__ environment variable exists, set it as the dev revision.
if "__MAIL2BEYOND_REVISION__" in os.environ:
revision = "." + os.environ.get("__MAIL2BEYOND_REVISION__")

# Remove empty items if any
while "" in reqs:
reqs.remove("")
# Otherwise, look for the version in the package.
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1] + revision

return reqs
raise RuntimeError("Unable to find version string.")


setup(
Expand All @@ -31,12 +60,12 @@ def requirements():
license="MIT",
description="A Python based SMTP server package and CLI that redirects incoming SMTP messages to upstream APIs like"
" Google Chat, Slack and more!.",
long_description=read_me(),
long_description=get_readme(),
long_description_content_type="text/markdown",
version="1.0.0",
version=get_version("mail2beyond/__init__.py"),
scripts=['scripts/mail2beyond'],
packages=["mail2beyond", "mail2beyond.connectors", "mail2beyond.parsers"],
install_requires=requirements(),
install_requires=get_requirements(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit 40b491d

Please sign in to comment.