Skip to content

Commit 2da959e

Browse files
add actions for publishing dev versions to test.pypi
1 parent b4f169e commit 2da959e

4 files changed

Lines changed: 112 additions & 1 deletion

File tree

.github/workflows/publish-test.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Publish (TestPyPI)
2+
3+
# Fire only after the Tests workflow finishes. The job-level `if` further
4+
# restricts to successful runs on the `dev` branch.
5+
#
6+
# One-time setup required at https://test.pypi.org/manage/account/publishing/
7+
# Owner: Botts-Innovative-Research
8+
# Project: oshconnect
9+
# Workflow: publish-test.yml
10+
# Environment: publish-test
11+
# And in this repo's Settings -> Environments, create an env named
12+
# `publish-test` (no secrets needed; OIDC handles trust).
13+
on:
14+
workflow_run:
15+
workflows: ["Tests"]
16+
types: [completed]
17+
18+
permissions: {}
19+
20+
jobs:
21+
publish:
22+
if: >
23+
github.event.workflow_run.conclusion == 'success'
24+
&& github.event.workflow_run.head_branch == 'dev'
25+
runs-on: ubuntu-latest
26+
environment:
27+
name: publish-test
28+
url: https://test.pypi.org/project/oshconnect/
29+
permissions:
30+
id-token: write # OIDC trusted publishing
31+
contents: read
32+
33+
steps:
34+
- name: Checkout (matching the tested commit)
35+
uses: actions/checkout@v5
36+
with:
37+
ref: ${{ github.event.workflow_run.head_sha }}
38+
39+
- name: Install uv
40+
uses: astral-sh/setup-uv@v6
41+
42+
- name: Install Python 3.13
43+
run: uv python install 3.13
44+
45+
# Append `.dev<run_number>` to the version in pyproject.toml so each
46+
# dev push gets a fresh PEP 440-compliant pre-release (e.g.
47+
# 0.5.1a0 -> 0.5.1a0.dev42). The change is in-memory on the runner;
48+
# nothing is committed back to the repo.
49+
- name: Auto-bump version with .devN suffix
50+
run: |
51+
python - <<'PY'
52+
import os, pathlib, re
53+
run = os.environ['GITHUB_RUN_NUMBER']
54+
p = pathlib.Path('pyproject.toml')
55+
src = p.read_text()
56+
new = re.sub(
57+
r'^(version\s*=\s*")([^"]+)(")',
58+
lambda m: f'{m.group(1)}{m.group(2)}.dev{run}{m.group(3)}',
59+
src, count=1, flags=re.M,
60+
)
61+
if new == src:
62+
raise SystemExit("No `version = \"...\"` line found in pyproject.toml")
63+
p.write_text(new)
64+
for line in new.splitlines():
65+
if line.startswith("version"):
66+
print(f"Bumped {line}")
67+
break
68+
PY
69+
70+
- name: Build
71+
run: uv build
72+
73+
- name: Publish to TestPyPI
74+
run: uv publish --publish-url https://test.pypi.org/legacy/

.github/workflows/tests.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
name: Tests
2-
on: [ push, pull_request, workflow_dispatch ]
2+
on:
3+
push:
4+
paths-ignore:
5+
- 'docs/**'
6+
- 'README.md'
7+
- 'CLAUDE.md'
8+
- '.github/workflows/docs_pages.yaml'
9+
pull_request:
10+
paths-ignore:
11+
- 'docs/**'
12+
- 'README.md'
13+
- 'CLAUDE.md'
14+
- '.github/workflows/docs_pages.yaml'
15+
workflow_dispatch:
316

417
permissions: {}
518

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ Links:
99
* [Architecture Doc](https://docs.google.com/document/d/1pIaeQw0ocU6ApNgqTVRZuSwjJAbhCcmweMq6RiVYEic/edit?usp=sharing)
1010
* [UML Diagram](https://drive.google.com/file/d/1FVrnYiuAR8ykqfOUa1NuoMyZ1abXzMPw/view?usp=drive_link)
1111

12+
## Pre-releases
13+
14+
Every push to the `dev` branch publishes a `.devN` pre-release wheel to
15+
[TestPyPI](https://test.pypi.org/project/oshconnect/) once the test suite
16+
passes. To install the latest:
17+
18+
```bash
19+
pip install --index-url https://test.pypi.org/simple/ \
20+
--extra-index-url https://pypi.org/simple/ \
21+
oshconnect --pre
22+
```
23+
24+
The `--extra-index-url` is needed so transitive deps (pydantic, paho-mqtt,
25+
…) still resolve from real PyPI. Tagged releases (`v*`) continue to publish
26+
to real PyPI via `.github/workflows/publish.yml`.
27+
1228
## Running Tests
1329

1430
```bash
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"type": "PhysicalSystem",
3+
"id": "fake-weather-001",
4+
"uniqueId": "urn:osh:sensor:fakeweather:001",
5+
"label": "Fake Weather Station",
6+
"description": "A simulated weather station emitting temperature, pressure, wind speed, and wind direction.",
7+
"definition": "http://www.w3.org/ns/sosa/Sensor"
8+
}

0 commit comments

Comments
 (0)