Skip to content

Commit b6fe529

Browse files
authored
Create main.yml
1 parent 3ad8dfe commit b6fe529

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

.github/workflows/main.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Build and upload to PyPI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_wheels:
7+
name: Build wheels on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [windows-latest, ubuntu-latest]
12+
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
21+
- name: Run test.py in develop mode
22+
run: |
23+
python setup.py develop
24+
python -m pip install opencv-python
25+
26+
python --version
27+
python test.py
28+
- name: Build wheels for Linux
29+
if: matrix.os == 'ubuntu-latest'
30+
run: |
31+
pip install -U wheel setuptools auditwheel patchelf
32+
pip wheel . --verbose -w dist
33+
auditwheel repair dist/document_scanner_sdk*.whl --plat manylinux_2_24_$(uname -m)
34+
35+
- name: Build wheels for Windows
36+
if: matrix.os == 'windows-latest'
37+
run: |
38+
pip install -U wheel setuptools
39+
python setup.py bdist_wheel -d wheelhouse
40+
- uses: actions/upload-artifact@v2
41+
with:
42+
path: wheelhouse/*.whl
43+
44+
build_sdist:
45+
name: Build source distribution
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v2
49+
50+
- name: Build sdist
51+
run: python setup.py sdist -d dist
52+
53+
- uses: actions/upload-artifact@v2
54+
with:
55+
path: dist/*.tar.gz
56+
57+
upload_pypi:
58+
needs: [build_wheels, build_sdist]
59+
runs-on: ubuntu-latest
60+
# upload to PyPI on every tag starting with 'v'
61+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
62+
# alternatively, to publish when a GitHub Release is created, use the following rule:
63+
# if: github.event_name == 'release' && github.event.action == 'published'
64+
steps:
65+
- uses: actions/download-artifact@v2
66+
with:
67+
name: artifact
68+
path: dist
69+
70+
- uses: pypa/[email protected]
71+
with:
72+
user: __token__
73+
password: ${{ secrets.pypi_password }}
74+
skip_existing: true

0 commit comments

Comments
 (0)