Skip to content

Rework GitHub Actions to correctly and sanely push to PyPi in a controlled manner #687

Rework GitHub Actions to correctly and sanely push to PyPi in a controlled manner

Rework GitHub Actions to correctly and sanely push to PyPi in a controlled manner #687

Workflow file for this run

name: Build
on:
push:
pull_request:
types: [opened, edited, synchronize]
jobs:
build:
name: Build wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.10", "3.11"]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install CPython
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install deps
run: |
pip install .
- name: Build wheels
uses: pypa/cibuildwheel@v2.19.1
- uses: actions/upload-artifact@v4
with:
name: artifact-cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
sdist:
name: Make source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: artifact-source-dist
path: "./**/dist/*.tar.gz"
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install CPython
uses: actions/setup-python@v5
with:
python-version: 3.7
- name: Install Deps
run: |
sudo apt update
sudo apt install -y libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
python -m ensurepip
pip install -r docs/requirements.txt
pip install -r requirements.txt
- name: Build Docs
run: |
cd docs
make html
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.7
- name: install black
run: |
python -m ensurepip
pip install black
- name: run linter
run: |
black twitchio --line-length 120 --verbose --check
upload_pypi:
if: github.event_name == 'push' && github.ref_type == 'tag'
name: Publish built wheels to Pypi
runs-on: ubuntu-latest
environment: release
needs: [build, sdist]
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
- name: Copy artifacts to dist/ folder
run: |
find . -name 'artifact-*' -exec unzip '{}' \;
mkdir -p dist/
find . -name '*.tar.gz' -exec mv '{}' dist/ \;
find . -name '*.whl' -exec mv '{}' dist/ \;
- uses: pypa/gh-action-pypi-publish@release/v1
name: Publish to PyPI