|
8 | 8 | import subprocess |
9 | 9 | import time |
10 | 10 | import json |
11 | | -from datetime import datetime |
| 11 | +from datetime import datetime, timezone |
12 | 12 |
|
13 | 13 | NEXT_CHANGELOG_FILE_NAME = "NEXT_CHANGELOG.md" |
14 | 14 | CHANGELOG_FILE_NAME = "CHANGELOG.md" |
@@ -127,7 +127,7 @@ def clean_next_changelog(package_path: str) -> None: |
127 | 127 | content = file.read() |
128 | 128 |
|
129 | 129 | # Remove content between ### sections |
130 | | - cleaned_content = re.sub(r'(### [^\n]+\n)\n*([^#]+)', r'\1\n', content) |
| 130 | + cleaned_content = re.sub(r'(### [^\n]+\n).*?(?=(###|$))', r'\1\n', content) |
131 | 131 | # Ensure there is exactly one empty line before each section |
132 | 132 | cleaned_content = re.sub(r'(\n*)(###[^\n]+)', r'\n\n\2', cleaned_content) |
133 | 133 | # Find the version number |
@@ -160,19 +160,19 @@ def get_previous_tag_info(package: Package) -> Optional[TagInfo]: |
160 | 160 | changelog = f.read() |
161 | 161 |
|
162 | 162 | # Extract the latest release section using regex |
163 | | - match = re.search(r"## Release v[\d\.]+.*?(?=\n## (\[Release\] )?Release v|\Z)", changelog, re.S) |
| 163 | + match = re.search(r"## (\[Release\] )?Release v[\d\.]+.*?(?=\n## (\[Release\] )?Release v|\Z)", changelog, re.S) |
164 | 164 |
|
165 | 165 | # E.g., for new packages. |
166 | 166 | if not match: |
167 | 167 | return None |
168 | 168 |
|
169 | 169 | latest_release = match.group(0) |
170 | | - version_match = re.search(r'## Release v(\d+\.\d+\.\d+)', latest_release) |
| 170 | + version_match = re.search(r'## (\[Release\] )?Release v(\d+\.\d+\.\d+)', latest_release) |
171 | 171 |
|
172 | 172 | if not version_match: |
173 | 173 | raise Exception("Version not found in the changelog") |
174 | 174 |
|
175 | | - return TagInfo(package=package, version=version_match.group(1), content=latest_release) |
| 175 | + return TagInfo(package=package, version=version_match.group(2), content=latest_release) |
176 | 176 |
|
177 | 177 |
|
178 | 178 | def get_next_tag_info(package: Package) -> Optional[TagInfo]: |
@@ -304,13 +304,13 @@ def push_changes() -> None: |
304 | 304 |
|
305 | 305 | # Create the release metadata file |
306 | 306 | file_name = os.path.join(os.getcwd(), ".release_metadata.json") |
307 | | - metadata = {"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M:%S")} |
| 307 | + metadata = {"timestamp": datetime.now(tz=timezone.UTC).strftime("%Y-%m-%d %H:%M:%S%Z")} |
308 | 308 | with open(file_name, "w") as f: |
309 | 309 | json.dump(metadata, f, indent=4) |
310 | 310 |
|
311 | 311 | # Commit the changes |
312 | 312 | subprocess.check_output(['git', 'add', '--all']) # Stage all changes |
313 | | - subprocess.check_output(['git', 'commit', '-m', '"Release"']) # Commit with message "Release" |
| 313 | + subprocess.check_output(['git', 'commit', '-m', 'Release']) # Commit with message "Release" |
314 | 314 |
|
315 | 315 | # Push the changes |
316 | 316 | subprocess.check_output(['git', 'push']) # Step 3: Push the commit to the remote |
|
0 commit comments