Build and upload to PyPI #23
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
name: Build + Release Wheels | |
on: | |
workflow_dispatch: | |
inputs: | |
deploy_to_testpypi: | |
description: "Whether the build should be deployed to test.pypi.org instead of regular PyPI" | |
required: true | |
default: false | |
jobs: | |
build-and-release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-latest, macos-latest] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Setup Dependencies (Windows) | |
if: runner.os == 'Windows' | |
run: echo "No extra setup needed for Windows" | |
shell: bash | |
- name: Setup Dependencies (macOS) | |
if: runner.os == 'macOS' | |
run: echo "No extra setup needed for macOS" | |
shell: bash | |
- name: Build native binary (Windows) | |
if: runner.os == 'Windows' | |
run: make vinput.lib | |
shell: bash | |
- name: Build native binary (macOS) | |
if: runner.os == 'macOS' | |
run: make libvinput.dylib | |
shell: bash | |
- name: Build wheel | |
run: | | |
pip install build | |
python -m build --wheel | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions-${{ matrix.os }}-py${{ matrix.python-version }} | |
path: dist | |
- name: Install Twine | |
run: pip install twine | |
- name: Upload to PyPI | |
if: github.event.inputs.deploy_to_testpypi == 'false' | |
run: twine upload dist/* --verbose --skip-existing -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} | |
env: | |
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/ | |
- name: Upload to TestPyPI | |
if: github.event.inputs.deploy_to_testpypi == 'true' | |
run: twine upload dist/* --verbose --skip-existing -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }} | |
env: | |
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ |