Skip to content

Build Wheels and Release #179

Build Wheels and Release

Build Wheels and Release #179

name: Build Wheels and Release
on:
push:
tags:
- "v*"
- "buildwheels*"
branches:
# Runs on every merge to main to upload .dev0 wheels to anaconda.org
- main
- v1.**
# Make it possible to upload to TestPyPI or Anaconda manually if needed
workflow_dispatch:
inputs:
environment:
description: Which PyPI environment to upload to, if any
required: true
type: choice
options: ["none", "testpypi"]
push_wheels:
description: >
Push wheels to Anaconda if "true". Default is "false". Warning: this will overwrite existing wheels.
required: false
default: "false"
# Upload wheels to anaconda.org on a schedule
schedule:
# Run at 0300 hours on days 3, 13 and 23 of the month
- cron: "0 3 3,13,23 * *"
permissions:
contents: read # to fetch code (actions/checkout)
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
CIBW_BUILD_VERBOSITY: 2
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest --pyargs pywt -m "not slow"
CIBW_ENVIRONMENT: PIP_PREFER_BINARY=1
jobs:
build_linux_x86_64_wheels:
name: Build ${{ matrix.cibw_python }} ${{ matrix.cibw_arch }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
cibw_python: ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"]
cibw_arch: ["x86_64"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
name: Install Python
with:
python-version: "3.12"
- name: Build the wheel
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: dist
env:
CIBW_BUILD: ${{ matrix.cibw_python }}-*
CIBW_ARCHS_LINUX: ${{ matrix.cibw_arch }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels_linux_${{ matrix.cibw_arch }}_${{ matrix.cibw_python }}
path: ./dist/*.whl
if-no-files-found: error
build_linux_aarch64_wheels:
name: Build ${{ matrix.cibw_python }} ${{ matrix.cibw_arch }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04-arm]
cibw_python: ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"]
cibw_arch: ["aarch64"]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
name: Install Python
with:
python-version: "3.12"
- name: Build the wheel
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: dist
env:
CIBW_BUILD: ${{ matrix.cibw_python }}-*
CIBW_ARCHS_LINUX: ${{ matrix.cibw_arch }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels_linux_${{ matrix.cibw_arch }}_${{ matrix.cibw_python }}
path: ./dist/*.whl
build_macos_wheels:
name: Build ${{ matrix.cibw_python }} ${{ matrix.cibw_arch }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15-intel, macos-14]
cibw_python: ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"]
cibw_arch: ["x86_64", "arm64"]
exclude:
- os: macos-14
cibw_arch: "x86_64"
- os: macos-15-intel
cibw_arch: "arm64"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
name: Install Python
with:
python-version: "3.12"
- name: Build wheels for CPython (macOS) (x86_64)
if: matrix.cibw_arch == 'x86_64'
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: dist
env:
CIBW_BUILD: ${{ matrix.cibw_python }}-*
CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }}
- name: Build wheels for CPython (macOS) (arm64)
if: matrix.cibw_arch == 'arm64'
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: dist
env:
CIBW_BUILD: ${{ matrix.cibw_python }}-*
CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels_macos_${{ matrix.cibw_arch }}_${{ matrix.cibw_python }}
path: ./dist/*.whl
if-no-files-found: error
build_windows_wheels:
name: Build ${{ matrix.cibw_python }} ${{ matrix.cibw_arch }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, windows-11-arm]
cibw_arch: ["AMD64", "x86", "ARM64"]
cibw_python: ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"]
exclude:
- os: windows-latest
cibw_arch: ARM64
- os: windows-11-arm
cibw_arch: x86
- os: windows-11-arm
cibw_arch: AMD64
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
name: Install Python
with:
python-version: "3.12"
- name: Setup MSVC (32-bit)
if: matrix.cibw_arch == 'x86'
uses: bus1/cabuild/action/msdevshell@06ea2833eef61e9b0d0ce0d728416e617e4fb1fe # v1
with:
architecture: x86
- name: Setup MSVC (64-bit)
if: matrix.cibw_arch == 'AMD64'
uses: bus1/cabuild/action/msdevshell@06ea2833eef61e9b0d0ce0d728416e617e4fb1fe # v1
with:
architecture: x64
- name: Setup MSVC (ARM64)
if: matrix.cibw_arch == 'ARM64'
uses: bus1/cabuild/action/msdevshell@06ea2833eef61e9b0d0ce0d728416e617e4fb1fe # v1
with:
architecture: arm64
- name: Build Windows wheels for CPython
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: dist
env:
CIBW_BUILD: ${{ matrix.cibw_python }}-*
CIBW_ARCHS_WINDOWS: ${{ matrix.cibw_arch }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: wheels_windows_${{ matrix.cibw_arch }}_${{ matrix.cibw_python }}
path: ./dist/*.whl
if-no-files-found: error
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
name: Install Python
with:
python-version: "3.12"
- name: Build sdist
run: |
python -m pip install --upgrade pip build
python -m build --sdist
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sdist
path: ./dist/*.tar.gz
if-no-files-found: error
testpypi-publish:
name: Publish release to TestPyPI
if: >-
github.repository == 'PyWavelets/pywt' &&
github.event_name == 'workflow_dispatch' &&
github.event.inputs.environment == 'testpypi'
needs:
[
build_linux_x86_64_wheels,
build_linux_aarch64_wheels,
build_macos_wheels,
build_windows_wheels,
build_sdist,
]
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/pywavelets
permissions:
id-token: write # mandatory for trusted publishing
steps:
- name: Download sdist and wheels
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
merge-multiple: true
- name: Publish
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
print-hash: true
attestations: true
check_version:
name: Ensure commit is tag before upload to PyPI
if: >-
github.repository == 'PyWavelets/pywt' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/v')
needs:
[
build_linux_x86_64_wheels,
build_linux_aarch64_wheels,
build_macos_wheels,
build_windows_wheels,
build_sdist,
]
runs-on: ubuntu-latest
steps:
- name: Checkout PyWavelets
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
fetch-tags: true
submodules: false
persist-credentials: false
- name: Examine git commit
run: |
git describe --exact-match --tags HEAD
pypi-publish:
name: Publish release to PyPI
if: >-
github.repository == 'PyWavelets/pywt' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/v')
needs: [check_version]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pywavelets
permissions:
contents: write # needed to create the GitHub release
id-token: write # mandatory for trusted publishing
steps:
- name: Download sdist and wheels
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
merge-multiple: true
- name: Publish
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
print-hash: true
attestations: true
- name: GitHub release
run: gh release create "${GITHUB_REF_NAME}" --verify-tag --notes ""
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
deploy_anaconda:
name: Release (Anaconda)
needs:
[
build_linux_x86_64_wheels,
build_linux_aarch64_wheels,
build_macos_wheels,
build_windows_wheels,
]
# Run only on pushes to the main branch, on schedule, or when triggered manually
if: >-
github.repository == 'PyWavelets/pywt' &&
((github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.push_wheels == 'true') ||
github.event_name == 'schedule')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
id: download
with:
pattern: "wheels_*"
path: dist/
merge-multiple: true
- name: Push to Anaconda PyPI index
uses: scientific-python/upload-nightly-action@e76cfec8a4611fd02808a801b0ff5a7d7c1b2d99 # 0.6.4
with:
artifacts_path: dist/
anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}