Skip to content

Commit

Permalink
auto-publish to pypi workflow corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Fabbri committed Aug 29, 2022
1 parent 46c8556 commit adf7480
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
38 changes: 22 additions & 16 deletions .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
name: Publish Python distributions to PyPI
# Reference for this action:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
name: Publish to PyPI

# Only trigger, when the build CI workflow succeeded
on:
workflow_run:
workflows: ["CI"]
types:
- completed
release:
types: [ published ]

permissions:
contents: read

jobs:
deploy:
name: Build and publish Python distributions to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
if: startsWith(github.ref, 'refs/tags') # Only runs if commit is tagged
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
pip install setuptools wheel
- name: Build package
run: python setup.py sdist bdist_wheel

- name: Publish package
# GitHub recommends pinning 3rd party actions to a commit SHA.
uses: pypa/gh-action-pypi-publish@37f50c210e3d2f9450da2cd423303d6a14a6e29f
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion iblutil/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.3.2"
__version__ = "1.3.3"
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
from setuptools import setup, find_packages
import sys
from pathlib import Path

from setuptools import setup, find_packages

CURRENT_DIRECTORY = Path(__file__).parent.absolute()

CURRENT_PYTHON = sys.version_info[:2]
REQUIRED_PYTHON = (3, 8)
if CURRENT_PYTHON < REQUIRED_PYTHON:
sys.stderr.write("""
VER_ERR_MSG = """
==========================
Unsupported Python version
==========================
This version of iblutil requires Python {}.{}, but you're trying to
install it on Python {}.{}.
""".format(*(REQUIRED_PYTHON + CURRENT_PYTHON)))
"""
if CURRENT_PYTHON < REQUIRED_PYTHON:
sys.stderr.write(VER_ERR_MSG.format(*REQUIRED_PYTHON + CURRENT_PYTHON))
sys.exit(1)

with open('README.md', 'r') as f:
with open("README.md", "r") as f:
long_description = f.read()

with open('requirements.txt') as f:
with open("requirements.txt") as f:
require = [x.strip() for x in f.readlines() if not x.startswith('git+')]


Expand Down

0 comments on commit adf7480

Please sign in to comment.