Skip to content
6 changes: 4 additions & 2 deletions release/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ def __defaults(kwargs):
kwargs["cwd"] = repo_dir


def has_staged_changes(**kwargs):
def ensure_no_staged_changes(**kwargs):
__defaults(kwargs)
execute("git diff --cached --exit-code --quiet", **kwargs)
return True


def has_unstaged_changes(**kwargs):
def ensure_no_unstaged_changes(**kwargs):
__defaults(kwargs)
execute("git diff --exit-code --quiet", **kwargs)
return True


def fetch_tags(remote=push_remote_name, **kwargs):
Expand Down
23 changes: 13 additions & 10 deletions release/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_jdk(version):
else: jdk_java_home = jdk_env["JAVA_HOME"]
java_version = execute(f"{jdk_java_home}/bin/java -version", env=jdk_env)
if (version == 8 and "1.8.0" not in java_version) or \
(f"{version}.0" not in java_version and '"{version}"' not in java_version):
(f"{version}.0" not in java_version and f'"{version}"' not in java_version):
preferences.unset(key)
fail(f"JDK {version} is required")
return jdk_env
Expand Down Expand Up @@ -127,14 +127,17 @@ def command_stage_docs():
if not os.path.exists(kafka_site_repo_path) or not os.path.exists(os.path.join(kafka_site_repo_path, "powered-by.html")):
fail("{kafka_site_repo_path} doesn't exist or does not appear to be the kafka-site repository")

jdk21_env = get_jdk(21)
jdk25_env = get_jdk(25)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chia7712
Thanks for the review.
I’ve made the related updates. Below is a comparison between the previous and updated versions:


Before

python release.py

Requirements:
1. Updated docs to reference the new release version where appropriate.
2. JDK8 and JDK17 compilers and libraries
3. Your Apache ID, already configured with SSH keys on id.apache.org and SSH keys available in this shell session
4. All issues in the target release resolved with valid resolutions (if not, this script will report the problematic JIRAs)
5. A GPG key used for signing the release. This key should have been added to public Apache servers and the KEYS file on the Kafka site
...

Do you have all of these setup? (y/n): 

After

python release.py

Requirements:
1. Updated docs to reference the new release version where appropriate.
2. JDK25 compiler and libraries
3. Your Apache ID, already configured with SSH keys on id.apache.org and SSH keys available in this shell session
4. All issues in the target release resolved with valid resolutions (if not, this script will report the problematic JIRAs)
5. A GPG key used for signing the release. This key should have been added to public Apache servers and the KEYS file on the Kafka site
...

Do you have all of these setup? (y/n): 


# We explicitly override the version of the project that we normally get from gradle.properties since we want to be
# able to run this from a release branch where we made some updates, but the build would show an incorrect SNAPSHOT
# version due to already having bumped the bugfix version number.
gradle_version_override = detect_docs_release_version(project_version)

cmd("Building docs", f"./gradlew -Pversion={gradle_version_override} clean siteDocsTar aggregatedJavadoc", cwd=repo_dir, env=jdk21_env)
cmd("Building docs",f"./gradlew -Pversion={gradle_version_override} clean siteDocsTar", cwd=repo_dir, env=jdk25_env,)
# Disable parallel execution for aggregatedJavadoc due to Gradle 9 issues
cmd("Building docs", f"./gradlew -Pversion={gradle_version_override} aggregatedJavadoc --no-parallel", cwd=repo_dir, env=jdk25_env,)


docs_tar = os.path.join(repo_dir, "core", "build", "distributions", f"kafka_2.13-{gradle_version_override}-site-docs.tgz")

Expand Down Expand Up @@ -229,7 +232,7 @@ def verify_gpg_key():
preferences.once(f"verify_gpg_key_{gpg_key_pass_id}", verify_gpg_key)

apache_id = preferences.get('apache_id', lambda: prompt("Please enter your apache-id: "))
jdk21_env = get_jdk(21)
jdk25_env = get_jdk(25)


def verify_prerequisites():
Expand All @@ -245,8 +248,8 @@ def prereq(name, soft_check):
fail(f"Pre-requisite not met: {name}. Error: {e}")
prereq('Apache Maven CLI (mvn) in PATH', lambda: "Apache Maven" in execute("mvn -v"))
prereq("svn CLI in PATH", lambda: "svn" in execute("svn --version"))
prereq("Verifying that you have no unstaged git changes", lambda: git.has_unstaged_changes())
prereq("Verifying that you have no staged git changes", lambda: git.has_staged_changes())
prereq("Verifying that you have no unstaged git changes", lambda: git.ensure_no_unstaged_changes())
prereq("Verifying that you have no staged git changes", lambda: git.ensure_no_staged_changes())
return True


Expand Down Expand Up @@ -328,9 +331,9 @@ def delete_gitrefs():


git.targz(rc_tag, f"kafka-{release_version}-src/", f"{artifacts_dir}/kafka-{release_version}-src.tgz")
cmd("Building artifacts", "./gradlew clean && ./gradlew releaseTarGz -PscalaVersion=2.13", cwd=kafka_dir, env=jdk21_env, shell=True)
cmd("Building artifacts", "./gradlew clean && ./gradlew releaseTarGz -PscalaVersion=2.13", cwd=kafka_dir, env=jdk25_env, shell=True)
cmd("Copying artifacts", f"cp {kafka_dir}/core/build/distributions/* {artifacts_dir}", shell=True)
cmd("Building docs", "./gradlew clean aggregatedJavadoc", cwd=kafka_dir, env=jdk21_env)
cmd("Building docs", "./gradlew clean aggregatedJavadoc --no-parallel", cwd=kafka_dir, env=jdk25_env)
cmd("Copying docs", f"cp -R {kafka_dir}/build/docs/javadoc {artifacts_dir}")

for filename in os.listdir(artifacts_dir):
Expand All @@ -355,8 +358,8 @@ def delete_gitrefs():
svn.commit_artifacts(rc_tag, artifacts_dir, work_dir)

confirm_or_fail("Going to build and upload mvn artifacts based on these settings:\n" + textfiles.read(global_gradle_props) + '\nOK?')
cmd("Building and uploading archives", "./gradlew publish -PscalaVersion=2.13", cwd=kafka_dir, env=jdk21_env, shell=True)
cmd("Building and uploading archives", "mvn deploy -Pgpg-signing", cwd=os.path.join(kafka_dir, "streams/quickstart"), env=jdk21_env, shell=True)
cmd("Building and uploading archives", "./gradlew publish -PscalaVersion=2.13", cwd=kafka_dir, env=jdk25_env, shell=True)
cmd("Building and uploading archives", "mvn deploy -Pgpg-signing", cwd=os.path.join(kafka_dir, "streams/quickstart"), env=jdk25_env, shell=True)

# TODO: Many of these suggested validation steps could be automated
# and would help pre-validate a lot of the stuff voters test
Expand Down
2 changes: 1 addition & 1 deletion release/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def requirements_instructions(prefs_file, prefs):
return f"""
Requirements:
1. Updated docs to reference the new release version where appropriate.
2. JDK8 and JDK17 compilers and libraries
2. JDK25 compiler and libraries
3. Your Apache ID, already configured with SSH keys on id.apache.org and SSH keys available in this shell session
4. All issues in the target release resolved with valid resolutions (if not, this script will report the problematic JIRAs)
5. A GPG key used for signing the release. This key should have been added to public Apache servers and the KEYS file on the Kafka site
Expand Down