Skip to content

Fix release version replacement appending old suffixes#193

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-release-version-replacement
Open

Fix release version replacement appending old suffixes#193
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-release-version-replacement

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

The release automation was generating chained artifact versions like 1.0.0-beta-java.3-beta-java.2-beta-java.1 and duplicate [Unreleased] link definitions in CHANGELOG.md because the version qualifier regex didn't recognize the -beta-java.N format.

Root causes

sed patterns (publish-maven.yml) — BRE group syntax bug: (beta-) was treated as a literal string (beta-) rather than an optional group. Pattern only matched the base M.M.P, then the new qualifier was appended, leaving the old suffix intact:

# Before (only matched base M.M.P):
\(-java\(-preview\)\{0,1\}\.[0-9][0-9]*\)\{0,1\}

# After (matches any number of -word.N qualifiers, including chained ones):
\(-[a-z][a-z0-9-]*\.[0-9][0-9]*\)*

awk script (update-changelog.sh) — Two bugs:

  1. The [Unreleased]: URL regex extracted only the base version, so the new version link pointed to the wrong predecessor (e.g., v0.3.0-java.2 instead of v1.0.0-beta-java.2).
  2. Both the [Unreleased]: handler and the first-version-link handler could fire in the same run, each inserting a new [Unreleased]: definition.

Fixes

  • publish-maven.yml: Replaced all sed version patterns with \(-[a-z][a-z0-9-]*\.[0-9][0-9]*\)* — matches -java.N, -java-preview.N, -beta-java.N, and also cleans up pre-existing chained versions. Updated version validation regex to accept -beta-java.N.
  • update-changelog.sh: Extended awk version regex to (-(beta-)?java(-preview)?.[0-9]+)?; added unreleased_link_handled flag to prevent double-insertion of [Unreleased] links; reordered the two awk blocks so the flag is set before the first-version-link block evaluates it.
  • CHANGELOG.md: Removed 18 duplicate [Unreleased] entries; corrected predecessor links for 1.0.0-beta-java.2 and 1.0.0-beta-java.3.
  • README.md, jbang-example.java, cookbook *.md: Replaced chained invalid versions with correct 1.0.0-beta-java.3.
  • test-update-changelog.sh: Fixed pre-existing set -e + ((passed++)) bug that caused only one test to run; added tests for -beta-java.N format and duplicate-link prevention.

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • mvn spotless:apply has been run to format the code
  • mvn clean verify passes locally

Does this introduce a breaking change?

  • Yes
  • No

- Fix sed patterns in publish-maven.yml to use general qualifier regex
  `\(-[a-z][a-z0-9-]*\.[0-9][0-9]*\)*` that matches any version qualifier
  format (-java.N, -java-preview.N, -beta-java.N) and also handles
  previously-chained invalid versions
- Fix awk regex patterns in update-changelog.sh to recognize -beta-java.N
  in [Unreleased] and version link patterns (-(beta-)?java(-preview)?.N)
- Fix duplicate [Unreleased] link bug: track unreleased_link_handled flag
  so the first-version-link insertion block only fires when there is no
  existing [Unreleased] link to update
- Move [Unreleased] handler before first-version-link handler in awk so
  the flag is set before the later block evaluates it
- Update version validation regex to accept -beta-java.N format
- Fix CHANGELOG.md: remove duplicate [Unreleased] links and fix incorrect
  predecessor version references for 1.0.0-beta-java.2 and .3
- Fix README.md, jbang-example.java, and cookbook markdown files:
  replace chained invalid versions with correct 1.0.0-beta-java.3
- Fix test-update-changelog.sh: replace ((passed++)) with
  passed=$((passed+1)) to avoid set -e triggering on arithmetic result 0;
  add two new tests for beta-java format and no-duplicate-links guarantee

Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix release version replacement appending old suffixes Fix release version replacement appending old suffixes May 12, 2026
Copilot AI requested a review from brunoborges May 12, 2026 20:49
@edburns
Copy link
Copy Markdown
Collaborator

edburns commented May 12, 2026

@brunoborges thanks. Please mark this Ready for review as the signal for me to take a look at it.

@brunoborges brunoborges marked this pull request as ready for review May 13, 2026 01:17
Copilot AI review requested due to automatic review settings May 13, 2026 01:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes release automation and changelog update tooling so version replacement correctly handles -beta-java.N qualifiers (and previously chained suffixes), preventing invalid artifact coordinates in docs/examples and duplicate [Unreleased] link definitions in CHANGELOG.md.

Changes:

  • Update publish-maven.yml version validation and sed replacement patterns to fully replace qualified versions (including -beta-java.N) rather than appending new qualifiers onto old ones.
  • Fix update-changelog.sh awk parsing so it correctly identifies qualified predecessor versions and avoids inserting duplicate [Unreleased] link definitions.
  • Clean up existing documentation/examples and CHANGELOG.md, and extend the changelog script’s test suite (including fixing the test runner’s set -e increment bug).
Show a summary per file
File Description
src/site/markdown/cookbook/pr-visualization.md Fix JBang //DEPS example to use the correct non-chained beta version.
src/site/markdown/cookbook/persisting-sessions.md Fix multiple //DEPS snippets to remove chained beta suffixes.
src/site/markdown/cookbook/multiple-sessions.md Fix //DEPS snippets to reference the correct beta version.
src/site/markdown/cookbook/managing-local-files.md Fix //DEPS snippets to reference the correct beta version.
src/site/markdown/cookbook/error-handling.md Fix multiple //DEPS snippets to reference the correct beta version.
README.md Update dependency snippets to the corrected beta version (and remove chained versions).
jbang-example.java Fix //DEPS to the corrected beta version.
CHANGELOG.md Remove duplicate [Unreleased] link definitions and correct beta predecessor compare links.
.github/workflows/publish-maven.yml Fix version format validation and sed replacement patterns to correctly replace qualified versions.
.github/scripts/release/update-changelog.sh Fix awk regexes/flow to correctly parse qualified versions and prevent duplicate [Unreleased] insertion.
.github/scripts/release/test-update-changelog.sh Fix test runner increment logic under set -e; add tests for -beta-java.N and duplicate-link prevention.

Copilot's findings

  • Files reviewed: 11/11 changed files
  • Comments generated: 1

if ! echo "$RELEASE_VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-java(-preview)?\.[0-9]+)?$'; then
echo "Error: RELEASE_VERSION '$RELEASE_VERSION' is invalid. Expected format: M.M.P, M.M.P-java.N, or M.M.P-java-preview.N (e.g., 1.2.3, 1.2.3-java.0, or 1.2.3-java-preview.0)." >&2
if ! echo "$RELEASE_VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-(beta-)?java(-preview)?\.[0-9]+)?$'; then
echo "Error: RELEASE_VERSION '$RELEASE_VERSION' is invalid. Expected format: M.M.P, M.M.P-java.N, M.M.P-java-preview.N, or M.M.P-beta-java.N (e.g., 1.2.3, 1.2.3-java.0, 1.2.3-java-preview.0, or 1.2.3-beta-java.0)." >&2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix release version replacement appending old suffixes

4 participants