ultralytics-actions 0.0.83__py3-none-any.whl → 0.0.85__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 +1 -1
- actions/utils/__init__.py +3 -1
- actions/utils/github_utils.py +2 -51
- actions/utils/version_utils.py +71 -0
- {ultralytics_actions-0.0.83.dist-info → ultralytics_actions-0.0.85.dist-info}/METADATA +1 -1
- {ultralytics_actions-0.0.83.dist-info → ultralytics_actions-0.0.85.dist-info}/RECORD +10 -9
- {ultralytics_actions-0.0.83.dist-info → ultralytics_actions-0.0.85.dist-info}/WHEEL +0 -0
- {ultralytics_actions-0.0.83.dist-info → ultralytics_actions-0.0.85.dist-info}/entry_points.txt +0 -0
- {ultralytics_actions-0.0.83.dist-info → ultralytics_actions-0.0.85.dist-info}/licenses/LICENSE +0 -0
- {ultralytics_actions-0.0.83.dist-info → ultralytics_actions-0.0.85.dist-info}/top_level.txt +0 -0
actions/__init__.py
CHANGED
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,
|
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",
|
actions/utils/github_utils.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
import json
|
4
4
|
import os
|
5
5
|
from pathlib import Path
|
6
|
+
from typing import Union
|
6
7
|
|
7
8
|
import requests
|
8
9
|
|
@@ -95,7 +96,7 @@ class Action:
|
|
95
96
|
"""Checks if the repository is public using event data or GitHub API if needed."""
|
96
97
|
return self.event_data.get("repository", {}).get("private")
|
97
98
|
|
98
|
-
def get_username(self) -> str
|
99
|
+
def get_username(self) -> Union[str, None]:
|
99
100
|
"""Gets username associated with the GitHub token."""
|
100
101
|
response = self.post(GITHUB_GRAPHQL_URL, json={"query": "query { viewer { login } }"})
|
101
102
|
if response.status_code == 200:
|
@@ -190,53 +191,3 @@ class Action:
|
|
190
191
|
def ultralytics_actions_info():
|
191
192
|
"""Return GitHub Actions environment information and configuration details for Ultralytics workflows."""
|
192
193
|
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,71 @@
|
|
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
|
+
|
11
|
+
|
12
|
+
def should_publish(local_version, remote_version):
|
13
|
+
"""Determine if version should be published based on semver rules."""
|
14
|
+
if remote_version:
|
15
|
+
local_ver, remote_ver = [tuple(map(int, v.split("."))) for v in [local_version, remote_version]]
|
16
|
+
major_diff, minor_diff, patch_diff = [l - r for l, r in zip(local_ver, remote_ver)]
|
17
|
+
return (
|
18
|
+
(major_diff == 0 and minor_diff == 0 and 0 < patch_diff <= 2) # patch diff <=2
|
19
|
+
or (major_diff == 0 and minor_diff == 1 and local_ver[2] == 0) # new minor version
|
20
|
+
or (major_diff == 1 and local_ver[1] == 0 and local_ver[2] == 0) # new major version
|
21
|
+
) # should publish an update
|
22
|
+
else:
|
23
|
+
return True # possible first release
|
24
|
+
|
25
|
+
|
26
|
+
def check_pypi_version(pyproject_toml="pyproject.toml"):
|
27
|
+
"""Compare local and PyPI package versions to determine if a new version should be published."""
|
28
|
+
import tomllib # scope for Python 3.11+
|
29
|
+
|
30
|
+
with open(pyproject_toml, "rb") as f:
|
31
|
+
pyproject = tomllib.load(f)
|
32
|
+
|
33
|
+
package_name = pyproject["project"]["name"]
|
34
|
+
local_version = pyproject["project"].get("version", "dynamic")
|
35
|
+
|
36
|
+
if local_version == "dynamic":
|
37
|
+
attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
|
38
|
+
module_path, attr_name = attr.rsplit(".", 1)
|
39
|
+
init_file = Path(module_path.replace(".", "/")) / "__init__.py"
|
40
|
+
local_version = next(
|
41
|
+
line.split("=")[1].strip().strip("'\"")
|
42
|
+
for line in init_file.read_text().splitlines()
|
43
|
+
if line.startswith(attr_name)
|
44
|
+
)
|
45
|
+
|
46
|
+
if not re.match(r"^\d+\.\d+\.\d+$", local_version):
|
47
|
+
print(f"WARNING: Incorrect version pattern: {local_version}")
|
48
|
+
return local_version, None, False
|
49
|
+
|
50
|
+
response = requests.get(f"https://pypi.org/pypi/{package_name}/json")
|
51
|
+
remote_version = response.json()["info"]["version"] if response.status_code == 200 else None
|
52
|
+
print(f"Local: {local_version}, PyPI: {remote_version or 'Not Found'}")
|
53
|
+
|
54
|
+
return local_version, remote_version, should_publish(local_version, remote_version)
|
55
|
+
|
56
|
+
|
57
|
+
def check_pubdev_version(pubspec_yaml="pubspec.yaml"):
|
58
|
+
"""Compare local and pub.dev package versions to determine if a new version should be published."""
|
59
|
+
content = Path(pubspec_yaml).read_text()
|
60
|
+
package_name = re.search(r"^name:\s*(.+)$", content, re.MULTILINE).group(1).strip()
|
61
|
+
local_version = re.search(r"^version:\s*(.+)$", content, re.MULTILINE).group(1).strip()
|
62
|
+
|
63
|
+
if not re.match(r"^\d+\.\d+\.\d+$", local_version):
|
64
|
+
print(f"WARNING: Incorrect version pattern: {local_version}")
|
65
|
+
return local_version, None, False
|
66
|
+
|
67
|
+
response = requests.get(f"https://pub.dev/api/packages/{package_name}")
|
68
|
+
remote_version = response.json()["latest"]["version"] if response.status_code == 200 else None
|
69
|
+
print(f"Local: {local_version}, pub.dev: {remote_version or 'Not Found'}")
|
70
|
+
|
71
|
+
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.
|
3
|
+
Version: 0.0.85
|
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=
|
1
|
+
actions/__init__.py,sha256=jess3LsfC_cceuNA1dxiALao54P5xKwz6AykB6ryao0,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=
|
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=
|
10
|
+
actions/utils/github_utils.py,sha256=wjivM9FPZwaItXpQiYbGbnGdK6v4ayLEFvQT2xhRLq4,8202
|
11
11
|
actions/utils/openai_utils.py,sha256=09kW4K2LOc6KsWz5tijf2Piinhu3PIKPDVkRC3KyIxU,2943
|
12
|
-
|
13
|
-
ultralytics_actions-0.0.
|
14
|
-
ultralytics_actions-0.0.
|
15
|
-
ultralytics_actions-0.0.
|
16
|
-
ultralytics_actions-0.0.
|
17
|
-
ultralytics_actions-0.0.
|
12
|
+
actions/utils/version_utils.py,sha256=lKY2lLtYdxejKvqD9hFJiARMrYMHnP_KC_zmcLUmD20,3188
|
13
|
+
ultralytics_actions-0.0.85.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
14
|
+
ultralytics_actions-0.0.85.dist-info/METADATA,sha256=YJYd3XUlMmFZ74rUBtBzLI5Z6Jy9EPp4UbweMpMs2J4,11638
|
15
|
+
ultralytics_actions-0.0.85.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
16
|
+
ultralytics_actions-0.0.85.dist-info/entry_points.txt,sha256=rvqr6Juj7lCJL1DQLwMmOrA8R2Q8tyR_dvCe0mYuJ8s,441
|
17
|
+
ultralytics_actions-0.0.85.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
|
18
|
+
ultralytics_actions-0.0.85.dist-info/RECORD,,
|
File without changes
|
{ultralytics_actions-0.0.83.dist-info → ultralytics_actions-0.0.85.dist-info}/entry_points.txt
RENAMED
File without changes
|
{ultralytics_actions-0.0.83.dist-info → ultralytics_actions-0.0.85.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|