Skip to content

Commit f7d8803

Browse files
chore(release): add trusted-publishing workflows and PyPI docs
1 parent 24eaee4 commit f7d8803

3 files changed

Lines changed: 129 additions & 6 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Publish Python Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
workflow_dispatch:
8+
inputs:
9+
repository:
10+
description: "Target index for publish"
11+
required: true
12+
default: testpypi
13+
type: choice
14+
options:
15+
- testpypi
16+
- pypi
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
build:
23+
name: Build Distribution Artifacts
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Check out source
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: "3.11"
34+
35+
- name: Validate tag matches pyproject version
36+
if: github.event_name == 'push'
37+
run: |
38+
PYTHONPATH=src python -m agentrules.core.utils.release_metadata \
39+
--tag "${GITHUB_REF_NAME}"
40+
41+
- name: Guard manual PyPI publish to tagged refs only
42+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.repository == 'pypi'
43+
run: |
44+
if [ "${GITHUB_REF_TYPE}" != "tag" ]; then
45+
echo "Manual PyPI publish must run from a tag ref (vX.Y.Z)."
46+
exit 1
47+
fi
48+
PYTHONPATH=src python -m agentrules.core.utils.release_metadata \
49+
--tag "${GITHUB_REF_NAME}"
50+
51+
- name: Install build tooling
52+
run: |
53+
python -m pip install --upgrade pip
54+
python -m pip install --upgrade build twine
55+
56+
- name: Build sdist and wheel
57+
run: python -m build
58+
59+
- name: Check built metadata
60+
run: python -m twine check dist/*
61+
62+
- name: Upload distribution artifacts
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: python-dist
66+
path: dist/*
67+
68+
publish-testpypi:
69+
name: Publish to TestPyPI
70+
needs: build
71+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.repository == 'testpypi'
72+
runs-on: ubuntu-latest
73+
environment: testpypi
74+
permissions:
75+
id-token: write
76+
77+
steps:
78+
- name: Download distribution artifacts
79+
uses: actions/download-artifact@v4
80+
with:
81+
name: python-dist
82+
path: dist
83+
84+
- name: Publish package distributions to TestPyPI
85+
uses: pypa/gh-action-pypi-publish@release/v1
86+
with:
87+
repository-url: https://test.pypi.org/legacy/
88+
packages-dir: dist
89+
90+
publish-pypi:
91+
name: Publish to PyPI
92+
needs: build
93+
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.repository == 'pypi')
94+
runs-on: ubuntu-latest
95+
environment: pypi
96+
permissions:
97+
id-token: write
98+
99+
steps:
100+
- name: Download distribution artifacts
101+
uses: actions/download-artifact@v4
102+
with:
103+
name: python-dist
104+
path: dist
105+
106+
- name: Publish package distributions to PyPI
107+
uses: pypa/gh-action-pypi-publish@release/v1
108+
with:
109+
packages-dir: dist

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ The pipeline captures metrics (elapsed time, agent counts) and hands them to the
7575

7676
## 📦 Installation
7777

78-
### Clone & bootstrap
78+
### Install from PyPI
79+
80+
```bash
81+
pip install agentrules
82+
```
83+
84+
### Install from source
7985

8086
```bash
8187
git clone https://github.com/trevor-nichols/agentrules-architect.git
@@ -104,7 +110,7 @@ Prefer module execution during development? Invoke the CLI with Python’s modul
104110
python -m agentrules analyze /path/to/project
105111
```
106112

107-
Need to skip local cloning? Install straight from GitHub (PyPI release pending):
113+
Need to install directly from GitHub instead of PyPI?
108114

109115
```bash
110116
pip install "git+https://github.com/trevor-nichols/agentrules-architect.git#egg=agentrules"
@@ -320,9 +326,18 @@ Toggle outputs with `agentrules configure --outputs` or via the config TOML.
320326
- Run targeted tests: `python tests/phase_3_test/run_test.py`
321327
- Deterministic smoke runs (CI/local without API calls): `agentrules analyze --offline tests/tests_input`
322328
- Full suite: `python -m unittest discover tests -v`
323-
- Releases are tag-driven: bump `[project].version` in `pyproject.toml`, commit it, create the matching `vX.Y.Z` tag, and push the tag to let GitHub Actions publish the GitHub Release automatically.
329+
- Releases are tag-driven: bump `[project].version` in `pyproject.toml`, commit, create matching `vX.Y.Z` tag, and push it.
330+
- GitHub Actions now publishes package artifacts with Trusted Publishing (OIDC) via `.github/workflows/publish-pypi.yml` (no long-lived PyPI API token).
331+
- Run a safe preflight publish first from Actions with `workflow_dispatch` and `repository = testpypi`; publish to production PyPI on tag push or manual `repository = pypi`.
324332
- Keep docs and presets in sync when adding providers (`config/agents.py`, `config/tools.py`, `core/agents/*`).
325333

334+
### Release Process (PyPI)
335+
336+
1. Update `[project].version` in `pyproject.toml`, then commit and push.
337+
2. Run `.github/workflows/publish-pypi.yml` manually with `repository = testpypi` to validate package upload first.
338+
3. Create and push matching tag `vX.Y.Z` to trigger Trusted Publishing to PyPI.
339+
4. The same tag also triggers `.github/workflows/release.yml` for GitHub Release artifact/notes.
340+
326341
## 🤝 Contributing
327342

328343
See `CONTRIBUTING.md` for detailed guidelines on workflows, testing, and pull request expectations. Issues and PRs are welcome—just ensure Ruff/Pyright/tests pass before submitting.

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "agentrules"
77
version = "3.4.0"
8-
description = "Interactive CLI for the CursorRules Architect multi-phase analysis pipeline."
8+
description = "AGENTS.md/CLAUDE.md generator and ExecPlan harness for coding agents"
99
readme = "README.md"
1010
authors = [{name = "trevor-nichols"}]
11-
license = {text = "MIT"}
11+
license = "MIT"
1212
requires-python = ">=3.11.9"
1313
keywords = ["cursor", "ai", "analysis", "cli", "agents"]
1414
classifiers = [
1515
"Programming Language :: Python :: 3",
1616
"Programming Language :: Python :: 3.11",
1717
"Programming Language :: Python :: 3.12",
18-
"License :: OSI Approved :: MIT License",
1918
"Operating System :: OS Independent"
2019
]
2120
dependencies = [

0 commit comments

Comments
 (0)