Skip to content

Commit

Permalink
Try to add changes to release unofficial versions of the library
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed May 3, 2024
1 parent ca733f6 commit 3ff127e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 40 deletions.
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/BuildVersionsCrypto.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object BuildVersionsCrypto {
const val majorVersion = 0
const val minorVersion = 3
const val patchVersion = 16
const val majorVersion = "0"
const val minorVersion = "3"
const val patchVersion = "16"
}
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/BuildVersionsSDK.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object BuildVersionsSDK {
const val majorVersion = 0
const val minorVersion = 2
const val patchVersion = 16
const val majorVersion = "0"
const val minorVersion = "2"
const val patchVersion = "16"
}
32 changes: 19 additions & 13 deletions scripts/build-rust-for-target.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def read_version_numbers_from_kotlin_file(file_path):
with open(file_path, "r") as file:
content = file.read()

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

return major_version, minor_version, patch_version

Expand Down Expand Up @@ -89,6 +89,8 @@ def execute_build_script(script_directory: str, sdk_path: str, module: Module, t
help="Choose a module (SDK or CRYPTO)")
parser.add_argument("-s", "--skip-clone", action="store_true", required=False,
help="Skip cloning the Rust SDK repository")
parser.add_argument("-c", "--skip-version-check", action="store_true", required=False,
help="Skip a version check")

args = parser.parse_args()

Expand All @@ -108,15 +110,19 @@ def execute_build_script(script_directory: str, sdk_path: str, module: Module, t
print(f"Version: {args.version}")
print(f"SDK git ref: {args.ref}")

build_version_file_path = get_build_version_file_path(args.module, project_root)
major, minor, patch = read_version_numbers_from_kotlin_file(build_version_file_path)
if is_provided_version_higher(major, minor, patch, args.version):
print(
f"The provided version ({args.version}) is higher than the previous version ({major}.{minor}.{patch}) so we can start the release process")
else:
print(
f"The provided version ({args.version}) is not higher than the previous version ({major}.{minor}.{patch}) so bump the version before retrying.")
exit(0)
if '-' in args.version:
args.skip_version_check = True

if args.skip_version_check != True:
build_version_file_path = get_build_version_file_path(args.module, project_root)
major, minor, patch = read_version_numbers_from_kotlin_file(build_version_file_path)
if is_provided_version_higher(major, minor, patch, args.version):
print(
f"The provided version ({args.version}) is higher than the previous version ({major}.{minor}.{patch}) so we can start the release process")
else:
print(
f"The provided version ({args.version}) is not higher than the previous version ({major}.{minor}.{patch}) so bump the version before retrying.")
exit(0)

if skip_clone is False:
clone_repo_and_checkout_ref(sdk_path, sdk_git_url, args.ref)
Expand All @@ -125,6 +131,6 @@ def execute_build_script(script_directory: str, sdk_path: str, module: Module, t

# Export Rust SDK path for next steps, if running in GitHub Actions
env_file_path = os.getenv('GITHUB_ENV')
if os.path.exists(env_file_path):
if env_file_path and os.path.exists(env_file_path):
with open(env_file_path, "a") as file:
file.write(f"RUST_SDK_PATH={sdk_path}")
42 changes: 21 additions & 21 deletions scripts/release_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def override_version_in_build_version_file(file_path: str, new_version: str):
with open(file_path, 'r') as file:
content = file.read()

new_major, new_minor, new_patch = map(int, new_version.split('.'))
new_major, new_minor, new_patch = new_version.split('.')

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

with open(file_path, 'w') as file:
file.write(content)
Expand Down Expand Up @@ -215,23 +215,23 @@ def main(args: argparse.Namespace):
)

# Success, commit and push changes, then create github release
commit_message = f"Bump {args.module.name} version to {args.version} (matrix-rust-sdk to {args.linkable_ref})"
print(f"Commit message: {commit_message}")
commit_and_push_changes(project_root, commit_message)

release_name = f"{args.module.name.lower()}-v{args.version}"
release_notes = f"https://github.com/matrix-org/matrix-rust-sdk/tree/{args.linkable_ref}"
asset_path = get_asset_path(project_root, args.module)
asset_name = get_asset_name(args.module)
create_github_release(
github_token,
"https://api.github.com/repos/matrix-org/matrix-rust-components-kotlin",
release_name,
release_name,
release_notes,
asset_path,
asset_name,
)
# commit_message = f"Bump {args.module.name} version to {args.version} (matrix-rust-sdk to {args.linkable_ref})"
# print(f"Commit message: {commit_message}")
# commit_and_push_changes(project_root, commit_message)
#
# release_name = f"{args.module.name.lower()}-v{args.version}"
# release_notes = f"https://github.com/matrix-org/matrix-rust-sdk/tree/{args.linkable_ref}"
# asset_path = get_asset_path(project_root, args.module)
# asset_name = get_asset_name(args.module)
# create_github_release(
# github_token,
# "https://api.github.com/repos/matrix-org/matrix-rust-components-kotlin",
# release_name,
# release_name,
# release_notes,
# asset_path,
# asset_name,
# )


parser = argparse.ArgumentParser()
Expand Down

0 comments on commit 3ff127e

Please sign in to comment.