-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
97 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,60 +5,134 @@ on: | |
tags: | ||
- v* | ||
|
||
workflow_dispatch: | ||
inputs: | ||
os_choice: | ||
description: 'Choose what to build' | ||
required: true | ||
default: 'all' | ||
type: choice | ||
options: | ||
- all | ||
- sdist-only | ||
- ubuntu-latest | ||
- windows-latest | ||
- macos-latest | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos-latest, windows-latest, ubuntu-latest] | ||
build_wheels_ubuntu: | ||
name: Build wheels on ubuntu-latest | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event_name == 'push' || (github.event.inputs.os_choice == 'all' || github.event.inputs.os_choice == 'ubuntu-latest') && github.event.inputs.os_choice != 'sdist-only' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
with: | ||
output-dir: ./wheelhouse | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-ubuntu-latest | ||
path: ./wheelhouse/*.whl | ||
overwrite: true | ||
|
||
build_wheels_windows: | ||
name: Build wheels on windows-latest | ||
runs-on: windows-latest | ||
if: ${{ github.event_name == 'push' || (github.event.inputs.os_choice == 'all' || github.event.inputs.os_choice == 'windows-latest') && github.event.inputs.os_choice != 'sdist-only' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
with: | ||
output-dir: ./wheelhouse | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-windows-latest | ||
path: ./wheelhouse/*.whl | ||
overwrite: true | ||
|
||
build_wheels_macos: | ||
name: Build wheels on macos-latest | ||
runs-on: macos-latest | ||
if: ${{ github.event_name == 'push' || (github.event.inputs.os_choice == 'all' || github.event.inputs.os_choice == 'macos-latest') && github.event.inputs.os_choice != 'sdist-only' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Build wheels | ||
uses: pypa/[email protected] | ||
with: | ||
output-dir: ./wheelhouse | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheels-macos-latest | ||
path: ./wheelhouse/*.whl | ||
overwrite: true | ||
|
||
build_sdist: | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event_name == 'push' || github.event.inputs.os_choice == 'all' || github.event.inputs.os_choice == 'sdist-only' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install build dependencies | ||
run: python -m pip install --upgrade pip build | ||
|
||
- name: Build sdist | ||
run: pipx run build --sdist | ||
run: python -m build --sdist | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: sdist | ||
path: dist/*.tar.gz | ||
overwrite: true | ||
|
||
upload_pypi: | ||
needs: [build_wheels, build_sdist] | ||
needs: | ||
- build_wheels_ubuntu | ||
- build_wheels_windows | ||
- build_wheels_macos | ||
- build_sdist | ||
runs-on: ubuntu-latest | ||
# upload to PyPI on every tag starting with 'v' | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
# alternatively, to publish when a GitHub Release is created, use the following rule: | ||
# if: github.event_name == 'release' && github.event.action == 'published' | ||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks default artifact into dist/ | ||
# if `name: artifact` is omitted, the action will create extra parent dir | ||
name: artifact | ||
path: dist | ||
path: dist/ | ||
|
||
- uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: "dist/*.whl,dist/*.tar.gz" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: List artifacts (debug) | ||
run: ls dist | ||
|
||
- uses: pypa/[email protected] | ||
- name: Upload to PyPI | ||
uses: pypa/[email protected] | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_PASSWORD }} | ||
packages: 'dist/*' |