Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 70 additions & 4 deletions dev/create-release/release-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,73 @@ EOF
echo "Edited js/downloads.js"
fi

# 3. Add news post
# 3. Update the latest stable version in downloads.md and site/static/versions.json.
# site/downloads.html is regenerated from downloads.md by the jekyll build below,
# so it does not need to be edited here.
if [[ "$RELEASE_VERSION" =~ -preview[0-9]*$ ]]; then
echo "Skipping downloads.md and versions.json for preview release: $RELEASE_VERSION"
else
python3 <<EOF
import json
import re

release_version = "${RELEASE_VERSION}"

def parse_version(v):
return [int(p) for p in v.strip().split(".")]

def vercmp(v1, v2):
a = parse_version(v1)
b = parse_version(v2)
return (a > b) - (a < b)

# downloads.md: bump the Maven coordinate example to the latest stable version.
# Only update when this release is newer than the version currently shown, so a
# maintenance release on an older branch does not downgrade the coordinate.
with open("downloads.md") as f:
lines = f.readlines()

with open("downloads.md", "w") as f:
in_maven_block = False
for line in lines:
if re.match(r"\s*artifactId:\s*spark-core", line):
in_maven_block = True
m = re.match(r"(\s*version:\s*)(\d+\.\d+\.\d+)(\s*)$", line)
if in_maven_block and m:
if vercmp(release_version, m.group(2)) > 0:
line = f"{m.group(1)}{release_version}{m.group(3)}"
in_maven_block = False
f.write(line)

# site/static/versions.json: add (or replace) the entry for this release, keeping
# the list sorted in descending version order (it drives the API docs version picker).
path = "site/static/versions.json"
with open(path) as f:
versions = json.load(f)

entry = {
"name": release_version,
"version": release_version,
"url": f"https://spark.apache.org/docs/{release_version}/api/python/",
}

versions = [v for v in versions if v.get("version") != release_version]
insert_at = len(versions)
for i, v in enumerate(versions):
if vercmp(release_version, v.get("version", "0.0.0")) > 0:
insert_at = i
break
versions.insert(insert_at, entry)

with open(path, "w") as f:
json.dump(versions, f, indent=4)
f.write("\n")
EOF

echo "Edited downloads.md and site/static/versions.json"
fi

# 4. Add news post
RELEASE_DATE=$(TZ=America/Los_Angeles date +"%Y-%m-%d")
FILENAME="news/_posts/${RELEASE_DATE}-spark-${RELEASE_VERSION//./-}-released.md"
mkdir -p news/_posts
Expand Down Expand Up @@ -356,7 +422,7 @@ EOF

echo "Created $FILENAME"

# 4. Add release notes with Python to extract JIRA version ID
# 5. Add release notes with Python to extract JIRA version ID
if [[ "$RELEASE_VERSION" =~ -preview[0-9]*$ ]]; then
echo "Skipping JIRA release notes for preview release: $RELEASE_VERSION"
else
Expand Down Expand Up @@ -430,11 +496,11 @@ EOF
echo "Created $FILENAME"
fi

# 5. Build the website
# 6. Build the website
bundle install
bundle exec jekyll build

# 6. Update latest or preview symlink
# 7. Update latest or preview symlink
IFS='.' read -r rel_maj rel_min rel_patch <<< "$RELEASE_VERSION"

if [[ "$RELEASE_VERSION" =~ -preview[0-9]*$ ]]; then
Expand Down