-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (165 loc) · 5.53 KB
/
build.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Builds on all branches & PRs
# Deploys to PyPi on new tags.
name: Build, test and publish
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-20.04
name: Runs tests
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" , "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Test with tox
run: tox
env:
RUSTUP_TOOLCHAIN: nightly
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Pytest Test Results (Python ${{ matrix.python-version }})
path: pytest.xml
publish-test-results:
name: "Publish Unit Tests Results"
needs: test
runs-on: ubuntu-latest
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: artifacts/**/*.xml
build_linux:
needs: test
runs-on: ubuntu-latest
name: Linux Wheels
steps:
# For tags we assume the version in pyproject.toml is correct!
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Rewrite version for dev if not tag
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
sed -E -i -e "s/version\s*=\s*\"(.*)(\.rc.*|\.a.*|\.post.*)?\"/version = \"\1.dev0+${GITHUB_SHA::8}\"/;" pyproject.toml
- name: Note version
run: |
PACKAGE_VERSION=$(grep "version" ./pyproject.toml | tr -d '"' | awk -F' ' '{print $3}')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: python -m cibuildwheel --output-dir dist
env:
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y"
CIBW_ENVIRONMENT_LINUX: 'PATH="$PATH:$HOME/.cargo/bin"'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux
path: dist/*.whl
build_macos_windows:
needs: test
runs-on: ${{ matrix.os }}
name: Mac/Win Wheel
strategy:
fail-fast: false
matrix:
os: [ macos-11, windows-2019 ]
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
arch: [ 'x64', 'x86' ]
exclude:
- os: macos-11
arch: 'x86'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rewrite version for dev if not tag
if: "!startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-11'"
shell: bash
run: |
sed -E -i '' -e "s/version\s*=\s*\"(.*)(\.rc.*|\.a.*|\.post.*)?\"/version = \"\1.dev0+${GITHUB_SHA::8}\"/;" pyproject.toml
- name: Rewrite version for dev if not tag
if: "!startsWith(github.ref, 'refs/tags/') && matrix.os != 'macos-11'"
shell: bash
run: |
sed -E -i -e "s/version\s*=\s*\"(.*)(\.rc.*|\.a.*|\.post.*)?\"/version = \"\1.dev0+${GITHUB_SHA::8}\"/;" pyproject.toml
- name: Note version
shell: bash
run: |
PACKAGE_VERSION=$(grep "version" ./pyproject.toml | tr -d '"' | awk -F' ' '{print $3}')
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
target: "${{ matrix.os == 'windows-2019' && 'i686-pc-windows-msvc' || 'x86_64-apple-darwin' }}"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.arch }}
- name: Upgrade pip, install dev dependencies
run: |
python -m pip install --upgrade pip wheel build
python -m pip install -r requirements.txt
- name: Build Python wheels
run: |
python -m build
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-py${{ matrix.python-version }}-${{ matrix.arch }}
path: dist/*.whl
deploy:
if: startsWith(github.ref, 'refs/tags/')
needs:
- build_linux
- build_macos_windows
runs-on: ubuntu-latest
name: Deploy wheels to PyPI
steps:
- name: Download wheels
uses: actions/download-artifact@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install twine
- name: Publish wheels to PyPI
env:
TWINE_USERNAME: ${{ secrets.TWINE_USR }}
TWINE_PASSWORD: ${{ secrets.TWINE_PSW }}
run: |
twine upload wheels-linux/*manylinux*.whl wheels-windows*/*.whl wheels-macos*/*.whl