kopia lustrzana https://github.com/thinkst/zippy
Add auto publishing to pypi
rodzic
41d5d9533f
commit
8db944015d
|
@ -0,0 +1,45 @@
|
|||
name: Publish to PyPI
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
jobs:
|
||||
pypi-publish:
|
||||
name: Upload release to PyPI
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: release
|
||||
url: https://pypi.org/p/thinkst-zippy
|
||||
permissions:
|
||||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
||||
steps:
|
||||
# retrieve your distributions here
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v3
|
||||
- name: "Check out repository code"
|
||||
uses: "actions/checkout@v3"
|
||||
- name: Install setuptools
|
||||
run: pip3 install setuptools>=63.2.0
|
||||
- name: Install wheel
|
||||
run: pip3 install wheel
|
||||
- name: Create package
|
||||
run: python3 setup.py sdist
|
||||
- name: check version matches tag
|
||||
run: |
|
||||
python3 -m pip install dist/*
|
||||
version_to_release=$(python -c "import zippy; print(zippy.__version__)")
|
||||
tag_name="${{ github.event.release.tag_name }}"
|
||||
tag_name_without_v="${tag_name#v}"
|
||||
if [[ "$version_to_release" == "$tag_name_without_v" ]]; then
|
||||
echo "Versions match - may it be a great release"
|
||||
exit 0
|
||||
else
|
||||
echo "Versions do not match - not publishing"
|
||||
echo "zippy version is: $version_to_release"
|
||||
echo "Git tag is: $tag_name -> $tag_name_without_v"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Publish package distributions to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
25
setup.py
25
setup.py
|
@ -1,8 +1,29 @@
|
|||
from setuptools import setup
|
||||
import codecs
|
||||
import os.path
|
||||
|
||||
def read(rel_path):
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
with codecs.open(os.path.join(here, rel_path), "r") as fp:
|
||||
return fp.read()
|
||||
|
||||
|
||||
def get_version(rel_path):
|
||||
"""
|
||||
Reading the package version dynamically.
|
||||
https://packaging.python.org/en/latest/guides/single-sourcing-package-version/
|
||||
"""
|
||||
for line in read(rel_path).splitlines():
|
||||
if line.startswith("__version__"):
|
||||
delim = '"' if '"' in line else "'"
|
||||
return line.split(delim)[1]
|
||||
else:
|
||||
raise RuntimeError("Unable to find version string.")
|
||||
|
||||
|
||||
setup(
|
||||
name='ZipPy setup file',
|
||||
version='0.1.2',
|
||||
name='thinkst-zippy',
|
||||
version=get_version("zippy/__init__.py"),
|
||||
packages=['zippy'],
|
||||
package_data={"": ["*.txt"]},
|
||||
entry_points={
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from .zippy import *
|
||||
__version__ = "0.1.3"
|
Ładowanie…
Reference in New Issue