-
-
Notifications
You must be signed in to change notification settings - Fork 3
173 lines (147 loc) · 4.77 KB
/
build_python.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
168
169
170
171
172
173
name: Python
on:
workflow_dispatch:
release:
types: [published]
pull_request:
branches: [master]
paths:
- "src/*.h"
- "src/*.cpp"
- "src/**/*.pyi"
- "src/CMakeLists.txt"
- "src/cmake/**"
- "src/utility/CMakeLists.txt"
- "src/utility/linux_kernel/*"
- ".github/workflows/build_python.yml"
push:
branches: [master]
paths:
- "src/*.h"
- "src/*.cpp"
- "src/**/*.pyi"
- "src/CMakeLists.txt"
- "src/cmake/**"
- "src/utility/CMakeLists.txt"
- "src/utility/linux_kernel/*"
- ".github/workflows/build_python.yml"
jobs:
check_source:
runs-on: ubuntu-latest
steps:
- name: Set up Python
id: python-setup
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Checkout Current Repo
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Install pre-commit, twine, and lib stubs
run: pip install pre-commit twine build .
- name: Create source distribution
run: python -m build -s
- name: Cache pre-commit venv
uses: actions/cache@v4
with:
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
path: '~/.cache/pre-commit'
- name: run pre-commit on all files
run: pre-commit run --all-files
- name: Checks distributable with twine
shell: bash
run: twine check dist/*
- name: Save distributable source as artifacts
uses: actions/upload-artifact@v4
with:
name: "cirque_pinnacle-sdist"
path: ${{ github.workspace }}/dist
build_linux:
runs-on: ubuntu-latest
needs: [check_source]
env:
BUILD_ARCH: native
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: |
sudo apt-get install python3-dev
python3 -m pip install --upgrade pip
python3 -m pip install twine
- name: Fetch distributable source artifact
uses: actions/download-artifact@v4
with:
name: "cirque_pinnacle-sdist"
path: ${{ github.workspace }}/sdist
- name: Try install from source distributable
run: pip install sdist/*.tar.gz -v
- name: Checkout Current Repo
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Build aarch64?
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
run: echo "BUILD_ARCH=aarch64 ${{ env.BUILD_ARCH }}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: contains(env.BUILD_ARCH, 'aarch64')
with:
platforms: aarch64
- name: Build binary wheels with cibuildwheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: ${{ env.BUILD_ARCH }}
CIBW_SKIP: cp36* pp* *musllinux*
- name: Move cross-compiled wheels to dist folder
run: |
mkdir -p dist
mv ./wheelhouse/*.whl ${{ github.workspace }}/dist/
- name: checks distributable with twine
run: python3 -m twine check dist/*
- name: Save distributable wheels as artifacts
uses: actions/upload-artifact@v4
with:
name: "cirque_pinnacle-bdist"
path: ${{ github.workspace }}/dist
release:
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
needs: [check_source, build_linux]
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Fetch distributable wheel artifacts
uses: actions/download-artifact@v4
with:
name: "cirque_pinnacle-bdist"
path: ${{ github.workspace }}/dist
- name: Fetch distributable source artifact
uses: actions/download-artifact@v4
with:
name: "cirque_pinnacle-sdist"
path: ${{ github.workspace }}/dist
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install twine
- name: Publish package (to TestPyPI)
if: github.event_name == 'workflow_dispatch'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: twine upload --repository testpypi dist/*
- name: Publish to PyPi
# only upload distributions to PyPi when triggered by a published release
if: github.event_name == 'release'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*