Skip to content

Commit

Permalink
Split sdist and pypi uploads into separate jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
imciner2 committed Jun 19, 2024
1 parent 464354c commit 81a6c38
Showing 1 changed file with 50 additions and 23 deletions.
73 changes: 50 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
name: Build
name: Build wheels

on: [push, pull_request]

jobs:
build_sdist:
name: Build source
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@master
with:
submodules: 'recursive'

- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.12'

- name: Build source
run: |
python -m pip install build
python -m build --sdist --outdir=wheelhouse
- name: Upload sdist to github
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: wheelhouse/*.tar.gz
if-no-files-found: error

build_wheels:
name: Build wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -56,35 +84,34 @@ jobs:
CIBW_ENVIRONMENT_WINDOWS: CMAKE_GENERATOR="Visual Studio 17 2022" CMAKE_GENERATOR_PLATFORM=x64
CIBW_BUILD_VERBOSITY: 1

- name: Build source
if: startsWith(matrix.os, 'ubuntu')
run: |
python -m build --sdist --outdir=wheelhouse
- name: Release to pypi
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
python -m pip install --upgrade twine
twine upload wheelhouse/*
- name: Upload artifacts to github
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse
path: ./wheelhouse/*.whl
if-no-files-found: error

merge_artifacts:
name: Merge wheel artifacts from build_wheels OS matrix jobs
publish_to_pypi:
name: Publish wheels to PyPi
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: [build_sdist, build_wheels]
runs-on: ubuntu-latest
needs: build_wheels

steps:
- name: Merge artifacts
uses: actions/upload-artifact/merge@v4
- name: Download packages
uses: actions/download-artifact@v4
with:
name: wheels
pattern: wheels-*
delete-merged: true
path: wheelhouse
merge-multiple: true

- name: Print out packages
run: ls wheelhouse

- name: Upload wheels to pypi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
python -m pip install --upgrade twine
twine upload wheelhouse/*

0 comments on commit 81a6c38

Please sign in to comment.