Skip to content

Commit

Permalink
Create GitHub action to publish the package to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
pamella committed May 17, 2024
1 parent e8fa44d commit 2f48ada
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release - Publish to PyPI

on:
release:
types: [published]

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
python -m build
twine check dist/*
- name: Publish package
run: twine upload dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: Tests

on: [push, pull_request]

Expand Down
14 changes: 5 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

long_description = ""
try:
from pypandoc import convert

long_description = convert("README.md", "rst")
except ImportError:
print("warning: pypandoc module not found, could not convert Markdown to RST")
with open("README.md") as f:
long_description = f.read()
except FileNotFoundError:
print("warning: README.md not found, could not set long_description")


def get_version(package):
Expand Down Expand Up @@ -57,10 +56,6 @@ def get_package_data(package):


if sys.argv[-1] == "publish":
try:
import pypandoc
except ImportError:
print("pypandoc not installed.\nUse `pip install pypandoc`.\nExiting.")
if os.system("pip freeze | grep twine"):
print("twine not installed.\nUse `pip install twine`.\nExiting.")
sys.exit()
Expand All @@ -81,6 +76,7 @@ def get_package_data(package):
license="MIT",
description="A simple django admin extension that shows when your periodic are going to run next",
long_description=long_description,
long_description_content_type="text/markdown",
author="Vinta Software",
author_email="[email protected]",
packages=get_packages("celerybeat_status"),
Expand Down

0 comments on commit 2f48ada

Please sign in to comment.