ultralytics-actions 0.0.83__py3-none-any.whl → 0.0.84__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
actions/__init__.py CHANGED
@@ -22,4 +22,4 @@
22
22
  # ├── test_summarize_pr.py
23
23
  # └── ...
24
24
 
25
- __version__ = "0.0.83"
25
+ __version__ = "0.0.84"
actions/utils/__init__.py CHANGED
@@ -8,8 +8,9 @@ from .common_utils import (
8
8
  allow_redirect,
9
9
  remove_html_comments,
10
10
  )
11
- from .github_utils import GITHUB_API_URL, GITHUB_GRAPHQL_URL, Action, check_pypi_version, ultralytics_actions_info
11
+ from .github_utils import GITHUB_API_URL, GITHUB_GRAPHQL_URL, Action, ultralytics_actions_info
12
12
  from .openai_utils import get_completion
13
+ from .version_utils import check_pubdev_version, check_pypi_version
13
14
 
14
15
  __all__ = (
15
16
  "GITHUB_API_URL",
@@ -20,6 +21,7 @@ __all__ = (
20
21
  "REDIRECT_END_IGNORE_LIST",
21
22
  "Action",
22
23
  "allow_redirect",
24
+ "check_pubdev_version",
23
25
  "check_pypi_version",
24
26
  "get_completion",
25
27
  "remove_html_comments",
@@ -190,53 +190,3 @@ class Action:
190
190
  def ultralytics_actions_info():
191
191
  """Return GitHub Actions environment information and configuration details for Ultralytics workflows."""
192
192
  Action().print_info()
193
-
194
-
195
- def check_pypi_version(pyproject_toml="pyproject.toml"):
196
- """Compares local and PyPI package versions to determine if a new version should be published."""
197
- import re
198
-
199
- import tomllib # requires Python>=3.11
200
-
201
- version_pattern = re.compile(r"^\d+\.\d+\.\d+$") # e.g. 0.0.0
202
-
203
- with open(pyproject_toml, "rb") as f:
204
- pyproject = tomllib.load(f)
205
-
206
- package_name = pyproject["project"]["name"]
207
- local_version = pyproject["project"].get("version", "dynamic")
208
-
209
- # If version is dynamic, extract it from the specified file
210
- if local_version == "dynamic":
211
- version_attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
212
- module_path, attr_name = version_attr.rsplit(".", 1)
213
- with open(f"{module_path.replace('.', '/')}/__init__.py") as f:
214
- local_version = next(line.split("=")[1].strip().strip("'\"") for line in f if line.startswith(attr_name))
215
-
216
- print(f"Local Version: {local_version}")
217
- if not bool(version_pattern.match(local_version)):
218
- print("WARNING: Incorrect local version pattern")
219
- return "0.0.0", "0.0.0", False
220
-
221
- # Get online version from PyPI
222
- response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
223
- online_version = response.json()["info"]["version"] if response.status_code == 200 else None
224
- print(f"Online Version: {online_version or 'Not Found'}")
225
-
226
- # Determine if a new version should be published
227
- if online_version:
228
- local_ver = tuple(map(int, local_version.split(".")))
229
- online_ver = tuple(map(int, online_version.split(".")))
230
- major_diff = local_ver[0] - online_ver[0]
231
- minor_diff = local_ver[1] - online_ver[1]
232
- patch_diff = local_ver[2] - online_ver[2]
233
-
234
- publish = (
235
- (major_diff == 0 and minor_diff == 0 and 0 < patch_diff <= 2)
236
- or (major_diff == 0 and minor_diff == 1 and local_ver[2] == 0)
237
- or (major_diff == 1 and local_ver[1] == 0 and local_ver[2] == 0)
238
- ) # should publish an update
239
- else:
240
- publish = True # publish as this is likely a first release
241
-
242
- return local_version, online_version, publish
@@ -0,0 +1,70 @@
1
+ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
+
3
+ # from actions.utils.version_utils import check_pypi_version
4
+ # check_pypi_version()
5
+
6
+ import re
7
+ from pathlib import Path
8
+
9
+ import requests
10
+ import tomllib
11
+
12
+
13
+ def should_publish(local_version, remote_version):
14
+ """Determine if version should be published based on semver rules."""
15
+ if remote_version:
16
+ local_ver, remote_ver = [tuple(map(int, v.split("."))) for v in [local_version, remote_version]]
17
+ major_diff, minor_diff, patch_diff = [l - r for l, r in zip(local_ver, remote_ver)]
18
+ return (
19
+ (major_diff == 0 and minor_diff == 0 and 0 < patch_diff <= 2) # patch diff <=2
20
+ or (major_diff == 0 and minor_diff == 1 and local_ver[2] == 0) # new minor version
21
+ or (major_diff == 1 and local_ver[1] == 0 and local_ver[2] == 0) # new major version
22
+ ) # should publish an update
23
+ else:
24
+ return True # possible first release
25
+
26
+
27
+ def check_pypi_version(pyproject_toml="pyproject.toml"):
28
+ """Compare local and PyPI package versions to determine if a new version should be published."""
29
+ with open(pyproject_toml, "rb") as f:
30
+ pyproject = tomllib.load(f)
31
+
32
+ package_name = pyproject["project"]["name"]
33
+ local_version = pyproject["project"].get("version", "dynamic")
34
+
35
+ if local_version == "dynamic":
36
+ attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
37
+ module_path, attr_name = attr.rsplit(".", 1)
38
+ init_file = Path(module_path.replace(".", "/")) / "__init__.py"
39
+ local_version = next(
40
+ line.split("=")[1].strip().strip("'\"")
41
+ for line in init_file.read_text().splitlines()
42
+ if line.startswith(attr_name)
43
+ )
44
+
45
+ if not re.match(r"^\d+\.\d+\.\d+$", local_version):
46
+ print(f"WARNING: Incorrect version pattern: {local_version}")
47
+ return local_version, None, False
48
+
49
+ response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
50
+ remote_version = response.json()["info"]["version"] if response.status_code == 200 else None
51
+ print(f"Local: {local_version}, PyPI: {remote_version or 'Not Found'}")
52
+
53
+ return local_version, remote_version, should_publish(local_version, remote_version)
54
+
55
+
56
+ def check_pubdev_version(pubspec_yaml="pubspec.yaml"):
57
+ """Compare local and pub.dev package versions to determine if a new version should be published."""
58
+ content = Path(pubspec_yaml).read_text()
59
+ package_name = re.search(r"^name:\s*(.+)$", content, re.MULTILINE).group(1).strip()
60
+ local_version = re.search(r"^version:\s*(.+)$", content, re.MULTILINE).group(1).strip()
61
+
62
+ if not re.match(r"^\d+\.\d+\.\d+$", local_version):
63
+ print(f"WARNING: Incorrect version pattern: {local_version}")
64
+ return local_version, None, False
65
+
66
+ response = requests.get(f"https://pub.dev/api/packages/{package_name}")
67
+ remote_version = response.json()["latest"]["version"] if response.status_code == 200 else None
68
+ print(f"Local: {local_version}, pub.dev: {remote_version or 'Not Found'}")
69
+
70
+ return local_version, remote_version, should_publish(local_version, remote_version)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ultralytics-actions
3
- Version: 0.0.83
3
+ Version: 0.0.84
4
4
  Summary: Ultralytics Actions for GitHub automation and PR management.
5
5
  Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>
6
6
  Maintainer-email: Ultralytics <hello@ultralytics.com>
@@ -1,17 +1,18 @@
1
- actions/__init__.py,sha256=9YNukQw4V5oIQLSnwaexGsTxWPXqQnVS6mg7PBT2oh4,742
1
+ actions/__init__.py,sha256=Z5WUMTbBJ3h5WEoPBA-lyplNH4NIRfOdyqwegOy3Yi0,742
2
2
  actions/dispatch_actions.py,sha256=vbA4w_B8vMXMen__ck2WoDsUFCELjXOQbpLzZCmqTXg,4240
3
3
  actions/first_interaction.py,sha256=whphdBrWkcWRt6RgOeK2dUoGq3aBTqttQdokxVjkye4,16309
4
4
  actions/summarize_pr.py,sha256=NCaDSbw4PVoRbPJzji_Ua2HadI2pn7QOE_dy3VK9_cc,10463
5
5
  actions/summarize_release.py,sha256=OncODHx7XsmB-nPf-B1tnxUTcaJx6hM4JAMa9frypzM,7922
6
6
  actions/update_file_headers.py,sha256=dAu8RWOn-CkuFZHa5LT1-BvNxYX4FRQe2B1UDAjvG3I,6648
7
7
  actions/update_markdown_code_blocks.py,sha256=9PL7YIQfApRNAa0que2hYHv7umGZTZoHlblesB0xFj4,8587
8
- actions/utils/__init__.py,sha256=TXYvhFgDeAnosePM4jfOrEd6PlC7tWC-WMOgCB_T6Tw,728
8
+ actions/utils/__init__.py,sha256=7k4cmFX0Td99Uzgsd8Mm-E0xq5kQ5ZJoPM_oGCVD4CU,804
9
9
  actions/utils/common_utils.py,sha256=2eNwGJFigl9bBXcyWzdr8mr97Lrx7zFKWIFYugZcUJw,11736
10
- actions/utils/github_utils.py,sha256=FaC8kFx9kviT6coid8j_mBYL0GIkd4Unz_ViQovnWq0,10324
10
+ actions/utils/github_utils.py,sha256=JQivk6IW2UBeHGx7adIuWjId7D03AWziF6fOfG-Ad6A,8171
11
11
  actions/utils/openai_utils.py,sha256=09kW4K2LOc6KsWz5tijf2Piinhu3PIKPDVkRC3KyIxU,2943
12
- ultralytics_actions-0.0.83.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
13
- ultralytics_actions-0.0.83.dist-info/METADATA,sha256=j74Ku5UUIo6ilg_1lkz6WJt3-RjeO2gXVJqCZ-BRzIE,11638
14
- ultralytics_actions-0.0.83.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
15
- ultralytics_actions-0.0.83.dist-info/entry_points.txt,sha256=rvqr6Juj7lCJL1DQLwMmOrA8R2Q8tyR_dvCe0mYuJ8s,441
16
- ultralytics_actions-0.0.83.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
17
- ultralytics_actions-0.0.83.dist-info/RECORD,,
12
+ actions/utils/version_utils.py,sha256=oCFPrdzzzkORaT02JAfb9GcPFOIncTU1v_AXAfR8W6I,3157
13
+ ultralytics_actions-0.0.84.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
14
+ ultralytics_actions-0.0.84.dist-info/METADATA,sha256=3ifMiF4wPn5FGY2OpOdnucXZdE8PUFGZhA2AfXkZZSo,11638
15
+ ultralytics_actions-0.0.84.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
16
+ ultralytics_actions-0.0.84.dist-info/entry_points.txt,sha256=rvqr6Juj7lCJL1DQLwMmOrA8R2Q8tyR_dvCe0mYuJ8s,441
17
+ ultralytics_actions-0.0.84.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
18
+ ultralytics_actions-0.0.84.dist-info/RECORD,,