-
Notifications
You must be signed in to change notification settings - Fork 3
148 lines (122 loc) · 4.47 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
name: CI build for PyPI
on:
push:
# branches:
# - master
tags:
- 'v*'
jobs:
build:
strategy:
matrix:
python-version: [3.11]
buildplat:
- platform: windows-2019
manylinux_type: ""
os_name: win
arch: AMD64
- platform: ubuntu-20.04
manylinux_type: manylinux
arch: x86_64
# - platform: ubuntu-20.04
# manylinux_type: musllinux
# arch: x86_64
python: [["cp36", "3.6"],["cp37", "3.7"],["cp38", "3.8"],["cp39", "3.9"],["cp310", "3.10"], ["cp311", "3.11"], ["cp312", "3.12"]]
runs-on: ${{ matrix.buildplat.platform }}
# if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: List files in repository
shell: bash
run: |
ls -R .
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install common dependencies
run: |
python -m pip install --upgrade pip
pip install Cython numpy pybind11 scipy
- name: Install C++ compiler (Windows)
if: matrix.buildplat.os_name == 'win'
uses: msys2/setup-msys2@v2
with:
install: mingw64/mingw-w64-x86_64-gcc
# - name: Install system dependencies
# run: |
# sudo apt-get update
# sudo apt-get install -y --no-install-recommends \
# libblas-dev \
# liblapack-dev
# 直接在env下设置环境变量
- name: Set CIBW variables
run: |
echo "CIBW_BUILD=${{ format('{0}-{1}*', matrix.python[0], (matrix.buildplat.manylinux_type || matrix.buildplat.os_name)) }}"
echo "CIBW_ARCHS=${{ matrix.buildplat.arch }}"
env:
CIBW_BUILD: ${{ format('{0}-{1}*', matrix.python[0], (matrix.buildplat.manylinux_type || matrix.buildplat.os_name)) }}
CIBW_ARCHS: ${{ matrix.buildplat.arch }}
- name: Build wheels with cibuildwheel
shell: bash
env:
CIBW_BUILD: ${{ format('{0}-{1}*', matrix.python[0], (matrix.buildplat.manylinux_type || matrix.buildplat.os_name)) }}
CIBW_ARCHS: ${{ matrix.buildplat.arch }}
run: |
pip install cibuildwheel
if [ "${{ matrix.buildplat.platform }}" = "windows-2019" ]; then
cibuildwheel --output-dir wheelhouse --platform windows --arch ${{ matrix.buildplat.arch }}
else
cibuildwheel --output-dir wheelhouse --platform linux --arch ${{ matrix.buildplat.arch }}
fi
- name: Save Wheel Package as Artifact
uses: actions/upload-artifact@v2
with:
name: wheelhouse
path: wheelhouse/*.whl
package_source:
runs-on: ubuntu-latest # 可以在任何平台上执行,这里假设选择Ubuntu
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python (for creating source distribution)
uses: actions/setup-python@v2
with:
python-version: '3.11' # 您可以选择一个合适的Python版本来构建源码包
- name: Install common dependencies
run: |
python -m pip install --upgrade pip
pip install Cython numpy pybind11 scipy
- name: Create source distribution
run: python setup.py sdist # 假设您的项目有一个setup.py文件
- name: Move source distribution to specific directory
run: |
mkdir dist_sources
mv dist/*.tar.gz dist_sources/ # 移动生成的源码包到新的目录
- name: Upload source distribution as artifact
uses: actions/upload-artifact@v2
with:
name: source-distribution
path: dist_sources/*
deploy_to_testpypi:
needs: [build, package_source]
runs-on: ubuntu-latest
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
steps:
- name: Download Wheel Package Artifact
uses: actions/download-artifact@v2
with:
name: wheelhouse
path: ./wheelhouse
- name: Download Source Distribution Artifact
uses: actions/download-artifact@v2
with:
name: source-distribution
path: ./source_distribution
- name: Publish to TestPyPI
run: |
pip install twine
twine upload --repository-url https://upload.pypi.org/legacy/ wheelhouse/*.whl source_distribution/*.tar.gz