stdb-cli 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,8 @@ build/
12
12
  # uv / venv
13
13
  .venv/
14
14
  .uv/
15
+ # stdb-cli is a published library — its lock file is not used by consumers or CI
16
+ packages/cli/uv.lock
15
17
 
16
18
  # Environment
17
19
  .env
@@ -30,3 +32,5 @@ htmlcov/
30
32
  .vscode/
31
33
  .idea/
32
34
  *.iml
35
+
36
+ .superpowers/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stdb-cli
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Requires-Python: >=3.12
5
5
  Requires-Dist: httpx>=0.28.0
6
6
  Requires-Dist: python-dotenv>=1.2.2
@@ -0,0 +1,124 @@
1
+ # stdb-cli
2
+
3
+ Command-line client for the STDB Service. Authenticates with an API key from the [STDB Portal](https://stdb-portal.csltaipeitech.com).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install stdb-cli
9
+ export STDB_API_KEY=<your-api-key>
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```bash
15
+ stdb search-location "大安區"
16
+ stdb search-dataset "台北租屋坪數"
17
+ stdb retrieve --cf demographics --cq population --res 8 --ts 2023-12-31 --location-id 12345
18
+ ```
19
+
20
+ Run `stdb --help` for the full command list.
21
+
22
+ ## Local Development
23
+
24
+ ```bash
25
+ cd packages/cli
26
+ uv sync
27
+ uv run stdb --help
28
+ ```
29
+
30
+ To test a local build:
31
+
32
+ ```bash
33
+ uv build
34
+ pip install dist/stdb_cli-<version>-py3-none-any.whl
35
+ ```
36
+
37
+ ## Releasing to PyPI
38
+
39
+ Releases are fully driven by Git tags. **You never run `uv publish` manually** — CI does it.
40
+
41
+ ### Step-by-step
42
+
43
+ 1. **Bump the version** in `pyproject.toml`:
44
+
45
+ ```toml
46
+ [project]
47
+ name = "stdb-cli"
48
+ version = "0.1.1" # ← bump here
49
+ ```
50
+
51
+ Follow [semver](https://semver.org): patch for fixes, minor for features, major for breaking changes.
52
+
53
+ 2. **Commit and push** the version bump:
54
+
55
+ ```bash
56
+ git add packages/cli/pyproject.toml
57
+ git commit -m "chore(cli): bump to 0.1.1"
58
+ git push
59
+ ```
60
+
61
+ 3. **Tag and push the tag** (tag must match the version, prefixed with `cli-v`):
62
+
63
+ ```bash
64
+ git tag cli-v0.1.1
65
+ git push origin cli-v0.1.1
66
+ ```
67
+
68
+ 4. **Watch the workflow** at GitHub → Actions → *Publish CLI to PyPI*. Once green, install with:
69
+
70
+ ```bash
71
+ pip install -U stdb-cli
72
+ ```
73
+
74
+ ### Why this order matters
75
+
76
+ The workflow verifies that the tag suffix (`0.1.1`) matches `pyproject.toml`'s `version` field. If you tag before bumping, CI fails on the first step — by design, to prevent accidentally publishing the wrong version. Always bump → commit → tag.
77
+
78
+ PyPI also does not allow overwriting an existing version. If a release fails partway through, bump to the next patch (`0.1.2`) rather than trying to re-push `0.1.1`.
79
+
80
+ ## CI/CD Design
81
+
82
+ Workflow file: [`.github/workflows/deploy-cli.yml`](../../.github/workflows/deploy-cli.yml)
83
+
84
+ ### Trigger
85
+
86
+ ```yaml
87
+ on:
88
+ push:
89
+ tags:
90
+ - 'cli-v*'
91
+ ```
92
+
93
+ Only tags matching `cli-v*` (e.g. `cli-v0.1.1`, `cli-v1.0.0`) trigger publishing. Pushes to branches, other tag patterns, and PRs do nothing — keeping the publish path narrow and intentional.
94
+
95
+ ### Steps
96
+
97
+ 1. **Checkout** the tagged commit.
98
+ 2. **Install uv** (via `astral-sh/setup-uv@v5`) and Python 3.12.
99
+ 3. **Verify tag vs. version**: extract the version from the tag (`cli-v0.1.1` → `0.1.1`), parse `pyproject.toml`'s `[project].version`, fail if they differ.
100
+ 4. **Build** the sdist and wheel with `uv build` into `dist/`.
101
+ 5. **Publish** to PyPI using `pypa/gh-action-pypi-publish@release/v1`.
102
+
103
+ ### Authentication: Trusted Publishing (OIDC)
104
+
105
+ The workflow uses [PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/) — no long-lived API token. Instead:
106
+
107
+ - The job declares `permissions: id-token: write`, letting GitHub Actions mint a short-lived OIDC token.
108
+ - PyPI verifies the token's claims (`repo = CityScience-TaipeiTech/STDB_mcp`, `workflow = deploy-cli.yml`, `environment = pypi`) against a publisher registered on the PyPI project page.
109
+ - If they match, PyPI accepts the upload. If anything is off (wrong repo, wrong workflow filename, wrong environment), upload is rejected.
110
+
111
+ This means there is no PyPI secret stored in this repository. A stolen API token can no longer be used to publish malicious versions — only a workflow run from this exact repo + workflow + environment can publish.
112
+
113
+ ### One-Time Setup (already done for this project)
114
+
115
+ For reference, the trusted publisher is configured at [pypi.org](https://pypi.org) → `stdb-cli` → Manage → Publishing:
116
+
117
+ | Field | Value |
118
+ | --------------- | ------------------------------ |
119
+ | Owner | `CityScience-TaipeiTech` |
120
+ | Repository name | `STDB_mcp` |
121
+ | Workflow name | `deploy-cli.yml` |
122
+ | Environment | `pypi` |
123
+
124
+ The matching `pypi` environment exists at GitHub → Settings → Environments.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "stdb-cli"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  requires-python = ">=3.12"
9
9
  dependencies = [
10
10
  "httpx>=0.28.0",
@@ -2,13 +2,17 @@ from __future__ import annotations
2
2
  import os
3
3
  import httpx
4
4
 
5
- STDB_ENDPOINT = os.getenv("STDB_ENDPOINT", "https://stdb-mcp.azurecontainerapps.io")
5
+ STDB_ENDPOINT = os.getenv("STDB_ENDPOINT", "https://stdb.csltaipeitech.com")
6
6
  STDB_API_KEY = os.getenv("STDB_API_KEY", "")
7
7
 
8
8
 
9
9
  def get_client() -> httpx.Client:
10
10
  if not STDB_API_KEY:
11
- raise SystemExit("STDB_API_KEY environment variable is not set.")
11
+ raise SystemExit(
12
+ "STDB_API_KEY environment variable is not set.\n"
13
+ "Get one at https://stdb-portal.csltaipeitech.com and run:\n"
14
+ " export STDB_API_KEY=<your-key>"
15
+ )
12
16
  return httpx.Client(
13
17
  base_url=f"{STDB_ENDPOINT}/v1",
14
18
  headers={"Authorization": f"Bearer {STDB_API_KEY}"},
File without changes