Skip to content

Fix: Handle non-semver branch versions like releases/26.x in GetLatestRelease#2112

Open
Copilot wants to merge 15 commits intomainfrom
copilot/fix-cicd-version-issue
Open

Fix: Handle non-semver branch versions like releases/26.x in GetLatestRelease#2112
Copilot wants to merge 15 commits intomainfrom
copilot/fix-cicd-version-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

❔What, Why & How

CI/CD fails on branches like releases/26.x with error '26.x' cannot be recognized as a semantic version string because GetLatestRelease attempts to parse the branch suffix directly as semver.

Changes:

  • Strip optional v prefix from branch version before parsing
  • Strip .x or x suffix (with or without dot) from branch version before parsing
  • For major-only versions (releases/26, releases/26.x, releases/26x, releases/v26, releases/v26.x, releases/v26x), match releases by major version only
  • For major.minor versions (releases/26.3), continue matching by major.minor as before
  • Add validation for invalid formats with graceful fallback to overall latest release
  • Ensure prerelease and draft releases are correctly filtered out when matching by major version or major.minor version
  • Support for v-prefixed tags (e.g., v26.3.0) in version matching
  • Added debug logging for troubleshooting when releases with invalid semver tags are skipped
  • Added documentation for supported release branch naming formats in Scenarios/settings.md

Before: releases/26.x → tries to parse 26.x → throws exception
After: releases/26.x → strips to 26 → finds latest 26.*.* release (excluding prereleases and drafts)

Supported branch naming formats:

  • releases/26 - major version only
  • releases/26.x - major version with .x suffix
  • releases/26x - major version with x suffix (no dot)
  • releases/v26 - major version with v prefix
  • releases/v26.x - major version with v prefix and .x suffix
  • releases/v26x - major version with v prefix and x suffix
  • releases/26.3 - major.minor version

✅ Checklist

  • Add tests (E2E, unit tests)
  • Update RELEASENOTES.md
  • Update documentation (e.g. for new settings or scenarios)
  • Add telemetry
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: CICD fails on releases/26.x branch - '26.x' cannot be recognized as a semantic version string</issue_title>
<issue_description>### AL-Go version

7.3

Describe the issue

We've setup our CI/CD to trigger on main and releases/*, pretty much on BCApps.

But when the CI/CD runs, it fails with this error:
Error: Error trying to locate previous release. Error was '26.x' cannot be recognized as a semantic version string (https://semver.org/)

A bit more context to the error:

Locating previous release
  Getting the latest release from https://api.github.com/repos/nabsolutions-product/Eagle/releases/latest - branch releases/26.x
  Analyzing releases https://api.github.com/repos/nabsolutions-product/Eagle/releases
  Error: Error trying to locate previous release. Error was '26.x' cannot be recognized as a semantic version string (https://semver.org/)
  Test-BcContainer Telemetry Correlation Id: 1734ffa6-da0a-45fe-a6ab-1f315d1fd076
  Applying settings from E:\actions-runner-01\_work\Eagle\Eagle\.github\AL-Go-TemplateRepoSettings.doNotEdit.json
  Applying settings from E:\actions-runner-01\_work\Eagle\Eagle\.github\AL-Go-Settings.json
  Applying settings from E:\actions-runner-01\_work\Eagle\Eagle\.github\AL-Go-TemplateProjectSettings.doNotEdit.json
  No settings found in E:\actions-runner-01\_work\Eagle\Eagle\.AL-Go\settings.json
  No settings found in E:\actions-runner-01\_work\Eagle\Eagle\.github\CICD.settings.json
  No settings found in E:\actions-runner-01\_work\Eagle\Eagle\.AL-Go\CICD.settings.json
  No settings found in E:\actions-runner-01\_work\Eagle\Eagle\.AL-Go\nab-al-go-authentication[bot].settings.json
  Applying conditional settings for workflows: CICD

I have not yet created any release for this app with AL-Go, but I do not think that is the main issue here. It seems to assume that the branch name is a semver string. I also tested with releases/26 with similar error. releases/26.3 did work, though, since 26.3 is a valid semver.

Setting "skipUpgrade": true also works as a workaround, since in that scenario AL-Go do not look for previous release. This seems to be the reason why this work in the BCApps repo...

Expected behavior

It should not throw error. Try to find previous release, and if not write a warning - just as if running in the main branch.

Steps to reproduce

Setup CI/CD to trigger on main and releases/*

    "CICDPushBranches": [
        "main",
        "releases/*"
    ],

Do not set skipUpgrade.
Create a branch from main, called releases/26.x
Push to remote to trigger CI/CD

Should error out on build step

Additional context (logs, screenshots, etc.)

On request, if needed.
Internal work item: AB#609691</issue_description>

<agent_instructions>Can you please make the check for finding releases base on a branch more resilient.
E.g. if the branch is releases/26.x then the process shouldn't try to parse "26.x" as a sem version, instead try to find the latest 26 version.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@mazhelez @jwikman Thanks for reporting this. It seems like an unsupported scenario. I'll take a look. @mazhelez Hey @jwikman

I finally have some time to take a proper look at this issue.
The way AL-Go works in this case, if finding the version from the branch itself.

If you have a releases/26.x you'd expect the latest release to be a 26. version, not the release from main.</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 5, 2026 08:21
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI/CD error for semantic versioning on releases/26.x branch Fix: Handle non-semver branch versions like releases/26.x in GetLatestRelease Feb 5, 2026
Copilot AI requested a review from mazhelez February 5, 2026 08:24
Copy link
Collaborator

@mazhelez mazhelez left a comment

Choose a reason for hiding this comment

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

@copilot can you also please add release notes entry

@mazhelez mazhelez marked this pull request as ready for review February 5, 2026 12:24
@mazhelez mazhelez requested a review from a team as a code owner February 5, 2026 12:24
Copilot AI review requested due to automatic review settings February 5, 2026 12:24
@mazhelez
Copy link
Collaborator

mazhelez commented Feb 5, 2026

@copilot can you also please add release notes entry

Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 5, 2026

@copilot can you also please add release notes entry

Added release notes entry in commit 082778b.

Copy link
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

This PR fixes a bug where CI/CD workflows fail on branches with non-semantic version names like releases/26.x, which couldn't be parsed as valid semantic versions. The fix introduces logic to strip the .x suffix and handle major-only version patterns (e.g., 26.x → match all 26.*.* releases) separately from major.minor patterns (e.g., 26.3 → match all 26.3.* releases).

Changes:

  • Strip .x suffix from branch versions before parsing
  • Add support for major-only version matching (e.g., releases/26.x or releases/26)
  • Maintain existing major.minor version matching behavior (e.g., releases/26.3)
  • Add graceful fallback to overall latest release for invalid version formats

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
Actions/Github-Helper.psm1 Modified GetLatestRelease function to handle .x suffix removal and implement major-only version filtering with proper error handling and fallback behavior
Tests/GitHub-Helper.Test.ps1 Added comprehensive test coverage for the new functionality including tests for major-only versions, major.minor versions, invalid formats, and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI requested a review from mazhelez February 5, 2026 12:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
aholstrup1
aholstrup1 previously approved these changes Feb 6, 2026
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Copy link
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mazhelez and others added 2 commits February 6, 2026 09:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mazhelez mazhelez enabled auto-merge (squash) February 6, 2026 11:39
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.

[Bug]: CICD fails on releases/26.x branch - '26.x' cannot be recognized as a semantic version string

3 participants