Nest the two library packages under a single import namespace so they can ship as one distribution: protocol/ -> smartthings_local/protocol/ ocf/ -> smartthings_local/ocf/ (git mv, history preserved) - Rewrite all imports protocol.* -> smartthings_local.protocol.*, ocf.* -> smartthings_local.ocf.* across the ocf modules, mqtt_demo/ (bridge, descriptor, samples), and tests. - Add pyproject.toml: dist name `smartthings-local`, hatch-vcs versioning from v* tags, wheel ships only smartthings_local/. - Add .github/workflows/publish.yml: build + PyPI Trusted Publishing on v* tags (OIDC, no stored token). - Force-include protocol/ocf_root_ca.pem via [tool.hatch.build] artifacts: it is tracked but matches .gitignore's *.pem, so hatchling's VCS file selection would drop it — and dtls_session.py loads it at runtime. - Update mqtt_demo Dockerfile COPY and deploy.sh tar allowlist to the single smartthings_local/ package. - .gitignore: build artifacts (_version.py, dist/, *.egg-info/). Validated: pytest tests/ (11 passed), python -m build produces sdist + wheel with the pem bundled, fresh pip install resolves all nested imports with the pem readable from site-packages.
51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
name: Publish to PyPI
|
|
|
|
# Publishes smartthings-local to PyPI on a version tag (v1.2.3).
|
|
# Uses PyPI Trusted Publishing (OIDC) — no API token is stored in the repo.
|
|
# One-time setup on PyPI: add a trusted publisher for this repo pointing at
|
|
# workflow `publish.yml` and environment `pypi`.
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build sdist + wheel
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # hatch-vcs needs full history + tags to derive the version
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
- run: python -m pip install --upgrade build
|
|
- run: python -m build
|
|
- name: Verify the built version matches the tag
|
|
run: |
|
|
ls -l dist/
|
|
version="${GITHUB_REF_NAME#v}"
|
|
if ! ls dist/ | grep -q "smartthings_local-${version}"; then
|
|
echo "Built artifacts do not match tag version ${version}"; exit 1
|
|
fi
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
|
|
publish:
|
|
name: Publish to PyPI
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
environment: pypi
|
|
permissions:
|
|
id-token: write # required for Trusted Publishing (OIDC)
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
- uses: pypa/gh-action-pypi-publish@release/v1
|