Skip to content
Open
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
14 changes: 13 additions & 1 deletion .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
types: [opened, synchronize, ready_for_review]
paths:
- 'socketsecurity/**'
- 'setup.py'
- 'pyproject.toml'
- 'uv.lock'

permissions:
contents: read
Expand Down Expand Up @@ -46,6 +46,18 @@ jobs:
print(f'✅ Version properly incremented from {main_ver} to {pr_ver}')
"

- name: Require uv.lock update when pyproject changes
run: |
CHANGED_FILES="$(git diff --name-only origin/main...HEAD)"

if echo "$CHANGED_FILES" | grep -qx 'pyproject.toml'; then
if ! echo "$CHANGED_FILES" | grep -qx 'uv.lock'; then
echo "❌ pyproject.toml changed, but uv.lock was not updated."
echo "Run 'uv lock' and commit uv.lock with the version bump."
exit 1
fi
fi

- name: Manage PR Comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
if: always() && github.event.pull_request.head.repo.full_name == github.repository
Expand Down
31 changes: 28 additions & 3 deletions .hooks/sync_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

INIT_FILE = pathlib.Path("socketsecurity/__init__.py")
PYPROJECT_FILE = pathlib.Path("pyproject.toml")
UV_LOCK_FILE = pathlib.Path("uv.lock")

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


def run_uv_lock() -> bool:
before = UV_LOCK_FILE.read_bytes() if UV_LOCK_FILE.exists() else b""
try:
subprocess.run(["uv", "lock"], check=True, text=True)
except FileNotFoundError:
print("❌ `uv` is required but was not found in PATH.")
sys.exit(1)
except subprocess.CalledProcessError:
print("❌ `uv lock` failed. Please run it manually and fix any errors.")
sys.exit(1)

after = UV_LOCK_FILE.read_bytes() if UV_LOCK_FILE.exists() else b""
return before != after

def main():
dev_mode = "--dev" in sys.argv
current_version = read_version_from_init(INIT_FILE)
Expand All @@ -84,15 +100,24 @@ def main():
base_version = current_version.split(".dev")[0] if ".dev" in current_version else current_version
new_version = find_next_available_dev_version(base_version)
inject_version(new_version)
print("⚠️ Version was unchanged — auto-bumped. Please git add + commit again.")
uv_lock_changed = run_uv_lock()
lock_hint = " and uv.lock" if uv_lock_changed else ""
print(f"⚠️ Version was unchanged — auto-bumped. Please git add{lock_hint} + commit again.")
sys.exit(0)
else:
new_version = bump_patch_version(current_version)
inject_version(new_version)
print("⚠️ Version was unchanged — auto-bumped. Please git add + commit again.")
uv_lock_changed = run_uv_lock()
lock_hint = " and uv.lock" if uv_lock_changed else ""
print(f"⚠️ Version was unchanged — auto-bumped. Please git add{lock_hint} + commit again.")
sys.exit(1)
else:
print("✅ Version already bumped — proceeding.")
uv_lock_changed = run_uv_lock()
if uv_lock_changed:
print("⚠️ Version already bumped, but uv.lock was out of date and has been updated. Please git add uv.lock + commit again.")
sys.exit(1)

print("✅ Version already bumped and uv.lock is up to date — proceeding.")
sys.exit(0)

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"

[project]
name = "socketsecurity"
version = "2.2.88"
version = "2.2.89"
requires-python = ">= 3.11"
license = {"file" = "LICENSE"}
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__author__ = 'socket.dev'
__version__ = '2.2.88'
__version__ = '2.2.89'
USER_AGENT = f'SocketPythonCLI/{__version__}'
2 changes: 1 addition & 1 deletion uv.lock

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

Loading