From 66bbbda56d00ac78397709094f611ac1d43a9393 Mon Sep 17 00:00:00 2001 From: Zhiqiang Wang Date: Sat, 19 Feb 2022 15:45:51 +0800 Subject: [PATCH] Specify version when publishing to PyPI (#329) * Fix python wheel classifiers * Specify version when release Python wheel * Trigger the workflow on push * Trigger the workflow on pull request * Test ref names * Testing ref names * Testing ref names * Test again * Fix substitution * Fix format * Don't trigger the workflow on pull request --- .github/workflows/pypi-release.yml | 59 +++++++++++++++++------------- setup.cfg | 3 -- setup.py | 11 ++---- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 0d7d4979..f6950dcd 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -1,37 +1,46 @@ # This workflow will upload a Python Package using Twine when a release is created -name: PyPI release +name: Publish 🐍 to PyPI.org on: push: - branches: ["release/*"] + branches: [ main, "release/*" ] release: - types: [published] + types: [ published ] jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - python -m pip install --user --upgrade setuptools wheel - - - name: Build package - run: python setup.py sdist bdist_wheel - - # We do this, since failures on test.pypi aren't that bad - - name: Publish distribution 📦 to Test PyPI - if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - verbose: true + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install --user --upgrade setuptools wheel + + - name: Build package + run: | + BUILD_VERSION=${GITHUB_REF:11} python setup.py sdist bdist_wheel + ls -lh dist/ + + # We do this, since failures on test.pypi aren't that bad + - name: Publish distribution 📦 to Test PyPI + if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + verbose: true + + - name: Publish distribution 📦 to PyPI + if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/setup.cfg b/setup.cfg index db259a58..930194c8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[bdist_wheel] -universal=1 - [metadata] license_file = LICENSE description-file = README.md diff --git a/setup.py b/setup.py index f5ae823b..6cddeb6f 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ import subprocess from pathlib import Path -from setuptools import setup, find_packages +from setuptools import find_packages, setup PATH_ROOT = Path(__file__).parent.resolve() @@ -86,9 +86,7 @@ def load_requirements(path_dir=PATH_ROOT, file_name="requirements.txt", comment_ # Operation system "Operating System :: OS Independent", # How mature is this project? Common values are - # 3 - Alpha - # 4 - Beta - # 5 - Production/Stable + # 3 - Alpha, 4 - Beta, 5 - Production/Stable "Development Status :: 4 - Beta", # Indicate who your project is intended for "Intended Audience :: Developers", @@ -99,8 +97,7 @@ def load_requirements(path_dir=PATH_ROOT, file_name="requirements.txt", comment_ "Topic :: Scientific/Engineering :: Image Recognition", # Pick your license as you wish "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 2, Python 3 or both. + # Specify the Python versions you support here. "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", @@ -119,7 +116,7 @@ def load_requirements(path_dir=PATH_ROOT, file_name="requirements.txt", comment_ # 'Programming Language' classifiers above, 'pip install' will check this # and refuse to install the project if the version does not match. See # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires - python_requires=">=3.6, <4", + python_requires=">=3.6.2", # List additional URLs that are relevant to your project as a dict. # # This field corresponds to the "Project-URL" metadata fields: