forked from carlkidcrypto/ezsnmp
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (88 loc) · 3.33 KB
/
build_and_publish_to_pypi.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
# Refer to the following link for help
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: PyPI Distributions
concurrency: build_and_publish_to_pypi
on:
release:
types: [published]
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-14, macos-15]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install cibuildwheel
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build wheels using cibuildwheel
uses: carlkidcrypto/[email protected]
with:
linux: python -m cibuildwheel --output-dir wheelhouse --platform linux;
macos: |
MACOS_VERSION=$(sw_vers -productVersion)
if [[ "$MACOS_VERSION" == "10.15."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\110.15"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "11."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\111.0"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "12."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\112.0"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "13."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\113.0"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "14."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\114.0"/' pyproject.toml
elif [[ "$MACOS_VERSION" == "15."* ]]; then
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\115.0"/' pyproject.toml
else
sed -i '' 's/\(MACOSX_DEPLOYMENT_TARGET = "\)[^"]*"/\110.15"/' pyproject.toml
fi
python -m cibuildwheel --output-dir wheelhouse --platform macos;
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: wheelhouse/*.whl
build-n-publish-pypi:
name: Build and Publish To PyPi
runs-on: ubuntu-latest
needs: build_wheels
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Set up dependencies
uses: carlkidcrypto/[email protected]
with:
linux: sudo apt-get update;
sudo apt-get install -y libsnmp-dev libperl-dev;
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a source tarball
run: >-
python -m
build
--sdist
--outdir dist/
.
- name: Download Wheels
uses: actions/download-artifact@v4
with:
pattern: cibw-wheels-*
merge-multiple: true
path: dist/
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1.6
with:
print_hash: true
password: ${{ secrets.PYPI_API_TOKEN }}