AL-Go icon indicating copy to clipboard operation
AL-Go copied to clipboard

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

Open jwikman opened this issue 3 months ago • 4 comments

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

jwikman avatar Sep 11 '25 19:09 jwikman

The issue comes from this code:

function GetLatestRelease {
    Param(
        [string] $token,
        [string] $api_url = $ENV:GITHUB_API_URL,
        [string] $repository = $ENV:GITHUB_REPOSITORY,
        [string] $ref = $ENV:GITHUB_REFNAME
    )

    Write-Host "Getting the latest release from $api_url/repos/$repository/releases/latest - branch $ref"
    # Get all releases from GitHub, sorted by SemVer tag
    # If any release tag is not a valid SemVer tag, use default GitHub sorting and issue a warning
    # Default github sorting will return the latest historically created release as the latest release - not the highest version
    $releases = GetReleases -token $token -api_url $api_url -repository $repository

    # Get Latest release
    $latestRelease = $releases | Where-Object { -not ($_.prerelease -or $_.draft) } | Select-Object -First 1
    $releaseBranchesFormats = 'release/*', 'releases/*'
    $isReleaseBranch = [boolean] $($releaseBranchesFormats | Where-Object { $ref -like $_ })

    if ($isReleaseBranch) {
        # If release branch, get the latest release from that the release branch
        # This is given by the latest release with the same major.minor as the release branch
        $releaseVersion = $ref -split '/' | Select-Object -Last 1 # Get the version from the release branch
        $semVerObj = SemVerStrToSemVerObj -semVerStr $releaseVersion -allowMajorMinorOnly
        $latestRelease = $releases | Where-Object {
            $releaseSemVerObj = SemVerStrToSemVerObj -semVerStr $_.tag_name
            $semVerObj.Major -eq $releaseSemVerObj.Major -and $semVerObj.Minor -eq $releaseSemVerObj.Minor
        } | Select-Object -First 1
    }
    $latestRelease
}

This code has some hardcoded checks against the branches under release/ and releases/.

This piece of code also blocks us from running the "Create release" pipeline on our releases/26.x branch 😕

Wouldn't it make sense to skip the release branch logic above if the branch leaf is not a semantic version?

jwikman avatar Sep 11 '25 21:09 jwikman

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

mazhelez avatar Sep 12 '25 09:09 mazhelez

Thanks Maria, it sure does. But it would be fairly easy to support both scenarios, IMO. 🙂

jwikman avatar Sep 12 '25 09:09 jwikman

Oh, @mazhelez @aholstrup1 @spetersenms , the reason this branching works in the BCApps was due to the "skipUpgrade": true setting that is used in that repo - and not the lack of running CI/CD as I mentioned yesterday. 🫣

I do not understand why you want to run all pipelines with skipUpgrade, but that's not releated to this issue. 😉

What I want to accomplish here is a "main" for each major that we need to maintain. Then we can run CI/CD against that as well as the "real main". For that purpose, "releases/26.x" felt as a good naming.

jwikman avatar Oct 08 '25 12:10 jwikman

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.

mazhelez avatar Nov 26 '25 16:11 mazhelez

@mazhelez, yes.

But if having "skipUpgrade": false, this is not possible.

jwikman avatar Nov 26 '25 16:11 jwikman