|
29 | 29 | PYPROJECT_FILE = pathlib.Path("pyproject.toml") |
30 | 30 | README_FILES = [ |
31 | 31 | pathlib.Path("README.md"), |
| 32 | + pathlib.Path("blog.md"), |
32 | 33 | pathlib.Path("docs/github-action.md"), |
33 | 34 | pathlib.Path("docs/pre-commit-hook.md"), |
| 35 | + pathlib.Path("docs/local-install-docker.md"), |
| 36 | + pathlib.Path("docs/version-management.md"), |
| 37 | + pathlib.Path("docs/parameters.md"), |
34 | 38 | ] |
35 | 39 |
|
36 | 40 | VERSION_PATTERN = re.compile(r"__version__\s*=\s*['\"]([^'\"]+)['\"]") |
37 | 41 | PYPROJECT_PATTERN = re.compile(r'^version\s*=\s*"([^"]+)"$', re.MULTILINE) |
38 | 42 | # Pattern to match SocketDev/[email protected] or @vX.X.X |
39 | 43 | ACTION_VERSION_PATTERN = re.compile(r'(SocketDev/socket-basics|socket-basics)@v\d+\.\d+\.\d+') |
40 | | -# Pattern to match docker build with version tag |
41 | | -DOCKER_BUILD_PATTERN = re.compile(r'docker build -t (socketdev/socket-basics|socket-basics)(?::\d+\.\d+\.\d+)?') |
| 44 | +# Pattern to match docker build with optional version tag (handles both new and existing tags) |
| 45 | +DOCKER_BUILD_PATTERN = re.compile(r'docker build (?:--platform [^\s]+ )?-t ([^\s:]+)(?::\d+\.\d+\.\d+)?') |
| 46 | +# Pattern to match docker run commands with version tags |
| 47 | +DOCKER_RUN_PATTERN = re.compile(r'(docker run [^\n]*?)([^\s:]+):(\d+\.\d+\.\d+)') |
| 48 | +# Pattern to match standalone image references with version (in docker run or other contexts) |
| 49 | +IMAGE_VERSION_PATTERN = re.compile(r'\b(socket-basics|socketdev/socket-basics|myorg/security-scanner):(\d+\.\d+\.\d+)\b') |
42 | 50 | # Update this URL to match your actual PyPI package if you publish it |
43 | 51 | PYPI_API = "https://pypi.org/pypi/security-wrapper/json" |
44 | 52 |
|
@@ -113,10 +121,15 @@ def update_readme_versions(version: str): |
113 | 121 | content = ACTION_VERSION_PATTERN.sub(rf'\1@v{version}', content) |
114 | 122 |
|
115 | 123 | # Update docker build commands to include version tag |
116 | | - def docker_replacement(match): |
| 124 | + def docker_build_replacement(match): |
| 125 | + # Group 0 is the whole match, group 1 is the image name |
| 126 | + prefix = match.group(0).split('-t')[0] + '-t ' |
117 | 127 | image_name = match.group(1) |
118 | | - return f'docker build -t {image_name}:{version}' |
119 | | - content = DOCKER_BUILD_PATTERN.sub(docker_replacement, content) |
| 128 | + return f'{prefix}{image_name}:{version}' |
| 129 | + content = DOCKER_BUILD_PATTERN.sub(docker_build_replacement, content) |
| 130 | + |
| 131 | + # Update standalone image references with version (e.g., socket-basics:1.0.2) |
| 132 | + content = IMAGE_VERSION_PATTERN.sub(rf'\1:{version}', content) |
120 | 133 |
|
121 | 134 | if content != original_content: |
122 | 135 | readme_file.write_text(content) |
|
0 commit comments