-
-
Notifications
You must be signed in to change notification settings - Fork 225
273 lines (253 loc) · 7.79 KB
/
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
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
name: Python
on:
push:
branches:
- master
tags:
- 'v*'
permissions:
contents: write
jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- go_target: amd64
cibw_target: x86_64
#- go_target:'386
# cibw_target: i686
- go_target: arm64
cibw_target: aarch64
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
if: matrix.go_target == 'arm64'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: bindings/py
env:
CIBW_ARCHS: ${{ matrix.cibw_target }}
CIBW_MANYLINUX_I686_IMAGE: quay.io/pypa/manylinux_2_28_i686
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64
CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_28_aarch64
CIBW_BEFORE_ALL: .ci/ensure-go.sh; cd bindings/py; go get github.com/tdewolff/minify/v2@${{ github.ref_name }}; go build -buildmode=c-shared -o src/minify/minify.so
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.go_target }}
path: ./wheelhouse/*.whl
windows-go-crosscompile:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- go_target: amd64
xcompiler: x86_64-w64-mingw32-gcc-win32
# go_target: 386
# xcompiler: i686-w64-mingw32-gcc-win32
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '>=1.17'
- name: Fetch go package
run: |
cd bindings/py
go get github.com/tdewolff/minify/v2@${{ github.ref_name }}
- name: Prebuild windows extension
run: |
sudo apt-get install mingw-w64
cd bindings/py
CC=${{ matrix.xcompiler }} CGO_ENABLED=1 GOOS=windows GOARCH=${{ matrix.go_target }} go build -buildmode=c-shared -o minify.so
- name: Upload go library
uses: actions/upload-artifact@v4
with:
name: minify-windows-${{ matrix.go_target }}.so
path: bindings/py/minify.so
windows:
runs-on: windows-latest
needs: windows-go-crosscompile
strategy:
matrix:
include:
- go_target: amd64
cibw_target: AMD64
#- go_target: 386
# cibw_target: x86
#- go_target: arm64
# cibw_target: ARM64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '>=1.17'
- name: Update version in go.mod
run: |
cd bindings/py
go get github.com/tdewolff/minify/v2@${{ github.ref_name }}
- uses: actions/download-artifact@v4
with:
name: minify-windows-${{ matrix.go_target }}.so
path: bindings/py/src/minify
- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: bindings/py
env:
CIBW_ARCHS: ${{ matrix.cibw_target }}
CIBW_BUILD_VERBOSITY: 1
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-${{ matrix.go_target }}
path: ./wheelhouse/*.whl
macos-go-crosscompile:
runs-on: macos-latest
strategy:
matrix:
include:
- go_target: amd64
clang_target: x86_64
- go_target: arm64
clang_target: arm64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '>=1.17'
- name: Fetch go package
run: |
cd bindings/py
go get github.com/tdewolff/minify/v2@${{ github.ref_name }}
- name: Prebuild macos extension
run: |
cd bindings/py
export CGO_ENABLED=1
export GOOS=darwin
export GOARCH=${{ matrix.go_target }}
#export CFLAGS="-Wno-error=unused-command-line-argument -target ${{ matrix.clang_target }}-unknown-darwin-unknown"
export CC=gcc
go build -buildmode=c-shared -o minify.so
- name: Upload go library
uses: actions/upload-artifact@v4
with:
name: minify-darwin-${{ matrix.go_target }}.so
path: bindings/py/minify.so
macos:
runs-on: macos-latest
needs: macos-go-crosscompile
strategy:
matrix:
include:
- go_target: amd64
cibw_target: x86_64
#- go_target: arm64
# cibw_target: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '>=1.17'
- name: Update version in go.mod
run: |
cd bindings/py
go get github.com/tdewolff/minify/v2@${{ github.ref_name }}
- uses: actions/download-artifact@v4
with:
name: minify-darwin-${{ matrix.go_target }}.so
path: bindings/py/src/minify/minify.so
- uses: actions/download-artifact@v4
with:
name: minify-darwin-${{ matrix.go_target }}.so
path: bindings/py/minify.so
- uses: actions/download-artifact@v4
with:
name: minify-darwin-${{ matrix.go_target }}.so
path: src/minify/minify.so
- uses: actions/download-artifact@v4
with:
name: minify-darwin-${{ matrix.go_target }}.so
path: minify.so
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Debug
run: |
ls -la
ls -la bindings/py
ls -la bindings/py/src/minify
- name: Build wheels
uses: pypa/[email protected]
with:
package-dir: bindings/py
env:
CIBW_ARCHS: ${{ matrix.cibw_target }}
#CIBW_ENVIRONMENT: GOARCH='${{ matrix.go_target }} CGO_ENABLED=1'
#CIBW_BEFORE_ALL: cd bindings/py; go build -buildmode=c-shared -o src/minify/minify.so
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.go_target }}
path: ./wheelhouse/*.whl
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/setup-go@v5
with:
go-version: '>=1.17'
- name: Update version in go.mod
run: |
cd bindings/py
go get github.com/tdewolff/minify/v2@${{ github.ref_name }}
- name: Install dependencies
run: pip install build
- name: Build package
run: |
cd bindings/py
python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels
path: bindings/py/dist/*
release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [linux, windows, macos, sdist]
#needs: [linux, windows, sdist]
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: bindings/py/artifacts
- name: Bundle release artifacts
run: |
cd bindings/py/
rm -r artifacts/*.so
mkdir dist
mv artifacts/*/* dist/
- name: Upload to GitHub Release
uses: softprops/[email protected]
with:
files: bindings/py/dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: bindings/py/dist/