Skip to content

Commit 7db2930

Browse files
mgyuchtDatabricks SDK Release Bot
andauthored
[Internal] Fix tagging workflow to identify last release properly (#4437)
## Changes ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [ ] `make test` run locally - [ ] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [ ] using Go SDK - [ ] using TF Plugin Framework --------- Co-authored-by: Databricks SDK Release Bot <runner@runner.na5iqnsnq1cexms4eb3eya1vmg.ex.internal.cloudapp.net>
1 parent 438823c commit 7db2930

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

.release_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"timestamp": "2025-01-16 13:55:53"
2+
"timestamp": "2025-01-27 14:59:20"
33
}

tagging.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import subprocess
99
import time
1010
import json
11-
from datetime import datetime
11+
from datetime import datetime, timezone
1212

1313
NEXT_CHANGELOG_FILE_NAME = "NEXT_CHANGELOG.md"
1414
CHANGELOG_FILE_NAME = "CHANGELOG.md"
@@ -127,7 +127,7 @@ def clean_next_changelog(package_path: str) -> None:
127127
content = file.read()
128128

129129
# 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)
131131
# Ensure there is exactly one empty line before each section
132132
cleaned_content = re.sub(r'(\n*)(###[^\n]+)', r'\n\n\2', cleaned_content)
133133
# Find the version number
@@ -160,19 +160,19 @@ def get_previous_tag_info(package: Package) -> Optional[TagInfo]:
160160
changelog = f.read()
161161

162162
# 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)
164164

165165
# E.g., for new packages.
166166
if not match:
167167
return None
168168

169169
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)
171171

172172
if not version_match:
173173
raise Exception("Version not found in the changelog")
174174

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)
176176

177177

178178
def get_next_tag_info(package: Package) -> Optional[TagInfo]:
@@ -304,13 +304,13 @@ def push_changes() -> None:
304304

305305
# Create the release metadata file
306306
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")}
308308
with open(file_name, "w") as f:
309309
json.dump(metadata, f, indent=4)
310310

311311
# Commit the changes
312312
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"
314314

315315
# Push the changes
316316
subprocess.check_output(['git', 'push']) # Step 3: Push the commit to the remote

0 commit comments

Comments
 (0)