diff --git a/.gitignore b/.gitignore index 92bbd8b..b04a2d8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ __pycache__/ .idea/ .vscode/ tests/__pycache__/ +dist/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 63e0413..0ac72b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [0.3.2](https://github.com/syntasso/kratix-python/compare/v0.3.0...v0.3.2) (2025-11-23) + + +### Chores + +* setting python 3.10 as minimum required version +* configuring application for release +* exposing version in the package + + ## [0.3.0](https://github.com/syntasso/kratix-python/compare/v0.2.0...v0.3.0) (2025-10-29) diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..e3d1e03 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,54 @@ +# Releasing `kratix-sdk` + +This document captures the steps for cutting a new version of the SDK and publishing it to PyPI. + +1. **Set up Poetry credentials (one-time per machine)** + ```bash + poetry config repositories.testpypi https://test.pypi.org/legacy/ + # Use a TestPyPI API token copied from https://test.pypi.org/manage/account/token/ + poetry config pypi-token.testpypi + # For the main PyPI token (if not already configured) + poetry config pypi-token.pypi + ``` + Alternatively export `POETRY_HTTP_BASIC_TESTPYPI_USERNAME="__token__"` and `POETRY_HTTP_BASIC_TESTPYPI_PASSWORD=""` before publishing. + +2. **Prep the repo** + - Update `pyproject.toml` with the new version under `[tool.poetry]`. + - Add an entry to `CHANGELOG.md` summarising the release and changes. + - Commit your work before building artifacts. + +3. **Run quality checks** + ```bash + make install # installs dependencies + make fmt && make lint # optional but recommended + make test # run pytest + ``` + +4. **Build distributions** + ```bash + poetry build + ls dist/ # verify the wheel and sdist exist + tar tf dist/kratix-sdk-.tar.gz | head + ``` + Inspect the contents to ensure only expected files are included. + +5. **Publish to TestPyPI (recommended)** + ```bash + poetry publish --repository testpypi --build + python -m venv /tmp/kratix-sdk-test + source /tmp/kratix-sdk-test/bin/activate + pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple kratix-sdk== + ``` + Run a quick smoke test (`python -c "import kratix_sdk; print(kratix_sdk.__version__)"`) to ensure the build works. + +6. **Publish to PyPI** + ```bash + poetry publish --build + git tag v + git push origin main --tags + ``` + PyPI credentials/API token must be configured in `~/.pypirc` beforehand. + +7. **Communicate the release** + - Share release notes on the relevant channels. + - Update downstream sample projects if they pin versions. diff --git a/Readme.md b/Readme.md index 6ac95dd..da37d90 100644 --- a/Readme.md +++ b/Readme.md @@ -1,14 +1,17 @@ # kratix-python -You can read library document [here](https://syntasso.github.io/kratix-python). +Library documentation can be found [here](https://syntasso.github.io/kratix-python). ## Installation ```bash -# Install from git +# From PyPI (preferred once published) +pip install kratix-sdk + +# From the main branch pip install git+https://github.com/syntasso/kratix-python.git -# Or for development +# Editable install for local development pip install -e . ``` @@ -74,3 +77,5 @@ Library is under `kratix_sdk`. Examples of Promises using this library can be fo * `make fmt` code formatting using `ruff` * `make lint` linting using `ruff` + +See `RELEASING.md` for the tested release workflow when publishing to TestPyPI/PyPI. diff --git a/kratix_sdk/__init__.py b/kratix_sdk/__init__.py index 38084cd..ddd786b 100644 --- a/kratix_sdk/__init__.py +++ b/kratix_sdk/__init__.py @@ -1,3 +1,5 @@ +from importlib import metadata as importlib_metadata + from .status import Status from .resource import Resource from .kratix_sdk import ( @@ -12,6 +14,11 @@ from .promise import Promise from .types import GroupVersionKind, DestinationSelector +try: + __version__ = importlib_metadata.version("kratix-sdk") +except importlib_metadata.PackageNotFoundError: # pragma: no cover - source tree fallback + __version__ = "0.0.0" + __all__ = [ "Status", "Resource", @@ -25,4 +32,5 @@ "get_output_dir", "get_metadata_dir", "set_metadata_dir", + "__version__", ] diff --git a/kratix_sdk/kratix_sdk.py b/kratix_sdk/kratix_sdk.py index c52fc91..81278a2 100644 --- a/kratix_sdk/kratix_sdk.py +++ b/kratix_sdk/kratix_sdk.py @@ -154,7 +154,6 @@ def publish_status(self, resource: Resource, status: Status) -> None: body=body, ) - def is_promise_workflow(self) -> bool: """Returns true if the workflow is a promise workflow.""" return self.workflow_type() == "promise" @@ -169,4 +168,4 @@ def is_configure_action(self) -> bool: def is_delete_action(self) -> bool: """Returns true if the workflow is a delete action.""" - return self.workflow_action() == "delete" \ No newline at end of file + return self.workflow_action() == "delete" diff --git a/poetry.lock b/poetry.lock index 3aa7550..b5f22e6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. [[package]] name = "cachetools" @@ -742,5 +742,5 @@ test = ["websockets"] [metadata] lock-version = "2.1" -python-versions = ">=3.9" -content-hash = "7e130a3b27d684978c92f33c3ac8a11ec0655de9e2ac1529edb51660968efc9f" +python-versions = ">=3.10" +content-hash = "9df3f044d00d9fb3a7b7500fd9d58e5b9b192bb68b47ee9739ad84dbe4f2c248" diff --git a/pyproject.toml b/pyproject.toml index f612712..a2920aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,20 +4,41 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "kratix-sdk" -version = "0.3.0" +version = "0.3.2" description = "Kratix SDK for writing Promises workflows" readme = "Readme.md" +authors = ["Syntasso "] license = "Apache-2.0" homepage = "https://github.com/syntasso/kratix-python" repository = "https://github.com/syntasso/kratix-python" +documentation = "https://syntasso.github.io/kratix-python" +keywords = ["kratix", "platform-engineering", "promises", "sdk"] packages = [{include = "kratix_sdk"}] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Build Tools", + "Topic :: Utilities", +] + +[tool.poetry.urls] +"Source" = "https://github.com/syntasso/kratix-python" +"Documentation" = "https://syntasso.github.io/kratix-python" +"Bug Tracker" = "https://github.com/syntasso/kratix-python/issues" +"Changelog" = "https://github.com/syntasso/kratix-python/blob/main/CHANGELOG.md" [tool.poetry.dependencies] -python = ">=3.9" +python = ">=3.10" kubernetes = ">=33.0.0,<35" PyYAML = ">=6.0.0,<7" [tool.poetry.group.dev.dependencies] pytest = "8.4.2" ruff = "0.14.4" -pdoc = "^15" \ No newline at end of file +pdoc = "^15"