11name : Tests
22on :
33 push :
4+ # Tag pushes (v*) are handled by publish.yml, which runs the same matrix
5+ # before publishing — skip here to avoid running the suite twice.
6+ tags-ignore :
7+ - ' **'
48 paths-ignore :
59 - ' docs/**'
610 - ' README.md'
6165 name : coverage-${{ matrix.python-version }}
6266 path : coverage.xml
6367 if-no-files-found : warn
64- retention-days : 7
68+ retention-days : 7
69+
70+ # Publish a `.devN` pre-release wheel to TestPyPI on every push to dev,
71+ # gated on the full pytest matrix passing. Lives in this workflow (rather
72+ # than a separate `workflow_run`-triggered file) so that the gate is a
73+ # plain `needs:` dependency — `workflow_run` only fires from workflows
74+ # that exist on the default branch, which is a maintenance footgun.
75+ #
76+ # One-time setup required at https://test.pypi.org/manage/account/publishing/
77+ # Owner: Botts-Innovative-Research
78+ # Repo: OSHConnect-Python
79+ # Workflow: tests.yaml
80+ # Environment: publish-test
81+ # And in this repo's Settings -> Environments, create env `publish-test`.
82+ publish-test :
83+ needs : pytest
84+ if : github.event_name == 'push' && github.ref == 'refs/heads/dev'
85+ runs-on : ubuntu-latest
86+ environment :
87+ name : publish-test
88+ url : https://test.pypi.org/project/oshconnect/
89+ permissions :
90+ id-token : write # OIDC trusted publishing
91+ contents : read
92+ steps :
93+ - name : Checkout
94+ uses : actions/checkout@v5
95+
96+ - name : Install uv
97+ uses : astral-sh/setup-uv@v6
98+
99+ - name : Install Python 3.13
100+ run : uv python install 3.13
101+
102+ # Append `.dev<run_number>` to the version in pyproject.toml so each
103+ # dev push gets a fresh PEP 440-compliant pre-release (e.g.
104+ # 0.5.1a0 -> 0.5.1a0.dev42). The change lives only on the runner.
105+ - name : Auto-bump version with .devN suffix
106+ run : |
107+ python - <<'PY'
108+ import os, pathlib, re
109+ run = os.environ['GITHUB_RUN_NUMBER']
110+ p = pathlib.Path('pyproject.toml')
111+ src = p.read_text()
112+ new = re.sub(
113+ r'^(version\s*=\s*")([^"]+)(")',
114+ lambda m: f'{m.group(1)}{m.group(2)}.dev{run}{m.group(3)}',
115+ src, count=1, flags=re.M,
116+ )
117+ if new == src:
118+ raise SystemExit('No `version = "..."` line found in pyproject.toml')
119+ p.write_text(new)
120+ for line in new.splitlines():
121+ if line.startswith('version'):
122+ print(f'Bumped {line}')
123+ break
124+ PY
125+
126+ - name : Build
127+ run : uv build
128+
129+ - name : Publish to TestPyPI
130+ run : uv publish --publish-url https://test.pypi.org/legacy/
0 commit comments