Skip to content

Commit 11b247c

Browse files
author
Anonymous Committer
committed
Automate Python tag-based PyPI releases
1 parent 6ee860f commit 11b247c

File tree

14 files changed

+194
-340
lines changed

14 files changed

+194
-340
lines changed

.github/workflows/generate.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: generate-sdks
1+
name: generate-python-sdk
22

33
on:
44
workflow_dispatch:
@@ -42,7 +42,7 @@ jobs:
4242
if: ${{ hashFiles('openapi/justserpapi.openapi.json') != '' }}
4343
uses: actions/upload-artifact@v4
4444
with:
45-
name: generated-sdks
45+
name: generated-python-sdk
4646
path: |
4747
.generated
4848
openapi/justserpapi.openapi.json

.github/workflows/python.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
55

6-
name: justserpapi Python package
6+
name: python-package
77

88
on: [push, pull_request]
99

@@ -27,11 +27,11 @@ jobs:
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install -r test-requirements.txt
30-
pip install -e .
30+
pip install .
3131
- name: Validate docs and tests
3232
run: |
3333
python scripts/sdkctl.py validate-examples
34-
pytest --cov=justserpapi
34+
python -m unittest discover -s tests -v
3535
- name: Build distribution artifacts
3636
run: |
3737
python -m build

.github/workflows/release.yml

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,60 @@
1-
name: release-sdks
1+
name: release-python
22

33
on:
4-
workflow_dispatch:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
id-token: write
511

