build sdist and pure wheel in the same wheels.yml workflow

.zip is deprecated for Python source distributions so use the default .tar.gz
This commit is contained in:
Cosimo Lupo 2023-06-09 19:21:52 +01:00
parent 82e368e2b7
commit d264510618
No known key found for this signature in database
GPG Key ID: DF65A8A5A119C9A8
3 changed files with 27 additions and 45 deletions

View File

@ -1,34 +0,0 @@
# This workflows will upload a Python Package using Twine when a tag is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Upload Python Package
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '*.*.*' # e.g. 1.0.0 or 20.15.10
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*

View File

@ -3,9 +3,6 @@ name: Build + Deploy
on: on:
push: push:
tags: ["*.*.*"] tags: ["*.*.*"]
release:
types:
- published
# enables workflow to be run manually # enables workflow to be run manually
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch: workflow_dispatch:
@ -21,6 +18,26 @@ env:
jobs: jobs:
build_pure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install setuptools wheel twine
- name: Build source distribution and pure-python wheel
run: |
python setup.py sdist bdist_wheel
- uses: actions/upload-artifact@v3
with:
path: |
dist/*.whl
dist/*.tar.gz
build_wheels: build_wheels:
name: ${{ matrix.type }} ${{ matrix.arch }} on ${{ matrix.os }} name: ${{ matrix.type }} ${{ matrix.arch }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@ -86,17 +103,19 @@ jobs:
path: wheelhouse/*.whl path: wheelhouse/*.whl
deploy: deploy:
name: Upload if release name: Upload to PyPI on tagged commit
needs: [build_wheels, build_arch_wheels]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published' needs:
- build_pure
- build_wheels
- build_arch_wheels
# only run if the commit is tagged...
if: startsWith(github.ref, 'refs/tags/')
steps: steps:
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
name: artifact name: artifact
path: dist path: dist
- uses: pypa/gh-action-pypi-publish@v1.8.6 - uses: pypa/gh-action-pypi-publish@v1.8.6
with: with:
user: __token__ user: __token__

View File

@ -24,9 +24,6 @@ replace = __version__ = "{new_version}"
search = version="{current_version}" search = version="{current_version}"
replace = version="{new_version}" replace = version="{new_version}"
[sdist]
formats = zip
[metadata] [metadata]
license_files = LICENSE license_files = LICENSE