Skip to content

Commit d5ff693

Browse files
committed
py ci
1 parent 37a13f2 commit d5ff693

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

.github/workflows/py.yaml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: PyPI 📦 Distribution
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
# https://github.com/Cryptex-github/ril-py/blob/main/.github/workflows/py-binding.yml
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.config.os }}
11+
name: ${{ matrix.config.name }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
config:
16+
- {
17+
os: ubuntu-latest,
18+
arch: x64,
19+
python-ver: '3.8',
20+
name: 'manylinux2014_x86_64'
21+
}
22+
- {
23+
os: ubuntu-latest,
24+
arch: x32,
25+
python-ver: '3.8',
26+
name: 'manylinux2014_i686'
27+
}
28+
- {
29+
os: ubuntu-latest,
30+
arch: x64,
31+
python-ver: '3.8',
32+
name: 'sdist'
33+
}
34+
# - {
35+
# os: macos-latest,
36+
# arch: x64,
37+
# python-ver: '3.8',
38+
# name: 'macos_x86_64'
39+
# }
40+
steps:
41+
- name: set up python
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: '3.9'
45+
46+
- name: set up rust
47+
uses: dtolnay/rust-toolchain@stable
48+
with:
49+
toolchain: stable
50+
51+
- name: Setup Rust cache
52+
uses: Swatinem/rust-cache@v2
53+
with:
54+
key: ${{ matrix.alt_arch_name }}
55+
56+
- name: Get pip cache dir
57+
id: pip-cache
58+
if: matrix.os != 'windows-latest'
59+
run: |
60+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
61+
62+
- name: Cache python dependencies
63+
uses: actions/cache@v3
64+
with:
65+
path: ${{ steps.pip-cache.outputs.dir || steps.pip-cache-win.outputs.dir }}
66+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
67+
68+
- name: install python dependencies
69+
run: pip install -U setuptools wheel twine cibuildwheel platformdirs
70+
71+
- name: Display cibuildwheel cache dir
72+
id: cibuildwheel-cache
73+
run: |
74+
from platformdirs import user_cache_path
75+
import os
76+
77+
with open(os.getenv('GITHUB_OUTPUT'), 'w') as f:
78+
f.write(f"dir={str(user_cache_path(appname='cibuildwheel', appauthor='pypa'))}")
79+
shell: python
80+
81+
- name: Cache cibuildwheel tools
82+
uses: actions/cache@v3
83+
with:
84+
path: ${{ steps.cibuildwheel-cache.outputs.dir }}
85+
key: ${{ runner.os }}-cibuildwheel-${{ matrix.python-version }}
86+
87+
- name: build sdist
88+
if: matrix.os == 'ubuntu' && matrix.python-version == 'cp310'
89+
run: |
90+
pip install maturin build
91+
python -m build --sdist -o wheelhouse
92+
93+
- name: build ${{ matrix.platform || matrix.os }} binaries
94+
run: cibuildwheel --output-dir wheelhouse
95+
env:
96+
CIBW_BUILD: '${{ matrix.python-version }}-*'
97+
# rust doesn't seem to be available for musl linux on i686
98+
CIBW_SKIP: '*-musllinux_i686'
99+
# we build for "alt_arch_name" if it exists, else 'auto'
100+
CIBW_ARCHS: ${{ matrix.alt_arch_name || 'auto' }}
101+
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"'
102+
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
103+
CIBW_BEFORE_BUILD: rustup show
104+
CIBW_BEFORE_BUILD_LINUX: >
105+
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y &&
106+
rustup show
107+
CIBW_TEST_COMMAND: 'pytest {project}/test'
108+
CIBW_TEST_REQUIRES: pytest requests
109+
CIBW_TEST_SKIP: '*-macosx_arm64 *-macosx_universal2:arm64'
110+
CIBW_BUILD_VERBOSITY: 1
111+
112+
- run: ${{ matrix.ls || 'ls -lh' }} wheelhouse/
113+
114+
- name: '📤 Upload artifact'
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: wheels
118+
path: wheelhouse/
119+
120+
publish:
121+
needs: [build]
122+
runs-on: ubuntu-latest
123+
if: startsWith(github.ref, 'refs/tags')
124+
steps:
125+
- uses: actions/download-artifact@v2
126+
with:
127+
name: artifact
128+
path: dist
129+
130+
- name: '📦 Publish distribution to PyPI'
131+
uses: pypa/gh-action-pypi-publish@master
132+
with:
133+
user: __token__
134+
password: ${{ secrets.pypi_pass }}

0 commit comments

Comments
 (0)