forked from xuri/excelize-py
-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (184 loc) · 7.06 KB
/
build.yml
File metadata and controls
213 lines (184 loc) · 7.06 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
on: [push, pull_request, release]
name: build
permissions:
contents: read
pull-requests: write
jobs:
test:
strategy:
matrix:
go-version: [1.25.x]
os: [ubuntu-24.04, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15.0-alpha.5"]
targetplatform: [x64]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
cache: false
- name: Install Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Checkout code
uses: actions/checkout@v6
- name: Get dependencies
run: |
env GO111MODULE=on go vet ./...
pip install coverage
- name: Build
run: go build -v .
- name: Test on Windows
env:
CGO_ENABLED: 1
if: matrix.os == 'windows-latest'
run: go build -buildmode=c-shared -o libexcelize.amd64.windows.dll main.go && coverage run -m unittest
- name: Test on Linux
env:
CGO_ENABLED: 1
if: matrix.os == 'ubuntu-24.04'
run: go build -buildmode=c-shared -o libexcelize.amd64.linux.so main.go && coverage run -m unittest
- name: Test on macOS
env:
CGO_ENABLED: 1
if: matrix.os == 'macos-latest'
run: go build -buildmode=c-shared -o libexcelize.arm64.darwin.dylib main.go && coverage run -m unittest
- name: Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: unittests
name: codecov-umbrella
build:
runs-on: ${{ matrix.os }}
needs: [test]
if: github.event_name == 'release' && github.event.action == 'published'
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, macos-latest]
steps:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: 1.25.x
cache: false
- name: Install Python
uses: actions/setup-python@v6
with:
python-version: "3.9"
- name: Checkout code
uses: actions/checkout@v6
- name: Get dependencies
run: |
env GO111MODULE=on go vet ./...
pip install coverage
- name: Build Linux Shared Library
if: matrix.os == 'ubuntu-24.04'
env:
CGO_ENABLED: 1
run: |
docker run --rm -v $PWD:/src -w /src quay.io/pypa/manylinux2014_x86_64 bash -c "
yum install -y wget || true
wget https://go.dev/dl/go1.25.7.linux-amd64.tar.gz && \
tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz && \
export PATH=/usr/local/go/bin:\$PATH && \
CGO_ENABLED=1 CC=gcc GOOS=linux GOARCH=amd64 \
go build -buildmode=c-shared -ldflags='-s -w' -trimpath \
-o libexcelize.amd64.linux.so main.go && \
rm -f libexcelize.*.h
"
docker run --rm -v $PWD:/src -w /src quay.io/pypa/manylinux2014_i686 bash -c "
yum install -y wget || true
wget https://go.dev/dl/go1.25.7.linux-386.tar.gz && \
tar -C /usr/local -xzf go1.25.7.linux-386.tar.gz && \
export PATH=/usr/local/go/bin:\$PATH && \
CGO_ENABLED=1 CC=gcc GOOS=linux GOARCH=386 \
go build -buildmode=c-shared -ldflags='-s -w' -trimpath \
-o libexcelize.386.linux.so main.go && \
rm -f libexcelize.*.h
"
- name: Build Linux ARM64 Shared Library
if: matrix.os == 'ubuntu-24.04-arm'
env:
CGO_ENABLED: 1
run: |
docker run --rm -v $PWD:/src -w /src quay.io/pypa/manylinux2014_aarch64 bash -c "
yum install -y wget || true
wget https://go.dev/dl/go1.25.7.linux-arm64.tar.gz && \
tar -C /usr/local -xzf go1.25.7.linux-arm64.tar.gz && \
export PATH=/usr/local/go/bin:\$PATH && \
CGO_ENABLED=1 CC=gcc GOOS=linux GOARCH=arm64 \
go build -buildmode=c-shared -ldflags='-s -w' -trimpath \
-o libexcelize.arm64.linux.so main.go && \
rm -f libexcelize.*.h
"
- name: Build Shared Library
if: matrix.os == 'macos-latest'
env:
CGO_ENABLED: 1
run: |
wget https://github.com/mstorsjo/llvm-mingw/releases/download/20260224/llvm-mingw-20260224-ucrt-macos-universal.tar.xz
tar -xzf llvm-mingw-20260224-ucrt-macos-universal.tar.xz
export PATH="$(pwd)/llvm-mingw-20260224-ucrt-macos-universal/bin:$PATH"
CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -trimpath -o libexcelize.amd64.windows.dll main.go
CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -ldflags "-s -w" -buildmode=c-shared -trimpath -o libexcelize.386.windows.dll main.go
CC=aarch64-w64-mingw32-gcc GOOS=windows GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -trimpath -o libexcelize.arm64.windows.dll main.go
CC=gcc GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -buildmode=c-shared -trimpath -o libexcelize.arm64.darwin.dylib main.go
CC=gcc GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -buildmode=c-shared -trimpath -o libexcelize.amd64.darwin.dylib main.go
rm -f libexcelize.*.h
- name: Upload Linux Artifacts
if: matrix.os == 'ubuntu-24.04'
uses: actions/upload-artifact@v7
with:
name: linux-artifacts
path: |
libexcelize.386.linux.so
libexcelize.amd64.linux.so
- name: Upload Linux ARM64 Artifacts
if: matrix.os == 'ubuntu-24.04-arm'
uses: actions/upload-artifact@v7
with:
name: linux-arm64-artifacts
path: |
libexcelize.arm64.linux.so
- name: Upload Darwin Artifacts
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v7
with:
name: darwin-artifacts
path: |
libexcelize.amd64.windows.dll
libexcelize.386.windows.dll
libexcelize.arm64.windows.dll
libexcelize.arm64.darwin.dylib
libexcelize.amd64.darwin.dylib
publish:
runs-on: ubuntu-latest
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/excelize
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Install Python
uses: actions/setup-python@v6
with:
python-version: "3.9"
- name: Checkout code
uses: actions/checkout@v6
- name: Download Artifacts
uses: actions/download-artifact@v8
with:
merge-multiple: true
path: ./
- name: Build Python Package
run: |
pip install build setuptools wheel
python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1