Files
kotlin-fork/scripts/update-bootstrap
T
Dmitriy Novozhilov 37aad51438 [Build] Regenerate verification-metadata.xml in bootstrap-update script
This is needed for two purposes:
- sometimes dependencies may differ because of changes in KGP, and it's
  better to find it right after version-update commit, not only at remote run
- there is a plan to drop `trusted` section from `verification-metadata.xml`
  and always set specific versions of used dependencies even for bootstrap
  dependencies, so running it in regular bootstrap update routine won't
  allow forgetting about it (see KTI-1374)
2023-09-07 11:53:30 +00:00

39 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
import sys
import subprocess
def update_content(file_name, prefix, replacement):
with open(file_name, 'r', encoding='utf-8') as file:
data = file.readlines()
for i in range(len(data)):
line = data[i]
if prefix in line:
data[i] = replacement
with open(file_name, 'w', encoding='utf-8') as file:
file.writelines(data)
def git_add(*files):
subprocess.run(['git', 'add', *files], check=True)
def git_commit(message):
subprocess.run(['git', 'commit', message])
if __name__ == '__main__':
version = sys.argv[1]
properties = 'gradle.properties'
kotlinc = '.idea/kotlinc.xml'
update_content(properties, 'bootstrap.kotlin.default.version', f'bootstrap.kotlin.default.version={version}\n')
update_content(kotlinc, ' <option name="version" value=', f' <option name="version" value="{version}" />\n')
git_add(properties, kotlinc)
git_commit(f'Advance bootstrap to {version}')
subprocess.run(['sed', '-i', '-e', "'/<components>/,/<\/components>/d'", 'gradle/verification-metadata.xml'])
subprocess.run(['./gradlew', '-i', '--write-verification-metadata', 'sha256,md5', '-Pkotlin.native.enabled=true', 'resolveDependencies'])
status_output = subprocess.run(['git', 'status', '--porcelain'], capture_output=True).stdout
if len(status_output) != 0:
verification_metadata = "verification-metadata.xml"
git_add(f'gradle/{verification_metadata}')
git_commit(f'[Build] Update {verification_metadata}')