-
Notifications
You must be signed in to change notification settings - Fork 19
130 lines (112 loc) · 3.55 KB
/
Copy pathrelease.yml
File metadata and controls
130 lines (112 loc) · 3.55 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
name: Release
on:
push:
tags: ['v**']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
test:
name: Test / Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install -e .[test]
- name: Run tests
run: pytest -k "not example"
env:
API_KEY: ${{ secrets.API_KEY }}
- name: Run example tests
if: matrix.python-version == '3.14'
run: pytest -k "example"
env:
API_KEY: ${{ secrets.API_KEY }}
build:
name: Build distribution
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Build sdist and wheel
run: |
pip install build
python -m build
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
if-no-files-found: error
publish:
name: Publish release
needs: [build]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/serpapi
permissions:
contents: write
id-token: write
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist/
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
gh release create ${{ github.ref_name }} dist/* --generate-notes \
|| gh release upload ${{ github.ref_name }} dist/* --clobber
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
smoke-test:
name: Smoke test published package
needs: [publish]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Wait for PyPI availability
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "Waiting for serpapi==$VERSION on PyPI..."
for i in $(seq 1 12); do
if pip index versions serpapi 2>/dev/null | grep -q "$VERSION"; then
echo "Available!"
exit 0
fi
echo "Attempt $i/12 — sleeping 10s..."
sleep 10
done
echo "Timed out waiting for PyPI propagation" && exit 1
- name: Install from PyPI
run: |
VERSION=${GITHUB_REF_NAME#v}
pip install "serpapi==$VERSION"
- name: Verify import and version
env:
API_KEY: ${{ secrets.API_KEY }}
EXPECTED_VERSION: ${{ github.ref_name }}
shell: python3 {0}
run: |
import os
import serpapi
expected = os.environ["EXPECTED_VERSION"].lstrip("v")
assert serpapi.__version__ == expected, f"Version mismatch: {serpapi.__version__} != {expected}"
print(f"OK: serpapi=={serpapi.__version__} installed successfully")
client = serpapi.Client(api_key=os.environ["API_KEY"])
results = client.search({"engine": "google", "q": "coffee"})
assert results.get("organic_results"), "No organic results returned"
print(f"OK: live search returned {len(results['organic_results'])} organic results")