Release pgenlib #2
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: Release pgenlib | |
on: [workflow_dispatch] | |
jobs: | |
build_wheels: | |
name: Build wheels for ${{ matrix.arch }} ${{ matrix.os }} py3.${{ matrix.python }} | |
runs-on: ${{ matrix.os }}-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python: [7, 8, 9, 10, 11, 12] | |
os: [ubuntu, macos] | |
arch: [x86_64, aarch64, universal2] | |
exclude: | |
- os: macos | |
arch: universal2 | |
python: 7 | |
- os: ubuntu | |
arch: universal2 | |
- os: macos | |
arch: x86_64 | |
- os: macos | |
arch: aarch64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU for aarch64 emulation | |
if: runner.os == 'Linux' && matrix.arch == 'aarch64' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.19.1 | |
with: | |
package-dir: ./2.0/Python | |
env: | |
CIBW_SKIP: "*-musllinux_* pp3*-manylinux_aarch64" | |
CIBW_BUILD: ${{ format('*p3{0}-*', matrix.python) }} | |
CIBW_ARCHS: ${{ matrix.arch }} | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: "pytest {package}/tests" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.os }}-${{ matrix.arch }}-3${{ matrix.python }} | |
path: ./wheelhouse/*.whl | |
merge_wheels: | |
runs-on: ubuntu-latest | |
needs: build_wheels | |
steps: | |
- name: Merge wheel artifacts into a single artifact | |
uses: actions/upload-artifact/merge@v4 | |
with: | |
name: wheels | |
pattern: wheels-* | |
delete-merged: true | |
build_sdist: | |
runs-on: ubuntu-latest | |
env: | |
job_python_version: "3.12" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ env.job_python_version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.job_python_version }} | |
- name: Create source distribution | |
working-directory: ./2.0/Python | |
run: | | |
pip install build | |
python -m build --sdist . | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: sdist | |
path: ./2.0/Python/dist/pgenlib-*.tar.gz | |
- name: Install and test | |
working-directory: ./2.0/Python | |
run: | | |
pip install --no-cache-dir --no-binary=pgenlib dist/pgenlib-*.tar.gz pytest | |
pytest tests/ | |
upload_pypi: | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
if: github.repository_owner == 'chrchang' | |
permissions: | |
id-token: write | |
steps: | |
- name: Get artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: dist | |
- name: Publish distribution to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
- name: Publish distribution to PyPI | |
if: github.ref == 'refs/heads/master' | |
uses: pypa/gh-action-pypi-publish@release/v1 |