Skip to content

Commit

Permalink
Specify version when publishing to PyPI (#329)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zhiqwang authored Feb 19, 2022
1 parent 811c759 commit 66bbbda
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
59 changes: 34 additions & 25 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[bdist_wheel]
universal=1

[metadata]
license_file = LICENSE
description-file = README.md
Expand Down
11 changes: 4 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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:
Expand Down

0 comments on commit 66bbbda

Please sign in to comment.