Skip to content

feat: support release tag names in JBANG_DOWNLOAD_VERSION (early-access)#2480

Merged
maxandersen merged 2 commits into
mainfrom
feat/early-access-download-version
May 29, 2026
Merged

feat: support release tag names in JBANG_DOWNLOAD_VERSION (early-access)#2480
maxandersen merged 2 commits into
mainfrom
feat/early-access-download-version

Conversation

@maxandersen
Copy link
Copy Markdown
Collaborator

@maxandersen maxandersen commented May 28, 2026

Why

We now have a perpetual early-access release URL: https://github.com/jbangdev/jbang/releases/download/early-access/

This PR makes it reachable via the existing JBANG_DOWNLOAD_* variables, so users can opt in with a one-liner instead of pinning a full JBANG_DOWNLOAD_URL.

What

Extend the existing JBANG_DOWNLOAD_VERSION semantics rather than introduce a new variable:

  • Numeric values (existing behaviour) keep getting the customary v prefix — 0.120.0.../download/v0.120.0/jbang.tar.
  • Non-numeric values are used as a release tag name as-is — early-access.../download/early-access/jbang.tar.

So this Just Works:

export JBANG_DOWNLOAD_VERSION=early-access

JBANG_DOWNLOAD_BASEURL and JBANG_DOWNLOAD_URL continue to behave as before for mirrors / air-gapped setups.

Changes

  • src/main/scripts/jbang — bash case decides whether to prepend v.
  • src/main/scripts/jbang.ps1 — same logic via -match '^[0-9]'.
  • src/main/scripts/jbang.cmd — unchanged (delegates downloads to jbang.ps1 per AGENTS.md).
  • docs/modules/ROOT/pages/installation.adoc — new subsection "Downloading a specific version or the early-access build" and updated description in the env-var table.
  • src/test/java/dev/jbang/cli/TestScriptDownloadVersion.java — new WireMock-backed tests running the real bash and pwsh scripts, asserting both /download/v0.120.0/jbang.{tar,zip} and /download/early-access/jbang.{tar,zip} are requested. Uses assumeTrue to skip when bash / pwsh aren't available, matching the existing TestScriptRetry style.

Summary by CodeRabbit

  • New Features

    • JBANG_DOWNLOAD_VERSION now supports non-numeric release tags (e.g., early-access) in addition to numeric versions. Numeric versions automatically receive a v prefix in download URLs, while non-numeric tags are used as-is.
  • Documentation

    • Updated installation documentation describing version selection behavior.
  • Tests

    • Added comprehensive tests validating version download URL construction.

Review Change Stack

Numeric values (e.g. 0.120.0) continue to be resolved to the matching
vX.Y.Z GitHub release. Non-numeric values are now used as a release tag
name as-is, which makes the perpetual early-access build reachable via:

    export JBANG_DOWNLOAD_VERSION=early-access

resolving to https://github.com/jbangdev/jbang/releases/download/early-access/

Applied consistently in jbang (bash) and jbang.ps1; jbang.cmd delegates
downloads to jbang.ps1 so needs no change. Docs updated in
installation.adoc. New WireMock-backed script tests verify the URL
construction for both numeric and tag-named values on bash and pwsh.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c5d71300-f67f-4e22-9b77-d43ad1363306

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR implements conditional version-to-tag mapping for JBANG_DOWNLOAD_VERSION in both Bash and PowerShell startup scripts: numeric versions are prefixed with v (e.g., 0.120.0v0.120.0), while non-numeric tags like early-access are used as-is in GitHub download URLs. A new functional test class validates both platforms with WireMock stubs and environment isolation.

Changes

JBang version tag selection

Layer / File(s) Summary
Version prefix logic in startup scripts
src/main/scripts/jbang, src/main/scripts/jbang.ps1
Bash and PowerShell scripts now conditionally prefix JBANG_DOWNLOAD_VERSION with v only for numeric versions (e.g., 0.120.0v0.120.0); non-numeric tags like early-access are used directly when building the GitHub download URL.
Functional tests for version selection across platforms
src/test/java/dev/jbang/cli/TestScriptDownloadVersion.java
New test class validates that the startup scripts correctly translate numeric and non-numeric JBANG_DOWNLOAD_VERSION values into the expected GitHub download paths. Test infrastructure manages WireMock server lifecycle, creates stub archives, executes the target script with isolated environments, and verifies both the requested URL and absence of download errors on both Bash and PowerShell.
User documentation for version selection
docs/modules/ROOT/pages/installation.adoc
Documentation added to explain how JBANG_DOWNLOAD_VERSION selects releases: numeric values map to vX.Y.Z GitHub tags, non-numeric values are used as release tag names (e.g., early-access). Table entry revised to reflect the selection semantics.

Possibly related PRs

  • jbangdev/jbang#2472: Both PRs modify the startup jbang/jbang.ps1 download URL construction logic based on JBANG_DOWNLOAD_VERSION, with main PR's numeric-v vs tag-as-is semantics directly intersecting with related URL formatting changes.
  • jbangdev/jbang#2461: Both PRs modify the startup-script download URL construction in src/main/scripts/jbang and src/main/scripts/jbang.ps1 to interpret JBANG_DOWNLOAD_VERSION with different semantics (main PR changes v-prefixing rules; other PR layers retry support and optional URL override).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through versions bright,
Numeric vs, tags just right—
Early-access needs no v here,
Scripts and tests make it clear! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly summarizes the main feature: enabling non-numeric release tag names (like early-access) in the JBANG_DOWNLOAD_VERSION environment variable, which aligns with all the code and documentation changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@maxandersen maxandersen requested a review from quintesse May 28, 2026 23:18
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/test/java/dev/jbang/cli/TestScriptDownloadVersion.java (1)

