Skip to content

Commit 4ce9153

Browse files
committed
Add automated PyPI release workflow and local venv setup
1 parent 6493de6 commit 4ce9153

File tree

4 files changed

+103
-8
lines changed

4 files changed

+103
-8
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ jobs:
3030
- name: Install dependencies
3131
run: pip install -e .[test]
3232

33-
- name: Test with pytest
34-
run: |
35-
if [ "${{ matrix.python-version }}" == "3.11" ]; then
36-
pytest
37-
else
38-
pytest -k "not example"
39-
fi
33+
- name: Run tests
34+
run: pytest -k "not example"
35+
env:
36+
API_KEY: ${{secrets.API_KEY}}
37+
38+
- name: Run example tests
39+
if: matrix.python-version == '3.13'
40+
run: pytest -k "example"
4041
env:
4142
API_KEY: ${{secrets.API_KEY}}

.github/workflows/release.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v**']
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: false
10+
11+
jobs:
12+
test:
13+
name: Test / Python ${{ matrix.python-version }}
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
18+
steps:
19+
- uses: actions/checkout@v6
20+
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install dependencies
26+
run: pip install -e .[test]
27+
28+
- name: Run tests
29+
run: pytest -k "not example"
30+
env:
31+
API_KEY: ${{ secrets.API_KEY }}
32+
33+
- name: Run example tests
34+
if: matrix.python-version == '3.13'
35+
run: pytest -k "example"
36+
env:
37+
API_KEY: ${{ secrets.API_KEY }}
38+
39+
build:
40+
name: Build distribution
41+
needs: [test]
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v6
45+
46+
- uses: actions/setup-python@v5
47+
with:
48+
python-version: "3.13"
49+
50+
- name: Build sdist and wheel
51+
run: |
52+
pip install build
53+
python -m build
54+
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: dist
58+
path: dist/
59+
if-no-files-found: error
60+
61+
publish:
62+
name: Publish release
63+
needs: [build]
64+
runs-on: ubuntu-latest
65+
permissions:
66+
contents: write
67+
packages: write
68+
steps:
69+
- uses: actions/download-artifact@v4
70+
with:
71+
name: dist
72+
path: dist/
73+
74+
- name: Create GitHub Release
75+
env:
76+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
GH_REPO: ${{ github.repository }}
78+
run: gh release create ${{ github.ref_name }} dist/* --generate-notes
79+
80+
- name: Install twine
81+
run: pip install twine
82+
83+
- name: Publish to PyPI
84+
env:
85+
TWINE_USERNAME: __token__
86+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
87+
run: twine upload dist/*
88+
89+
- name: Publish to GitHub Packages
90+
env:
91+
TWINE_USERNAME: ${{ github.repository_owner }}
92+
TWINE_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
93+
run: twine upload --repository-url https://pypi.pkg.github.com/${{ github.repository_owner }} dist/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ __pycache__
1616

1717
.vscode
1818
t.py
19+
.venv/

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
NAME = "serpapi"
1616
DESCRIPTION = "The official Python client for SerpApi.com."
1717
URL = "https://github.com/serpapi/serpapi-python"
18-
EMAIL = "kenneth@serpapi.com"
18+
EMAIL = "team@serpapi.com"
1919
AUTHOR = "SerpApi.com"
2020
REQUIRES_PYTHON = ">=3.6.0"
2121
VERSION = None

0 commit comments

Comments
 (0)