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');