| 1 |
name: Wheels |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
branches: |
| 6 |
- master |
| 7 |
release: |
| 8 |
types: |
| 9 |
- published |
| 10 |
|
| 11 |
jobs: |
| 12 |
build_bdist: |
| 13 |
name: "Build ${{ matrix.os }} (${{ matrix.arch }}) wheels" |
| 14 |
runs-on: ${{ matrix.os }} |
| 15 |
timeout-minutes: 60 # should be long enough even on tags, but let's prevent hangs |
| 16 |
strategy: |
| 17 |
fail-fast: false |
| 18 |
matrix: |
| 19 |
include: |
| 20 |
- os: ubuntu-24.04 |
| 21 |
arch: x86_64 |
| 22 |
- os: ubuntu-24.04-arm |
| 23 |
arch: aarch64 |
| 24 |
- os: windows-2022 |
| 25 |
arch: AMD64 |
| 26 |
- os: macos-14 |
| 27 |
arch: arm64 |
| 28 |
- os: macos-15-intel |
| 29 |
arch: x86_64 |
| 30 |
- os: windows-11-arm |
| 31 |
arch: ARM64 |
| 32 |
|
| 33 |
steps: |
| 34 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 35 |
with: |
| 36 |
fetch-depth: 0 |
| 37 |
persist-credentials: false |
| 38 |
|
| 39 |
- name: Build just oldest and newest on PRs, all on tags |
| 40 |
if: ${{ github.event_name == 'pull_request' }} |
| 41 |
shell: bash |
| 42 |
# - On PPs, omit musllinux for speed |
| 43 |
# - On PRs, run just oldest and newest Python versions (3.11 is the oldest abi3 target) |
| 44 |
run: | |
| 45 |
CIBW_SKIP="cp310-win_arm64 *musllinux*" |
| 46 |
echo "CIBW_SKIP=$CIBW_SKIP" >> $GITHUB_ENV |
| 47 |
echo "Setting CIBW_SKIP=$CIBW_SKIP" |
| 48 |
|
| 49 |
CIBW_TEST_SKIP="cp312-* cp313-*" |
| 50 |
echo "CIBW_TEST_SKIP=$CIBW_TEST_SKIP" >> $GITHUB_ENV |
| 51 |
echo "Setting CIBW_TEST_SKIP=$CIBW_TEST_SKIP" |
| 52 |
|
| 53 |
- name: "Building ${{ matrix.os }} (${{ matrix.arch }}) wheels" |
| 54 |
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 |
| 55 |
env: |
| 56 |
CIBW_SKIP: ${{ env.CIBW_SKIP }} |
| 57 |
CIBW_TEST_SKIP: ${{ env.CIBW_TEST_SKIP }} |
| 58 |
CIBW_ARCHS: ${{ matrix.arch }} |
| 59 |
|
| 60 |
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 61 |
with: |
| 62 |
name: pypi-artifacts-${{ matrix.os }}-${{ matrix.arch }} |
| 63 |
path: ${{ github.workspace }}/wheelhouse/*.whl |
| 64 |
permissions: |
| 65 |
actions: write |
| 66 |
|
| 67 |
build_sdist: |
| 68 |
name: Build source distribution |
| 69 |
runs-on: ubuntu-24.04 |
| 70 |
steps: |
| 71 |
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 72 |
with: |
| 73 |
fetch-depth: 0 |
| 74 |
persist-credentials: false |
| 75 |
|
| 76 |
- name: Build sdist |
| 77 |
run: > |
| 78 |
pip install build |
| 79 |
&& python -m build --sdist . --outdir dist |
| 80 |
|
| 81 |
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 82 |
with: |
| 83 |
name: pypi-artifacts |
| 84 |
path: ${{ github.workspace }}/dist/*.tar.gz |
| 85 |
|
| 86 |
permissions: |
| 87 |
actions: write |
| 88 |
|
| 89 |
publish-artifacts-pypi: |
| 90 |
needs: [build_bdist, build_sdist] |
| 91 |
name: "Publish to PyPI" |
| 92 |
runs-on: ubuntu-24.04 |
| 93 |
# upload to PyPI for every tag starting with 'v' |
| 94 |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 95 |
steps: |
| 96 |
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 |
| 97 |
with: |
| 98 |
pattern: pypi-artifacts* |
| 99 |
path: ${{ github.workspace }}/dist |
| 100 |
merge-multiple: true |
| 101 |
|
| 102 |
# Move to Trusted Publishing |
| 103 |
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 |
| 104 |
with: |
| 105 |
print_hash: true |
| 106 |
environment: |
| 107 |
name: release |
| 108 |
url: https://pypi.org/p/cftime |
| 109 |
permissions: |
| 110 |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |