From 6a842552242792f5cd292fa2bb36ca08e4987c04 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Thu, 15 Oct 2026 19:49:06 +0200 Subject: [PATCH] fix: write the build number as semantic version metadata on R2026b From R2026b, ToolboxOptions.ToolboxVersion must be a semantic version and rejects Major.Minor.Patch.Build (mpm:arguments:InvalidVersion). Earlier releases accept only that four-part form and reject Major.Minor.Patch+Build. packageToolbox adds a build number for the default "build" release type, so packaging failed on R2026b. createToolboxOptions now writes a four-part version as Major.Minor.Patch+Build on R2026b and later. The .mltbx file name turns "+" into "_", so it keeps the same form on every release. Co-Authored-By: Claude Opus 5.5 --- code/+matbox/+toolbox/createToolboxOptions.m | 22 +++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/code/+matbox/+toolbox/createToolboxOptions.m b/code/+matbox/+toolbox/createToolboxOptions.m index 204ae84..db8420c 100644 --- a/code/+matbox/+toolbox/createToolboxOptions.m +++ b/code/+matbox/+toolbox/createToolboxOptions.m @@ -35,7 +35,7 @@ opts = matlab.addons.toolbox.ToolboxOptions(toolboxFolder, identifier, toolboxInfo); % Set the toolbox version - opts.ToolboxVersion = versionNumber; + opts.ToolboxVersion = formatToolboxVersion(versionNumber); % Ignore some files if specified toIgnore = false(size( opts.ToolboxFiles )); @@ -67,14 +67,30 @@ end end - % Specify name for output .mltbx file. - versionNumber = strrep(opts.ToolboxVersion, '.', '_'); + % Specify name for output .mltbx file. Every version separator, including + % the "+" before a build number, becomes an underscore. + versionNumber = replace(opts.ToolboxVersion, [".", "+"], "_"); outputFileName = sprintf('%s_v%s.mltbx', MLTBX_NAME, versionNumber); opts.OutputFile = fullfile(projectRootDirectory, "releases", outputFileName); toolboxOptions = opts; end +function toolboxVersion = formatToolboxVersion(versionNumber) +% formatToolboxVersion - Write a version number in the form ToolboxOptions accepts +% +% From R2026b, ToolboxVersion must be a semantic version, which writes a +% build number as ..+. Earlier releases accept +% only .... + + versionParts = split(versionNumber, "."); + if numel(versionParts) == 4 && ~isMATLABReleaseOlderThan("R2026b") + toolboxVersion = join(versionParts(1:3), ".") + "+" + versionParts(4); + else + toolboxVersion = versionNumber; + end +end + function opts = addRequirementsToToolboxOptions(opts, requirements) % Add GitHub repository requirements as Additional Software isGithubRequirement = strcmp({requirements.Type}, 'GitHub');