Skip to content

Commit 0d19e64

Browse files
authored
Fix uv lockfile sync + version incrementation checks (#204)
* update uv.lock to reflect new version Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> * update version check workflow to include uv.lock Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> * update python hooks to include uv sync Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> * remove unused setup.py check from workflow Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> * rev all versions to v2.2.89 Signed-off-by: lelia <2418071+lelia@users.noreply.github.com> --------- Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent 60219d3 commit 0d19e64

5 files changed

Lines changed: 44 additions & 7 deletions

File tree

.github/workflows/version-check.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
types: [opened, synchronize, ready_for_review]
55
paths:
66
- 'socketsecurity/**'
7-
- 'setup.py'
87
- 'pyproject.toml'
8+
- 'uv.lock'
99

1010
permissions:
1111
contents: read
@@ -46,6 +46,18 @@ jobs:
4646
print(f'✅ Version properly incremented from {main_ver} to {pr_ver}')
4747
"
4848
49+
- name: Require uv.lock update when pyproject changes
50+
run: |
51+
CHANGED_FILES="$(git diff --name-only origin/main...HEAD)"
52+
53+
if echo "$CHANGED_FILES" | grep -qx 'pyproject.toml'; then
54+
if ! echo "$CHANGED_FILES" | grep -qx 'uv.lock'; then
55+
echo "❌ pyproject.toml changed, but uv.lock was not updated."
56+
echo "Run 'uv lock' and commit uv.lock with the version bump."
57+
exit 1
58+
fi
59+
fi
60+
4961
- name: Manage PR Comment
5062
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
5163
if: always() && github.event.pull_request.head.repo.full_name == github.repository

.hooks/sync_version.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
INIT_FILE = pathlib.Path("socketsecurity/__init__.py")
1010
PYPROJECT_FILE = pathlib.Path("pyproject.toml")
11+
UV_LOCK_FILE = pathlib.Path("uv.lock")
1112

1213
VERSION_PATTERN = re.compile(r"__version__\s*=\s*['\"]([^'\"]+)['\"]")
1314
PYPROJECT_PATTERN = re.compile(r'^version\s*=\s*".*"$', re.MULTILINE)
@@ -72,6 +73,21 @@ def inject_version(version: str):
7273
new_pyproject = re.sub(r"(\[project\])", rf"\1\nversion = \"{version}\"", pyproject)
7374
PYPROJECT_FILE.write_text(new_pyproject)
7475

76+
77+
def run_uv_lock() -> bool:
78+
before = UV_LOCK_FILE.read_bytes() if UV_LOCK_FILE.exists() else b""
79+
try:
80+
subprocess.run(["uv", "lock"], check=True, text=True)
81+
except FileNotFoundError:
82+
print("❌ `uv` is required but was not found in PATH.")
83+
sys.exit(1)
84+
except subprocess.CalledProcessError:
85+
print("❌ `uv lock` failed. Please run it manually and fix any errors.")
86+
sys.exit(1)
87+
88+
after = UV_LOCK_FILE.read_bytes() if UV_LOCK_FILE.exists() else b""
89+
return before != after
90+
7591
def main():
7692
dev_mode = "--dev" in sys.argv
7793
current_version = read_version_from_init(INIT_FILE)
@@ -84,15 +100,24 @@ def main():
84100
base_version = current_version.split(".dev")[0] if ".dev" in current_version else current_version
85101
new_version = find_next_available_dev_version(base_version)
86102
inject_version(new_version)
87-
print("⚠️ Version was unchanged — auto-bumped. Please git add + commit again.")
103+
uv_lock_changed = run_uv_lock()
104+
lock_hint = " and uv.lock" if uv_lock_changed else ""
105+
print(f"⚠️ Version was unchanged — auto-bumped. Please git add{lock_hint} + commit again.")
88106
sys.exit(0)
89107
else:
90108
new_version = bump_patch_version(current_version)
91109
inject_version(new_version)
92-
print("⚠️ Version was unchanged — auto-bumped. Please git add + commit again.")
110+
uv_lock_changed = run_uv_lock()
111+
lock_hint = " and uv.lock" if uv_lock_changed else ""
112+
print(f"⚠️ Version was unchanged — auto-bumped. Please git add{lock_hint} + commit again.")
93113
sys.exit(1)
94114
else:
95-
print("✅ Version already bumped — proceeding.")
115+
uv_lock_changed = run_uv_lock()
116+
if uv_lock_changed:
117+
print("⚠️ Version already bumped, but uv.lock was out of date and has been updated. Please git add uv.lock + commit again.")
118+
sys.exit(1)
119+
120+
print("✅ Version already bumped and uv.lock is up to date — proceeding.")
96121
sys.exit(0)
97122

98123
if __name__ == "__main__":

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.2.88"
9+
version = "2.2.89"
1010
requires-python = ">= 3.11"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.2.88'
2+
__version__ = '2.2.89'
33
USER_AGENT = f'SocketPythonCLI/{__version__}'

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)