612
jobs:
7-
sync-and-push:
13+
publish:
814
runs-on: ubuntu-latest
15+
environment:
16+
name: pypi
17+
url: https://pypi.org/project/justserpapi/
918
steps:
1019
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
1122
- uses: actions/setup-python@v5
1223
with:
1324
python-version: "3.11"
14-
- uses: actions/setup-java@v4
15-
with:
16-
distribution: temurin
17-
java-version: "21"
18-
- name: Install orchestration dependencies
19-
run: python -m pip install --upgrade pip
20-
- name: Fetch canonical spec when it is not committed
21-
if: ${{ hashFiles('openapi/justserpapi.openapi.json') == '' }}
22-
env:
23-
JUSTSERPAPI_API_KEY: ${{ secrets.JUSTSERPAPI_API_KEY }}
24-
run: python scripts/sdkctl.py fetch-spec
25-
- name: Require canonical spec
26-
run: test -f openapi/justserpapi.openapi.json
27-
- name: Generate release artifacts
25+
- name: Install release dependencies
2826
run: |
29-
python scripts/sdkctl.py validate-examples
30-
python scripts/sdkctl.py validate-spec
31-
python scripts/sdkctl.py generate --clean
32-
- name: Sync SDK repositories
27+
python -m pip install --upgrade pip
28+
pip install -r test-requirements.txt
29+
pip install .
30+
- name: Verify tag and package version
31+
run: python scripts/sdkctl.py verify-release --tag "${GITHUB_REF_NAME}"
32+
- name: Validate docs
33+
run: python scripts/sdkctl.py validate-examples
34+
- name: Run tests
35+
run: python -m unittest discover -s tests -v
36+
- name: Build distribution artifacts
37+
run: python -m build
38+
- name: Check distribution metadata
39+
run: python -m twine check dist/*
40+
- name: Smoke install built wheel
3341
env:
34-
SDK_REPO_PUSH_TOKEN: ${{ secrets.SDK_REPO_PUSH_TOKEN }}
35-
run: python scripts/sdkctl.py sync-repos --push --tag
42+
RELEASE_VERSION: ${{ github.ref_name }}
43+
run: |
44+
python -m venv .release-venv
45+
. .release-venv/bin/activate
46+
pip install dist/*.whl
47+
python - <<'PY'
48+
import os
49+
import justserpapi
50+
51+
expected = os.environ["RELEASE_VERSION"].removeprefix("v")
52+
assert justserpapi.__version__ == expected
53+
54+
client = justserpapi.Client(api_key="test-api-key")
55+
assert type(client).__name__ == "Client"
56+
assert type(client.google).__name__ == "GoogleResource"
57+
client.close()
58+
PY
59+
- name: Publish to PyPI
60+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
run: |
2222
python -m pip install --upgrade pip
2323
pip install -r test-requirements.txt
24-
pip install -e .
24+
pip install .
2525
- name: Run orchestration tests
2626
run: python -m unittest discover -s tests -v
2727
- name: Validate documentation examples

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ client.close()
9393

9494
## OpenAPI Control Plane
9595

96-
This repository is driven by the canonical OpenAPI document plus the SDK control-plane files in `config/`, `scripts/`, and `overlays/`.
96+
This repository only owns the Python SDK. The canonical OpenAPI document plus the Python-specific control-plane files in `config/`, `scripts/`, and `overlays/python/` drive generation and validation.
9797

9898
- If `openapi/justserpapi.openapi.json` is committed, local generation is fully reproducible.
9999
- If it is not committed, CI can fetch and cache it by running `python scripts/sdkctl.py fetch-spec` with `JUSTSERPAPI_API_KEY` configured.
@@ -106,6 +106,19 @@ python scripts/sdkctl.py validate-spec --skip-generator-validate
106106
python scripts/sdkctl.py generate --clean
107107
```
108108

109+
## Release
110+
111+
Official releases are tag-driven:
112+
113+
```bash
114+
python scripts/sdkctl.py verify-release --tag vX.Y.Z
115+
git push origin vX.Y.Z
116+
```
117+
118+
- The package version comes from `justserpapi/_version.py`
119+
- If `openapi/justserpapi.openapi.json` is committed, its `info.version` must match the tag and package version
120+
- GitHub Actions publishes tagged releases to PyPI through Trusted Publishing
121+
109122
## License
110123

111124
Distributed under the MIT License. See `LICENSE` for more information.

config/generators/go.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

config/generators/java.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

config/sdk-manifest.json

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"service": {
33
"name": "justserpapi",
44
"display_name": "JustSerpAPI",
5-
"description": "OpenAPI-first SDK release control plane for JustSerpAPI.",
5+
"description": "OpenAPI-first Python SDK release tooling for JustSerpAPI.",
66
"default_server_url": "https://api.justserpapi.com"
77
},
88
"spec": {
@@ -15,10 +15,7 @@
1515
"cache_dir": ".cache/openapi-generator"
1616
},
1717
"release": {
18-
"generated_dir": ".generated",
19-
"repositories_dir": ".repositories",
20-
"commit_message": "chore: regenerate SDKs from OpenAPI {{SPEC_VERSION}}",
21-
"tag_name": "v{{SPEC_VERSION}}"
18+
"generated_dir": ".generated"
2219
},
2320
"languages": {
2421
"python": {
@@ -35,42 +32,6 @@
3532
"remote": "git@github.com:justserpapi/justserpapi-python.git",
3633
"default_branch": "main"
3734
}
38-
},
39-
"java": {
40-
"generator": "java",
41-
"output_subdir": "java",
42-
"config_template": "config/generators/java.json",
43-
"overlay_dir": "overlays/java",
44-
"package": {
45-
"name": "justserpapi-java",
46-
"registry": "maven-central"
47-
},
48-
"repo": {
49-
"name": "justserpapi-java",
50-
"remote": "git@github.com:justserpapi/justserpapi-java.git",
51-
"default_branch": "main"
52-
},
53-
"group_id": "com.justserpapi",
54-
"artifact_id": "justserpapi",
55-
"invoker_package": "com.justserpapi.client",
56-
"api_package": "com.justserpapi.client.api",
57-
"model_package": "com.justserpapi.client.model"
58-
},
59-
"go": {
60-
"generator": "go",
61-
"output_subdir": "go",
62-
"config_template": "config/generators/go.json",
63-
"overlay_dir": "overlays/go",
64-
"package": {
65-
"name": "justserpapi",
66-
"registry": "go-proxy"
67-
},
68-
"repo": {
69-
"name": "justserpapi-go",
70-
"remote": "git@github.com:justserpapi/justserpapi-go.git",
71-
"default_branch": "main"
72-
},
73-
"module_name": "github.com/justserpapi/justserpapi-go"
7435
}
7536
}
7637
}

docs/openapi-governance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OpenAPI Governance
22

3-
The canonical OpenAPI document is the product. Every language SDK is a derivative artifact.
3+
The canonical OpenAPI document is the product. This repository owns the Python SDK derived from it.
44

55
## Required conventions
66

@@ -30,5 +30,5 @@ The canonical OpenAPI document is the product. Every language SDK is a derivativ
3030

3131
## Repository policy
3232

33-
- `justserpapi/`, `docs/`, and the current root Python package are legacy generated artifacts and not the future source of truth.
34-
- Future releases must come from `openapi/` plus `config/`, `scripts/`, and `overlays/`.
33+
- This repository is Python-only; it does not orchestrate Java, Go, or other SDK releases.
34+
- Future Python releases must come from `openapi/` plus `config/`, `scripts/`, and `overlays/python/`.

overlays/go/README.md.tmpl

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)