Commit 9bf8d22
Fix: Handle non-semver branch versions like releases/26.x in GetLatestRelease (#2112)
### ❔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
- [x] Add tests (E2E, unit tests)
- [x] Update RELEASENOTES.md
- [x] Update documentation (e.g. for new settings or scenarios)
- [ ] Add telemetry
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *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](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/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)
>
> <comments>
> <comment_new><author>@mazhelez</author><body>
> @jwikman Thanks for reporting this.
> It seems like an unsupported scenario. I'll take a
look.</body></comment_new>
> <comment_new><author>@mazhelez</author><body>
> 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.<something> version, not the release from
`main`.</body></comment_new>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #1915
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 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](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 860bd00 commit 9bf8d22
4 files changed
Lines changed: 260 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
602 | 656 | | |
603 | 657 | | |
604 | 658 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
0 commit comments