168-202: ⚡ Quick win

Add a regression case for digit-prefixed non-numeric tags (e.g., 1.0.0-rc1).

Current tests only cover pure numeric and pure alpha tags, so the boundary where tags start with digits is untested.

Also applies to: 257-299

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/dev/jbang/cli/TestScriptDownloadVersion.java` around lines 168
- 202, Add a new JUnit test in TestScriptDownloadVersion mirroring the existing
tests (numericVersionGetsVPrefix and earlyAccessTagIsUsedAsIs) that verifies
digit-prefixed non-numeric tags are used as-is: stub a WireMock GET for
"/download/1.0.0-rc1/jbang.tar" returning createJbangTar(), invoke the bash
script via runProcess(cmd, bashEnv("1.0.0-rc1")), verify WireMock received a
request for "/download/1.0.0-rc1/jbang.tar", and assert stderr does not contain
"Error downloading JBang".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/scripts/jbang`:
- Around line 292-295: The case pattern [0-9]* treats any string starting with a
digit as numeric (so "1.0.0-rc1" becomes "v1.0.0-rc1"); update the case to
detect only wholly-numeric values and leave anything with non-digit chars
unchanged: change the branches around JBANG_DOWNLOAD_VERSION so that strings
matching "*[!0-9]*" (contain any non-digit) set jbtag="$JBANG_DOWNLOAD_VERSION"
and the fallback (all digits) prefixes with "v$JBANG_DOWNLOAD_VERSION"; update
the case that assigns jbtag accordingly.

In `@src/main/scripts/jbang.ps1`:
- Around line 162-166: The current check using -match '^[0-9]' prepends "v" for
any tag starting with a digit (e.g., "1.0.0-rc1"); change the conditional around
JBANG_DOWNLOAD_VERSION so it only treats pure numeric/semver-like versions as
numeric (e.g., use a stricter regex like '^\d+(\.\d+){0,2}$') before setting
jbtag="v$env:JBANG_DOWNLOAD_VERSION", leaving the else branch to keep
non-numeric or prerelease tags verbatim; update the if that references
$env:JBANG_DOWNLOAD_VERSION and the jbtag assignment accordingly.

In `@src/test/java/dev/jbang/cli/TestScriptDownloadVersion.java`:
- Around line 45-61: The test class TestScriptDownloadVersion currently creates
its own WireMockServer (wm) and lifecycle methods startWireMock/stopWireMock;
change the class to extend the repository BaseTest so it uses the shared
WireMock harness instead of custom setup: remove the wm field and the
startWireMock/stopWireMock methods, rely on the BaseTest-provided WireMock
instance (use the harness accessor name used by BaseTest, e.g., the shared
wireMockServer/wm field or getWireMockServer()), and update any references to wm
to use that shared instance; keep the `@TempDir` tempDir as-is.

---

Nitpick comments:
In `@src/test/java/dev/jbang/cli/TestScriptDownloadVersion.java`:
- Around line 168-202: Add a new JUnit test in TestScriptDownloadVersion
mirroring the existing tests (numericVersionGetsVPrefix and
earlyAccessTagIsUsedAsIs) that verifies digit-prefixed non-numeric tags are used
as-is: stub a WireMock GET for "/download/1.0.0-rc1/jbang.tar" returning
createJbangTar(), invoke the bash script via runProcess(cmd,
bashEnv("1.0.0-rc1")), verify WireMock received a request for
"/download/1.0.0-rc1/jbang.tar", and assert stderr does not contain "Error
downloading JBang".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: db9be6b6-87bc-4936-b5e7-5c88b755db00

📥 Commits

Reviewing files that changed from the base of the PR and between 0c1b40a and 7998050.

📒 Files selected for processing (4)
  • docs/modules/ROOT/pages/installation.adoc
  • src/main/scripts/jbang
  • src/main/scripts/jbang.ps1
  • src/test/java/dev/jbang/cli/TestScriptDownloadVersion.java

Comment thread src/main/scripts/jbang
Comment thread src/main/scripts/jbang.ps1 Outdated
Comment thread src/test/java/dev/jbang/cli/TestScriptDownloadVersion.java
quintesse
quintesse previously approved these changes May 29, 2026
Copy link
Copy Markdown
Contributor

@quintesse quintesse left a comment

Choose a reason for hiding this comment

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

LGTM

…access install

- Only prefix 'v' when JBANG_DOWNLOAD_VERSION is purely dotted-numeric;
  values like '1.0.0-rc1' or 'early-access' are now passed through as-is
  in both bash and PowerShell startup scripts.
- Align bash glob ('*[!0-9.]*') and PowerShell regex ('^[0-9]+(\.[0-9]+)*$')
  so both platforms classify the same inputs identically.
- Add TestScriptDownloadVersion regression cases for numeric, named-tag
  (early-access) and digit-prefixed prerelease (1.0.0-rc1) values, run
  against the real scripts via WireMock for bash and PowerShell.
- Add an early-access install snippet to the JReleaser changelog template
  showing the bash and PowerShell one-liners.
- Document the version-vs-tag selection rule in installation.adoc.
@maxandersen
Copy link
Copy Markdown
Collaborator Author

i changed the expression sligthly so it will treat any 1.2.3-adsff as a tag with v but anything else should just be fetched directly.

  • added text and full changelog to the earlyaccess so all changes since last real release is shown.

@maxandersen maxandersen merged commit 09ec597 into main May 29, 2026
30 checks passed
@maxandersen maxandersen deleted the feat/early-access-download-version branch May 29, 2026 23:04
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.

2 participants