-
Notifications
You must be signed in to change notification settings - Fork 2
225 lines (180 loc) · 7.88 KB
/
python-package.yml
File metadata and controls
225 lines (180 loc) · 7.88 KB
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
branches: [ "main" ]
release:
types: [ published ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8
- name: Lint with flake8
run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
build:
runs-on: ubuntu-latest
needs: [ lint ]
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Windows toolchains
run: |
sudo apt update
sudo apt install binutils-mingw-w64-x86-64 gcc-mingw-w64-x86-64 -y
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Set Python release
run: |
PYTHON_VERSION=${{ matrix.python-version }}
echo "PYTHON_RELEASE=${PYTHON_VERSION/./}" >> "$GITHUB_ENV"
- name: Set up Rust
run: |
cd mystiks_core
rustup toolchain install stable
rustup default stable
rustup update
rustup target add x86_64-pc-windows-gnu
- name: Set Mystiks version
run: |
RELEASE_NAME=${{ github.event.release.name }}
echo "MYSTIKS_VERSION=${RELEASE_NAME:1}" >> "$GITHUB_ENV"
if: github.event_name == 'release' && github.event.action == 'published'
- name: Update Mystiks Core version
working-directory: ./mystiks_core
run: sed -i "0,/version = \"1.0.0\"/s//version = \"${{ env.MYSTIKS_VERSION }}\"/" Cargo.toml
if: github.event_name == 'release' && github.event.action == 'published'
- name: Compile Mystiks Core for Linux
working-directory: ./mystiks_core
run: |
maturin build --release --strip
mv ./target/release/libmystiks_core.so ../mystiks/mystiks_core.cpython-${{ env.PYTHON_RELEASE }}-x86_64-linux-gnu.so
- name: Upload Mystiks Core artifact for Linux
uses: actions/upload-artifact@v4
with:
name: mystiks_core.cpython-${{ env.PYTHON_RELEASE }}-x86_64-linux-gnu.so
path: ./mystiks/mystiks_core.cpython-${{ env.PYTHON_RELEASE }}-x86_64-linux-gnu.so
if-no-files-found: error
retention-days: 1
- name: Compile Mystiks Core for Windows
working-directory: ./mystiks_core
run: |
maturin build --release --strip --target x86_64-pc-windows-gnu -i ${{ matrix.python-version }}
mv ./target/x86_64-pc-windows-gnu/release/mystiks_core.dll ../mystiks/mystiks_core.cp${{ env.PYTHON_RELEASE }}-win_amd64.pyd
- name: Upload Mystiks Core artifact for Windows
uses: actions/upload-artifact@v4
with:
name: mystiks_core.cp${{ env.PYTHON_RELEASE }}-win_amd64.pyd
path: ./mystiks/mystiks_core.cp${{ env.PYTHON_RELEASE }}-win_amd64.pyd
if-no-files-found: error
retention-days: 1
publish:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build twine
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Set Mystiks version
run: |
RELEASE_NAME="${{ github.event.release.name }}"
echo "MYSTIKS_VERSION=\"${RELEASE_NAME:1}\"" >> "$GITHUB_ENV"
if: github.event_name == 'release' && github.event.action == 'published'
- name: Update Mystiks version
run: sed -i "0,/version='1.0.0'/s//version='${{ env.MYSTIKS_VERSION }}'/" setup.py
if: github.event_name == 'release' && github.event.action == 'published'
# Download and move Mystiks Core for Python 3.10 on Linux
- name: Download Mystiks Core (cpython-310-x86_64-linux-gnu.so)
uses: actions/download-artifact@v4
with:
name: mystiks_core.cpython-310-x86_64-linux-gnu.so
- name: Move Mystiks Core (cpython-310-x86_64-linux-gnu.so)
run: mv mystiks_core.cpython-310-x86_64-linux-gnu.so ./mystiks/mystiks_core.cpython-310-x86_64-linux-gnu.so
# Download and move Mystiks Core for Python 3.11 on Linux
- name: Download Mystiks Core (cpython-311-x86_64-linux-gnu.so)
uses: actions/download-artifact@v4
with:
name: mystiks_core.cpython-311-x86_64-linux-gnu.so
- name: Move Mystiks Core (cpython-311-x86_64-linux-gnu.so)
run: mv mystiks_core.cpython-311-x86_64-linux-gnu.so ./mystiks/mystiks_core.cpython-311-x86_64-linux-gnu.so
# Download and move Mystiks Core for Python 3.12 on Linux
- name: Download Mystiks Core (cpython-312-x86_64-linux-gnu.so)
uses: actions/download-artifact@v4
with:
name: mystiks_core.cpython-312-x86_64-linux-gnu.so
- name: Move Mystiks Core (cpython-312-x86_64-linux-gnu.so)
run: mv mystiks_core.cpython-312-x86_64-linux-gnu.so ./mystiks/mystiks_core.cpython-312-x86_64-linux-gnu.so
# Download and move Mystiks Core for Python 3.13 on Linux
# - name: Download Mystiks Core (cpython-313-x86_64-linux-gnu.so)
# uses: actions/download-artifact@v4
# with:
# name: mystiks_core.cpython-313-x86_64-linux-gnu.so
# - name: Move Mystiks Core (cpython-313-x86_64-linux-gnu.so)
# run: mv mystiks_core.cpython-313-x86_64-linux-gnu.so ./mystiks/mystiks_core.cpython-313-x86_64-linux-gnu.so
# Download and move Mystiks Core for Python 3.10 on Windows
- name: Download Mystiks Core (cp310-win_amd64.pyd)
uses: actions/download-artifact@v4
with:
name: mystiks_core.cp310-win_amd64.pyd
- name: Move Mystiks Core (cp310-win_amd64.pyd)
run: mv mystiks_core.cp310-win_amd64.pyd ./mystiks/mystiks_core.cp310-win_amd64.pyd
# Download and move Mystiks Core for Python 3.11 on Windows
- name: Download Mystiks Core (cp311-win_amd64.pyd)
uses: actions/download-artifact@v4
with:
name: mystiks_core.cp311-win_amd64.pyd
- name: Move Mystiks Core (cp311-win_amd64.pyd)
run: mv mystiks_core.cp311-win_amd64.pyd ./mystiks/mystiks_core.cp311-win_amd64.pyd
# Download and move Mystiks Core for Python 3.12 on Windows
- name: Download Mystiks Core (cp312-win_amd64.pyd)
uses: actions/download-artifact@v4
with:
name: mystiks_core.cp312-win_amd64.pyd
- name: Move Mystiks Core (cp312-win_amd64.pyd)
run: mv mystiks_core.cp312-win_amd64.pyd ./mystiks/mystiks_core.cp312-win_amd64.pyd
# Download and move Mystiks Core for Python 3.13 on Windows
# - name: Download Mystiks Core (cp313-win_amd64.pyd)
# uses: actions/download-artifact@v4
# with:
# name: mystiks_core.cp313-win_amd64.pyd
# - name: Move Mystiks Core (cp313-win_amd64.pyd)
# run: mv mystiks_core.cp313-win_amd64.pyd ./mystiks/mystiks_core.cp313-win_amd64.pyd
- name: Build the package
run: python -m build
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
if: github.event_name == 'release' && github.event.action == 'published'
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: distribution
path: ./dist/*
if-no-files-found: error
retention-days: 90