Skip to content

Commit f2b2ac6

Browse files
committed
Allow building snapshots with the default relase_sdk flow
1 parent e17a3ce commit f2b2ac6

File tree

4 files changed

+33
-225
lines changed

4 files changed

+33
-225
lines changed

.github/workflows/snapshot.yml

Lines changed: 0 additions & 196 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
object BuildVersionsSDK {
2-
const val majorVersion = 25
3-
const val minorVersion = 4
4-
const val patchVersion = 22
2+
const val majorVersion = "25"
3+
const val minorVersion = "4"
4+
const val patchVersion = "22"
55
}

scripts/build-rust-for-target.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def read_version_numbers_from_kotlin_file(file_path):
3232
with open(file_path, "r") as file:
3333
content = file.read()
3434

35-
major_version = int(re.search(r"majorVersion\s*=\s*(\d+)", content).group(1))
36-
minor_version = int(re.search(r"minorVersion\s*=\s*(\d+)", content).group(1))
37-
patch_version = int(re.search(r"patchVersion\s*=\s*(\d+)", content).group(1))
35+
major_version = re.search(r'majorVersion\s*=\s*"(.+)"', content).group(1)
36+
minor_version = re.search(r'minorVersion\s*=\s*"(.+)"', content).group(1)
37+
patch_version = re.search(r'patchVersion\s*=\s*"(.+)"', content).group(1)
3838

3939
return major_version, minor_version, patch_version
4040

@@ -110,7 +110,10 @@ def execute_build_script(script_directory: str, sdk_path: str, module: Module, t
110110

111111
build_version_file_path = get_build_version_file_path(args.module, project_root)
112112
major, minor, patch = read_version_numbers_from_kotlin_file(build_version_file_path)
113-
if is_provided_version_higher(major, minor, patch, args.version):
113+
114+
if 'SNAPSHOT' in args.version:
115+
print(f"Version {args.version} is a SNAPSHOT version, skipping version check")
116+
elif is_provided_version_higher(major, minor, patch, args.version):
114117
print(
115118
f"The provided version ({args.version}) is higher than the previous version ({major}.{minor}.{patch}) so we can start the release process")
116119
else:

scripts/release_sdk.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def override_version_in_build_version_file(file_path: str, new_version: str):
2525
with open(file_path, 'r') as file:
2626
content = file.read()
2727

28-
new_major, new_minor, new_patch = map(int, new_version.split('.'))
28+
new_major, new_minor, new_patch = new_version.split('.')
2929

30-
content = re.sub(r"(majorVersion\s*=\s*)(\d+)", rf"\g<1>{new_major}", content)
31-
content = re.sub(r"(minorVersion\s*=\s*)(\d+)", rf"\g<1>{new_minor}", content)
32-
content = re.sub(r"(patchVersion\s*=\s*)(\d+)", rf"\g<1>{new_patch}", content)
30+
content = re.sub(r'(majorVersion\s*=\s*)"(.+)"', rf'\g<1>"{new_major}"', content)
31+
content = re.sub(r'(minorVersion\s*=\s*)"(.+)"', rf'\g<1>"{new_minor}"', content)
32+
content = re.sub(r'(patchVersion\s*=\s*)"(.+)"', rf'\g<1>"{new_patch}"', content)
3333

3434
with open(file_path, 'w') as file:
3535
file.write(content)
@@ -214,24 +214,25 @@ def main(args: argparse.Namespace):
214214
get_publish_task(args.module),
215215
)
216216

217-
# Success, commit and push changes, then create github release
218-
commit_message = f"Bump {args.module.name} version to {args.version} (matrix-rust-sdk to {args.linkable_ref})"
219-
print(f"Commit message: {commit_message}")
220-
commit_and_push_changes(project_root, commit_message)
221-
222-
release_name = f"{args.module.name.lower()}-v{args.version}"
223-
release_notes = f"https://github.com/matrix-org/matrix-rust-sdk/tree/{args.linkable_ref}"
224-
asset_path = get_asset_path(project_root, args.module)
225-
asset_name = get_asset_name(args.module)
226-
create_github_release(
227-
github_token,
228-
"https://api.github.com/repos/matrix-org/matrix-rust-components-kotlin",
229-
release_name,
230-
release_name,
231-
release_notes,
232-
asset_path,
233-
asset_name,
234-
)
217+
if not 'SNAPSHOT' in args.version:
218+
# Success, commit and push changes, then create github release
219+
commit_message = f"Bump {args.module.name} version to {args.version} (matrix-rust-sdk to {args.linkable_ref})"
220+
print(f"Commit message: {commit_message}")
221+
commit_and_push_changes(project_root, commit_message)
222+
223+
release_name = f"{args.module.name.lower()}-v{args.version}"
224+
release_notes = f"https://github.com/matrix-org/matrix-rust-sdk/tree/{args.linkable_ref}"
225+
asset_path = get_asset_path(project_root, args.module)
226+
asset_name = get_asset_name(args.module)
227+
create_github_release(
228+
github_token,
229+
"https://api.github.com/repos/matrix-org/matrix-rust-components-kotlin",
230+
release_name,
231+
release_name,
232+
release_notes,
233+
asset_path,
234+
asset_name,
235+
)
235236

236237

237238
parser = argparse.ArgumentParser()

0 commit comments

Comments
 (0)