Skip to content

Commit

Permalink
Improved GitHub actions build.
Browse files Browse the repository at this point in the history
  • Loading branch information
mliberty1 committed Jun 5, 2024
1 parent 95699b7 commit 808993d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
40 changes: 29 additions & 11 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
ref: ${{ github.ref }}

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

Expand All @@ -62,32 +62,41 @@ jobs:
- name: Build sdist
run: python -m build --sdist

- name: Find sdist filename
shell: bash
id: find_sdist_filename
run: echo "filename=$(ls dist/*.tar.gz)" >> $GITHUB_OUTPUT

- name: Install the wheel
run: python -m pip install -f dist pymonocypher
run: python -m pip install ./dist/${{ steps.find_sdist_filename.outputs.filename }}

- name: Run python unit tests
run: pytest

- name: Upload python source package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
if-no-files-found: error

build_wheels:
name: Build on ${{ matrix.os }}
name: Build on ${{ matrix.os }}, python=${{ matrix.python_version }}
needs:
- build_sdist
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python_version: ["cp39", "cp310", "cp311", "cp312"]
exclude:
- os: "macos-latest"
python_version: "cp39"

steps:
- name: Download sdist
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: sdist
path: dist/
Expand All @@ -97,24 +106,32 @@ jobs:
id: find_sdist_filename
run: echo "filename=$(ls dist/*.tar.gz)" >> $GITHUB_OUTPUT

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.17.0

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: universal2
CIBW_ARCHS_WINDOWS: native
CIBW_ARCHS_LINUX: native
# skip PyPy: Cython only supports CPython
# skip musllinux: build takes too long with default os images.
CIBW_SKIP: 'pp* *musllinux*'
CIBW_BUILD: '${{ matrix.python_version }}-*'
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest {package}/test
with:
package-dir: ${{ steps.find_sdist_filename.outputs.filename }}

- name: Upload python wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wheels
name: python_wheel-${{ matrix.os }}-${{ matrix.python_version }}
path: wheelhouse/*.whl
if-no-files-found: error

Expand All @@ -131,15 +148,16 @@ jobs:

steps:
- name: Download python sdist artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: sdist
path: dist/

- name: Download python wheel artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wheels
pattern: python_wheel-*
merge-multiple: true
path: dist/

- name: Display artifacts
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: C',
],

Expand Down

0 comments on commit 808993d

Please sign in to comment.