1+ name : Version Check
2+ on :
3+ pull_request :
4+ types : [opened, synchronize]
5+ paths :
6+ - ' socketsecurity/**'
7+ - ' setup.py'
8+ - ' pyproject.toml'
9+
10+ jobs :
11+ check_version :
12+ runs-on : ubuntu-latest
13+ steps :
14+ - uses : actions/checkout@v4
15+ with :
16+ fetch-depth : 0 # Fetch all history for all branches
17+
18+ - name : Check version increment
19+ run : |
20+ # Get version from current PR
21+ PR_VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
22+
23+ # Get version from main branch
24+ git checkout origin/main
25+ MAIN_VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'")
26+
27+ # Compare versions using Python
28+ python3 -c "
29+ from packaging import version
30+ pr_ver = version.parse('${PR_VERSION}')
31+ main_ver = version.parse('${MAIN_VERSION}')
32+ if pr_ver <= main_ver:
33+ print(f'❌ Version must be incremented! Main: {main_ver}, PR: {pr_ver}')
34+ exit(1)
35+ print(f'✅ Version properly incremented from {main_ver} to {pr_ver}')
36+ "
37+
38+ - name : Comment on PR if version check fails
39+ if : failure()
40+ uses : actions/github-script@v7
41+ with :
42+ script : |
43+ const comment = `
44+ ❌ **Version Check Failed**
45+
46+ Please increment the version number in \`socketsecurity/__init__.py\`.
47+ Current version on main: \`${process.env.MAIN_VERSION}\`
48+ Your PR version: \`${process.env.PR_VERSION}\`
49+ `;
50+
51+ github.rest.issues.createComment({
52+ issue_number: context.issue.number,
53+ owner: context.repo.owner,
54+ repo: context.repo.name,
55+ body: comment
56+ })
0 commit comments