Skip to content

Commit

Permalink
Add a workflow for building wheels and publishing them on PyPI, chang…
Browse files Browse the repository at this point in the history
…e names in the old workflows
  • Loading branch information
mwydmuch committed Sep 6, 2023
1 parent ad72421 commit 3cecc22
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build
name: Build and test

on:
push:
Expand All @@ -11,8 +11,7 @@ on:
- 'CMakeLists.txt'
- 'setup.py'
- 'pyproject.toml'
branches:
- master
branches: [master]
pull_request:
paths:
- '.github/workflows/**'
Expand All @@ -23,8 +22,7 @@ on:
- 'CMakeLists.txt'
- 'setup.py'
- 'pyproject.toml'
branches:
- master
branches: [master]

env:
HOMEBREW_NO_AUTO_UPDATE: 1
Expand All @@ -36,7 +34,6 @@ jobs:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, macos-12]
python-version: ['3.8', '3.9', '3.10', '3.11']

runs-on: ${{ matrix.os }}

steps:
Expand All @@ -46,7 +43,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install -y cmake libboost-all-dev libsdl2-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libjpeg-dev libbz2-dev libfluidsynth-dev libgme-dev libopenal-dev zlib1g-dev timidity tar nasm
sudo apt install -y cmake git libboost-all-dev libsdl2-dev libopenal-dev
- name: Apt report
if: runner.os == 'Linux'
Expand Down
92 changes: 92 additions & 0 deletions .github/workflows/build-wheels,yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Build Python wheels and make release

on:
workflow_dispatch:
pull_request:
push:
paths:
- '.github/workflows/**'
- 'include/**'
- 'scripts/**'
- 'src/**'
- 'CMakeLists.txt'
- 'setup.py'
- 'pyproject.toml'
branches: [master]
release:
types: [published]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, macos-11]

steps:
- uses: actions/checkout@v3

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Build wheels
uses: pypa/[email protected]
env:
# Configure cibuildwheel to build native archs, and some emulated ones
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_ARCHS_MACOS: x86_64
CIBW_BUILD_VERBOSITY: 3
CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
auditwheel show {wheel} && auditwheel repair -w {dest_dir} {wheel}

- name: Report builded wheels
run: |
ls -l ./wheelhouse/*.whl

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build sdist
run: pipx run build --sdist

- name: Upload sdist
uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download all dists
uses: actions/download-artifact@v3
with:
# Unpacks default artifact into dist/
# If `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# To test:
# with:
# repository_url: https://test.pypi.org/legacy/

3 changes: 2 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://pre-commit.com
# This GitHub Action assumes that the repo contains a valid .pre-commit-config.yaml file.
name: Pre-commit
name: Pre-commit checks
on:
pull_request:
push:
Expand All @@ -11,6 +11,7 @@ permissions:

jobs:
pre-commit:
name: Pre-commit checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down

0 comments on commit 3cecc22

Please sign in to comment.