diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..96ab015 --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,102 @@ +name: Publish Python Package + +'on': + push: + tags: + - v* + workflow_dispatch: + inputs: + publish_to_testpypi: + description: Publish package to TestPyPI instead of PyPI + required: true + default: false + type: boolean + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Verify tag matches pyproject version + if: startsWith(github.ref, 'refs/tags/') + run: | + PYPROJECT_VERSION=$(python - <<'PY' + import tomllib + + with open("pyproject.toml", "rb") as f: + data = tomllib.load(f) + print(data["tool"]["poetry"]["version"]) + PY + ) + + EXPECTED_TAG="v${PYPROJECT_VERSION}" + + if [[ "$GITHUB_REF_NAME" != "$EXPECTED_TAG" ]]; then + echo "Release tag must be '${EXPECTED_TAG}', but got '${GITHUB_REF_NAME}'." + exit 1 + fi + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Install build tools + run: python -m pip install --upgrade build twine + + - name: Build distributions + run: python -m build + + - name: Check package metadata + run: python -m twine check dist/* + + - name: Upload distributions + uses: actions/upload-artifact@v4 + with: + name: python-dist + path: dist/ + + publish-testpypi: + if: github.event_name == 'workflow_dispatch' && fromJSON(inputs.publish_to_testpypi) + runs-on: ubuntu-latest + needs: build + permissions: + id-token: write + environment: + name: development + url: https://test.pypi.org/p/omnia-timeseries + steps: + - name: Download distributions + uses: actions/download-artifact@v4 + with: + name: python-dist + path: dist/ + + - name: Publish to TestPyPI (trusted publishing) + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + publish-pypi: + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + needs: build + permissions: + id-token: write + environment: + name: production + url: https://pypi.org/p/omnia-timeseries + steps: + - name: Download distributions + uses: actions/download-artifact@v4 + with: + name: python-dist + path: dist/ + + - name: Publish to PyPI (trusted publishing) + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 427aa72..7f57ee4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,6 +20,26 @@ Here are some resources to help you get started with open source contributions: * Create a PR * Code review +### Release and versioning + +Follow the steps below for any release that is intended for PyPI. + +1. Update the package version in `pyproject.toml` under `[tool.poetry].version`. +2. Update `CHANGELOG.md` with the release notes for that exact version. +3. Merge the release PR to `main`. +4. Create and push a Git tag that exactly matches the package version prefixed with `v`. + +Examples: + +- `pyproject.toml` version `1.4.5` -> tag `v1.4.5` +- `pyproject.toml` version `1.4.5.post1` -> tag `v1.4.5.post1` + +Versioning policy: + +- Use `X.Y.Z` for normal releases (features/fixes). +- Use `X.Y.Z.postN` for packaging-only corrections where runtime behavior is unchanged. +- Do not create a release tag without first updating `pyproject.toml` to the matching version. + ### Issues #### Create a new issue diff --git a/README.md b/README.md index 9b73fb6..b124c27 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,22 @@ Python package for interacting with the [Omnia Industrial IoT Timeseries API](https://github.com/equinor/OmniaPlant/wiki). -## How do I get set up? ### +## Installation -To use the Python package, install it in the following manner: +Install from PyPI: + +``` +pip install omnia-timeseries +``` + +Install from GitHub (latest unreleased changes): ``` pip install git+https://github.com/equinor/omnia-timeseries-python.git@main ``` +Supported Python versions: 3.8+ (excluding 3.9.0 and 3.9.1) + For support, create an issue on GitHub. ## Example usage diff --git a/pyproject.toml b/pyproject.toml index 5cadec3..cc73a6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,28 @@ [tool.poetry] name = "omnia_timeseries" -version = "1.4.4.1" +version = "1.4.4.3" description = "Official Python SDK for the Omnia Timeseries API" readme = "README.md" authors = ["Equinor Omnia Industrial IoT Team "] -license = "LICENSE" +license = "MIT" +homepage = "https://github.com/equinor/omnia-timeseries-python" +repository = "https://github.com/equinor/omnia-timeseries-python" +documentation = "https://github.com/equinor/omnia-timeseries-python/blob/main/README.md" +keywords = ["omnia", "timeseries", "azure", "sdk", "industrial-iot"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Software Development :: Libraries :: Python Modules", +] +packages = [{ include = "omnia_timeseries", from = "src" }] [tool.poetry.dependencies] python = ">=3.8,<3.9.0 || >3.9.1,<4.0" @@ -26,6 +44,8 @@ black = ">=22.0,<26.0" [tool.poetry.urls] repository = "https://github.com/equinor/omnia-timeseries-python" +issues = "https://github.com/equinor/omnia-timeseries-python/issues" +changelog = "https://github.com/equinor/omnia-timeseries-python/blob/main/CHANGELOG.md" [tool.black] line-length = 88