Skip to content
Merged
Show file tree
Hide file tree
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
44 changes: 34 additions & 10 deletions release/bin/prepare-rc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,33 +221,57 @@ step_summary "> it is a mechanical version bump on top of the verified"
step_summary "> commit above."

# ---------------------------------------------------------------------------
# Step 4: Set POM versions (only on rc0 or if version doesn't match)
# Step 4: Set POM version and SCM tag (whenever either doesn't match)
# ---------------------------------------------------------------------------
step_summary ""
step_summary "### Version Update"

current_pom_version=$(get_current_pom_version || echo "unknown")
current_scm_tag=$(get_current_pom_scm_tag || echo "unknown")
print_info "Current POM version: ${current_pom_version}"
print_info "Current POM SCM tag: ${current_scm_tag}"

if [[ "${current_pom_version}" == "${version}" ]]; then
print_info "POM version already set to ${version}, skipping version update"
step_summary "POM version already at \`${version}\`, no update needed"
if [[ "${current_pom_version}" == "${version}" && "${current_scm_tag}" == "${rc_tag}" ]]; then
print_info "POM version and SCM tag already set for ${rc_tag}, skipping update"
step_summary "POM version already at \`${version}\` and SCM tag at \`${rc_tag}\`, no update needed"
else
print_info "Setting POM version to ${version}..."
set_pom_version "${version}"
step_summary "Updated POM version: \`${current_pom_version}\` -> \`${version}\`"
if [[ "${current_pom_version}" != "${version}" ]]; then
print_info "Setting POM version to ${version}..."
set_pom_version "${version}"
step_summary "Updated POM version: \`${current_pom_version}\` -> \`${version}\`"
fi

# Each RC needs its own tag here, so this also runs on rc1+ when the
# version is already set. Whatever the branch carried is overwritten.
if [[ "${current_scm_tag}" != "${rc_tag}" ]]; then
print_info "Setting POM SCM tag to ${rc_tag}..."
set_pom_scm_tag "${rc_tag}"
step_summary "Updated POM SCM tag: \`${current_scm_tag}\` -> \`${rc_tag}\`"
fi

# Commit version changes. Stage tracked files only: set_pom_version only
# edits existing POMs, and anything untracked must not land in the release.
# Commit version changes. Stage tracked files only: the version and SCM tag
# updates only edit existing POMs, and anything untracked must not land in
# the release.
exec_process git add -u
exec_process git commit -m "Set version to ${version} for release"
exec_process git commit -m "Set version to ${version} for release (${rc_tag})"
fi

if ! require_clean_worktree; then
step_summary "Working tree check: **FAILED** (see the job log for the offending paths)"
exit 1
fi

# The staged POMs are what Maven Central publishes, so refuse to tag and
# deploy a commit whose <scm><tag> doesn't name this RC.
if [[ ${DRY_RUN:-1} -ne 1 ]]; then
committed_scm_tag=$(get_current_pom_scm_tag || echo "unknown")
if [[ "${committed_scm_tag}" != "${rc_tag}" ]]; then
print_error "POM SCM tag is '${committed_scm_tag}', expected '${rc_tag}'"
step_summary "SCM tag check: **FAILED** (\`${committed_scm_tag}\` != \`${rc_tag}\`)"
exit 1
fi
fi

# ---------------------------------------------------------------------------
# Step 5: Create RC tag locally (pushed in step 9)
# ---------------------------------------------------------------------------
Expand Down
15 changes: 14 additions & 1 deletion release/bin/publish-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ if ! git rev-parse "${rc_tag}" >/dev/null 2>&1; then
exit 1
fi

# The workflow is dispatched from master, which is where these scripts live,
# so switch to the release branch before comparing it with the RC tag. This
# runs in dry-run mode too: it is local, and the checks below depend on it.
release_branch="${BRANCH_PREFIX}${major}.${minor}.x"
if [[ "$(git branch --show-current)" != "${release_branch}" ]]; then
print_info "Switching to ${release_branch}..."
if ! git checkout "${release_branch}"; then
print_error "Could not check out release branch ${release_branch}"
exit 1
fi
fi

rc_commit=$(git rev-list -1 "${rc_tag}")
current_commit=$(git rev-parse HEAD)

Expand Down Expand Up @@ -314,6 +326,7 @@ next_snapshot="${next_dev_version}-SNAPSHOT"
print_info "Bumping version to ${next_snapshot}..."

set_pom_version "${next_snapshot}"
set_pom_scm_tag "HEAD"

# Update previous.version property
exec_process ./mvnw -pl . versions:set-property \
Expand All @@ -333,7 +346,7 @@ expected_branch="${BRANCH_PREFIX}${major}.${minor}.x"
if [[ "${current_branch}" != "${expected_branch}" ]]; then
print_error "Refusing to push version bump: current branch is '${current_branch}'"
print_error "Expected to be on release branch '${expected_branch}' for version ${version}."
print_error "Run the publish workflow with that branch selected, or check out '${expected_branch}' locally."
print_error "The script checks out '${expected_branch}' before publishing; something switched branches since then."
exit 1
fi
# Also confirm the format independently in case someone has named a
Expand Down
10 changes: 10 additions & 0 deletions release/libs/_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,13 @@ function set_pom_version {
function get_current_pom_version {
./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout 2>/dev/null
}

# Only the root POM declares <scm>; every module inherits its tag.
function set_pom_scm_tag {
local tag="$1"
exec_process ./mvnw -pl . versions:set-scm-tag -DnewTag="${tag}" -DgenerateBackupPoms=false --batch-mode -q
}

function get_current_pom_scm_tag {
./mvnw -pl . help:evaluate -Dexpression=project.scm.tag -q -DforceStdout 2>/dev/null
}
37 changes: 37 additions & 0 deletions release/tests/version.bats
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,43 @@ setup() {
[[ "$output" == *"2.0.0-SNAPSHOT"* ]]
}

# ---- set_pom_scm_tag ----

@test "set_pom_scm_tag: passes correct args to mvnw in dry-run" {
DRY_RUN=1
run set_pom_scm_tag "apache-parquet-1.18.2-rc1"
[ "$status" -eq 0 ]
[[ "$output" == *"-pl . versions:set-scm-tag"* ]]
[[ "$output" == *"-DnewTag=apache-parquet-1.18.2-rc1"* ]]
[[ "$output" == *"-DgenerateBackupPoms=false"* ]]
}

@test "set_pom_scm_tag: accepts HEAD for the next development iteration" {
DRY_RUN=1
run set_pom_scm_tag "HEAD"
[ "$status" -eq 0 ]
[[ "$output" == *"-DnewTag=HEAD"* ]]
}

# ---- get_current_pom_scm_tag ----

@test "get_current_pom_scm_tag: evaluates project.scm.tag on the root POM" {
local tmpbin
tmpbin=$(mktemp -d)
cat > "${tmpbin}/mvnw" << 'SCRIPT'
#!/bin/bash
if [[ "$*" == *"-pl . help:evaluate -Dexpression=project.scm.tag"* ]]; then
echo "apache-parquet-1.18.0-rc2"
fi
SCRIPT
chmod +x "${tmpbin}/mvnw"
cd "${tmpbin}"
local result
result=$(get_current_pom_scm_tag)
[ "$result" = "apache-parquet-1.18.0-rc2" ]
rm -rf "${tmpbin}"
}

# ---- find_latest_rc_number ----

@test "find_latest_rc_number: returns highest RC number" {
Expand Down
Loading