Github actions only uploading artifacts on tag push #119
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 and upload to PyPI | |
# Build on every pull request change: | |
on: [push, pull_request] | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
env: | |
CIBW_BUILD: cp311-* cp312-* # build for Python 3.11 and 3.12 | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_SKIP: cp36-* *-win32 *-manylinux_i686 pp* *musllinux* | |
CIBW_ARCHS_MACOS: arm64 # arm64 for Apple Sillicon support | |
CIBW_ARCHS_LINUX: auto aarch64 # allowing arm processors | |
CIBW_REPAIR_WHEEL_COMMAND_MACOS: 'delocate-listdeps {wheel} && delocate-wheel --require-archs {delocate_archs} --ignore-missing-dependencies -w {dest_dir} {wheel}' | |
# not needed because those packages are already in package requirements | |
# CIBW_TEST_REQUIRES: pytest scikit-learn | |
CIBW_TEST_COMMAND: 'cd {package} && pytest -sv tests/test_tree.py && pytest -sv tests/test_wrappers.py' | |
strategy: | |
matrix: | |
# we will be able to include ubuntu-latest when we fix this issue | |
# https://github.com/bigmlcom/sensenet/issues/37 | |
os: [macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
if: runner.os == 'Linux' | |
uses: docker/setup-qemu-action@v1 | |
with: | |
platforms: all | |
- name: Build wheels | |
uses: pypa/[email protected] | |
- name: Upload wheels artifacts | |
# Upload wheels only on tag push | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bigml_sensenet-${{ github.ref_name }}-${{ matrix.build }}-${{ matrix.os }}_${{ matrix.arch }} | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build sdist | |
run: pipx run build --sdist | |
- name: Upload sdist artifacts | |
# Upload sdist only on tag push | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bigml_sensenet-${{ github.ref_name }} | |
path: dist/*.tar.gz | |
upload_pypi: | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
# Upload to PyPI on every tag push | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
path: all | |
- name: Merge files | |
run: | | |
mkdir dist | |
mv all/*/* dist/. | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_PASSWORD }} |