-
Notifications
You must be signed in to change notification settings - Fork 12
149 lines (126 loc) · 4.31 KB
/
wheels.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Build Wheels
on:
pull_request:
workflow_dispatch:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
jobs:
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Set up rust cache
uses: Swatinem/rust-cache@v2
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: install python dependencies
run: pip install -U setuptools wheel twine maturin build pkginfo>=1.10.0
- name: build sdist
run: |
python -m build --sdist -o wheelhouse
- name: List and check sdist
run: |
ls -lh wheelhouse/
twine check wheelhouse/*
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.tar.gz
build_wheels:
name: >
build ${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }}
${{ (matrix.arch) || '' }}
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows, macos]
python-version: ['cp312', 'cp311', 'cp310', 'cp39']
include:
- os: ubuntu
platform: linux
pip_cache: ~/.cache/pip
- os: windows
ls: dir
pip_cache: ~\AppData\Local\pip\Cache
runs-on: ${{ format('{0}-latest', matrix.os) }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- if: matrix.os == 'macos' || matrix.os == 'windows'
name: Set up rust toolchain
uses: dtolnay/rust-toolchain@stable
- if: matrix.os == 'macos' || matrix.os == 'windows'
name: Set up rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.arch }}
# Set up rust toolchain on mac os and windows (linux containers handled below)
- if: matrix.os == 'macos'
name: Add aarch64-apple-darwin target
run: rustup target add aarch64-apple-darwin
- if: matrix.os == 'windows'
name: Add i686-pc-windows-msvc target
run: |
# Disable self-update on windows to prevent race condition; see https://github.com/rust-lang/rustup/issues/2441
rustup toolchain install stable-i686-pc-windows-msvc --no-self-update
rustup target add i686-pc-windows-msvc
- name: Build ${{ matrix.platform || matrix.os }} binaries
uses: pypa/[email protected]
env:
CIBW_BUILD: '${{ matrix.python-version }}-*'
# rust doesn't seem to be available for musl linux on i686
CIBW_SKIP: '*-musllinux_i686'
# we build for matrix.arch (only exists on macos), else 'auto'
CIBW_ARCHS: ${{ matrix.arch || 'auto' }}
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"'
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
CIBW_BEFORE_BUILD: rustup show
# Linux wheels are built in manylinux containers; set up rust toolchain here
CIBW_BEFORE_BUILD_LINUX: >
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y &&
rustup show
CIBW_BUILD_VERBOSITY: 1
- name: List and check wheels
run: |
pip install twine pkginfo>=1.10.0
${{ matrix.ls || 'ls -lh' }} wheelhouse/
twine check wheelhouse/*
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./wheelhouse/*.whl
upload_to_pypi:
name: Upload to PYPI
runs-on: ubuntu-latest
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
needs: [build_wheels, build_sdist]
environment:
name: pypi
url: https://pypi.org/p/nbstripout-fast
permissions:
id-token: write
steps:
- name: Retrieve wheels and sdist
uses: actions/download-artifact@v3
- name: List the build artifacts
run: |
ls -lAs wheels/
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheels/