Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:
echo "wheel_path=$wheel_path" >> $GITHUB_OUTPUT
shell: bash

- name: Upload wheel as artifact
uses: actions/upload-artifact@v4
with:
name: python-wheel
path: dist/*.whl
overwrite: true
# - name: Upload wheel as artifact
# uses: actions/upload-artifact@v4
# with:
# name: python-wheel
# path: dist/*.whl
# overwrite: true
48 changes: 33 additions & 15 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Check if alpha release
id: check_alpha
run: |
# Get the version from the main package
VERSION=$(cat .release-please-manifest.json | jq -r '."."')
echo "version=$VERSION" >> $GITHUB_OUTPUT
if [[ "$VERSION" =~ [0-9]+\.[0-9]+\.[0-9]+a[0-9]+ ]]; then
echo "is_alpha=true" >> $GITHUB_OUTPUT
echo "Alpha version detected: $VERSION"
else
echo "is_alpha=false" >> $GITHUB_OUTPUT
echo "Stable version detected: $VERSION"
fi



- name: Install uv
Expand All @@ -75,12 +63,42 @@ jobs:
run: |
uv run python -c 'import otdf_python; print("Package imported successfully")'

- name: Store version
# While we improve the release process, prevent publishing to TestPyPI for versions <= 0.3.2
- name: Store version and determine if should publish to TestPyPI
id: check_version
shell: bash
run: |
PROJECT_VERSION=$(uv version --short)
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV

if [[ "$PROJECT_VERSION" =~ [0-9]+\.[0-9]+\.[0-9]+a[0-9]+ ]]; then
echo "is_alpha=true" >> $GITHUB_OUTPUT
echo "Alpha version detected: $PROJECT_VERSION"
else
echo "is_alpha=false" >> $GITHUB_OUTPUT
echo "Stable version detected: $PROJECT_VERSION"
fi

# Remove any alpha/beta/rc suffixes for comparison
CLEAN_VERSION=$(echo "$PROJECT_VERSION" | sed 's/[a-zA-Z].*//')
echo "clean_version=$CLEAN_VERSION" >> $GITHUB_OUTPUT

# Convert versions to comparable format (e.g., "0.3.2" -> "000300020000")
version_to_number() {
echo "$1" | awk -F. '{ printf("%04d%04d%04d\n", $1,$2,$3); }'
}

CURRENT_NUM=$(version_to_number "$CLEAN_VERSION")
THRESHOLD_NUM=$(version_to_number "0.3.2")

if [ "$CURRENT_NUM" -gt "$THRESHOLD_NUM" ]; then
echo "should_publish=true" >> $GITHUB_OUTPUT
echo "Version $PROJECT_VERSION (clean: $CLEAN_VERSION) is > 0.3.2, will publish to TestPyPI"
else
echo "should_publish=false" >> $GITHUB_OUTPUT
echo "Version $PROJECT_VERSION (clean: $CLEAN_VERSION) is <= 0.3.2, skipping TestPyPI publish"
fi

# For develop branch: trigger TestPyPI build (both alpha and stable releases go to TestPyPI from develop)

# Publish with "trusted publisher" mechanism:
Expand All @@ -89,7 +107,7 @@ jobs:
# Requires GHA token permission (above in YAML) and PyPI management:
# https://test.pypi.org/manage/project/otdf-python/settings/publishing/
- name: Publish package distributions to TestPyPI
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/chore/update-docs-and-release-process'
if: (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/chore/update-docs-and-release-process') && steps.check_version.outputs.should_publish == 'true'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ repos:
hooks:
- id: conventional-pre-commit
stages: [commit-msg,post-rewrite]
args: [--verbose,--scopes=feat,fix,docs,style,test,chore,ci]
args: [--verbose,--scopes="feat,fix,docs,style,test,chore,ci"]
12 changes: 2 additions & 10 deletions .release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,12 @@
"extra-files": [
"pyproject.toml",
"src/otdf_python/cli.py",
"tests/test_cli.py",
"RELEASES.md",
"otdf-python-proto/pyproject.toml",
{
"path": "uv.lock",
"type": "toml",
"jsonpath": "$.package[?(@.name.value=='otdf-python')].version"
}
]
},
"otdf-python-proto": {
"release-type": "python",
"package-name": "otdf-python-proto",
"extra-files": [
"otdf-python-proto/pyproject.toml",
},
{
"path": "otdf-python-proto/uv.lock",
"type": "toml",
Expand Down
4 changes: 2 additions & 2 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
".": "0.3.1",
"otdf-python-proto": "0.3.1"
".": "0.3.2",
"otdf-python-proto": "0.3.2"
}
2 changes: 1 addition & 1 deletion otdf-python-proto/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "otdf-python-proto"
version = "0.3.1"
version = "0.3.2"
description = "Generated protobuf files for OpenTDF Python SDK"
readme = "README.md"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion otdf-python-proto/src/otdf_python_proto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
and other OpenTDF services.
"""

__version__ = "0.3.1"
__version__ = "0.3.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding the version number here can lead to it becoming out of sync with the version in pyproject.toml. It's better to fetch the version dynamically from the package metadata. This ensures it's always correct and reduces maintenance effort during releases.

Suggested change
__version__ = "0.3.2"
__version__ = __import__('importlib.metadata').version('otdf-python-proto')


# Import submodules to make them available
from . import authorization
Expand Down
2 changes: 1 addition & 1 deletion otdf-python-proto/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "otdf-python"
version = "0.3.1"
version = "0.3.2"
description = "Unofficial OpenTDF SDK for Python"
readme = "README.md"
authors = [
Expand Down Expand Up @@ -38,6 +38,7 @@ dev = [
"pytest>=8.4.1",
"respx>=0.21.1",
"ruff>=0.12.10",
"tomli>=2.2.1 ; python_full_version < '3.11'",
]

[tool.pytest.ini_options]
Expand Down
2 changes: 1 addition & 1 deletion src/otdf_python/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


# Version - get from project metadata
__version__ = "0.3.0"
__version__ = "0.3.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding the version number here can lead to it becoming out of sync with the version in pyproject.toml. It's better to fetch the version dynamically from package metadata. This ensures it's always correct and reduces maintenance effort during releases.

Suggested change
__version__ = "0.3.2"
__version__ = __import__('importlib.metadata').version('otdf-python')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To avoid manually updating the version string in multiple places, you can read it dynamically from the package metadata using importlib.metadata. This will ensure it's always in sync with pyproject.toml.

You'll need to add from importlib import metadata at the top of the file.

Suggested change
__version__ = "0.3.2"
__version__ = metadata.version("otdf-python")



# Set up logging
Expand Down
15 changes: 14 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ def test_cli_version():
)
assert result.returncode == 0
assert "OpenTDF Python SDK" in result.stdout
assert "0.3.0" in result.stdout

with open(Path(__file__).parent.parent / "pyproject.toml", "rb") as f:
# Use tomli for Python < 3.11, tomllib for 3.11+
if sys.version_info < (3, 11):
import tomli

pyproject = tomli.load(f)
else:
import tomllib

pyproject = tomllib.load(f)
expected_version = pyproject["project"]["version"]

assert expected_version in result.stdout
Comment on lines +39 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is a great improvement to make the test more robust!

To further improve readability and adhere to best practices (like PEP 8, which recommends imports at the top of the file), you can move the conditional import logic to the top of the file and simplify the TOML loading.

At the top of tests/test_cli.py, add:

import sys
from pathlib import Path
if sys.version_info < (3, 11):
    import tomli as tomllib
else:
    import tomllib

Then you can simplify this part of the test.

    with open(Path(__file__).parent.parent / "pyproject.toml", "rb") as f:
        pyproject = tomllib.load(f)
    expected_version = pyproject["project"]["version"]

    assert expected_version in result.stdout



def test_cli_encrypt_help():
Expand Down
4 changes: 3 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading