Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 43 additions & 37 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

# Zip binaries for release (naming by OS/Architecture)
- name: Package Binaries
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
shell: bash
run: |
mkdir -p dist
Expand All @@ -57,7 +57,7 @@ jobs:
fi

- name: Upload Artifacts
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.os }}
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
select-by-folder: src/matlab

- name: Upload MEX Artifact
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: mex-${{ matrix.os }}
Expand All @@ -106,7 +106,7 @@ jobs:
package-matlab:
name: Package Matlab Toolbox
needs: build-matlab
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -127,43 +127,49 @@ jobs:
- name: Package Toolbox
uses: matlab-actions/run-command@v2
env:
RELEASE_TAG: ${{ github.ref_name }}
GITHUB_REF_NAME: ${{ github.ref_name }}
with:
command: |
% 1. Create a dummy .prj content with a GUID so the constructor doesn't crash
guid = char(java.util.UUID.randomUUID());
prjContent = sprintf(['<?xml version="1.0" encoding="UTF-8"?>' ...
'<deployment-project plugin="plugin.toolbox" v3.0>' ...
'<configuration file="pyraview.prj" name="pyraview" target="target.toolbox" target-name="Package Toolbox">' ...
'<param.guid>%s</param.guid>' ...
'</configuration></deployment-project>'], guid);

% 2. Write it to a temporary file
fid = fopen('temp_packaging.prj', 'w');
fprintf(fid, '%s', prjContent);
fclose(fid);

% Create the options object from the temporary PRJ
opts = matlab.addons.toolbox.ToolboxOptions('temp_packaging.prj');
opts.ToolboxName = 'Pyraview';

% Grab version from environment variable
v = getenv('RELEASE_TAG');
if startsWith(v, 'v')
v = v(2:end);
% 1. Use a fixed, permanent UUID for the project
% This ensures MATLAB treats every build as an update to the same toolbox
guid = '6e14a2b9-7f3c-4d8e-9a1b-3c5d7e9f2a4b';

% 2. Grab the version from the GitHub Tag environment variable
% Default to 1.0.0 if not running in a tagged action
version = getenv('GITHUB_REF_NAME');
if isempty(version) || ~startsWith(version, 'v')
version = '1.0.0';
else
% Remove the 'v' prefix (e.g., 'v1.2.3' -> '1.2.3')
version = erase(version, 'v');
end
opts.ToolboxVersion = v;

opts.AuthorName = 'Van Hooser lab';
opts.ToolboxImage = '';
opts.Description = 'High-performance multi-resolution decimation engine.';
opts.OutputFile = 'Pyraview.mltbx';

% Important: Include the folder with the MEX files
opts.ToolboxFiles = {fullfile(pwd, 'src', 'matlab')};
% 3. Create a structurally complete, valid Toolbox PRJ XML
xmlCode = [...
'<?xml version="1.0" encoding="UTF-8"?>', ...
'<deployment-project plugin="plugin.toolbox" v3.0>', ...
'<configuration file="pyraview.prj" name="pyraview" target="target.toolbox" target-name="Package Toolbox">', ...
'<param.appname>Pyraview</param.appname>', ...
'<param.authnamewatermark>Pyraview Team</param.authnamewatermark>', ...
'<param.summary>High-performance decimation engine.</param.summary>', ...
'<param.version>' version '</param.version>', ...
'<param.output>${PROJECT_ROOT}/Pyraview.mltbx</param.output>', ...
'<param.guid>' guid '</param.guid>', ...
'<fileset.rootdir><file>${PROJECT_ROOT}/src/matlab</file></fileset.rootdir>', ...
'<fileset.rootfiles><file>${PROJECT_ROOT}/src/matlab</file></fileset.rootfiles>', ...
'<build-deliverables><file location="${PROJECT_ROOT}" name="Pyraview.mltbx" optional="false">${PROJECT_ROOT}/Pyraview.mltbx</file></build-deliverables>', ...
'<workflow />', ...
'<matlab><root>/usr/local/matlab</root><toolboxes /></matlab>', ...
'</configuration></deployment-project>'];

% 4. Write the file
fid = fopen('pyraview.prj', 'w');
fprintf(fid, '%s', xmlCode);
fclose(fid);

% Package it
matlab.addons.toolbox.packageToolbox(opts);
% 5. Package using the file directly
fprintf('Packaging Pyraview version %s with GUID %s...\n', version, guid);
matlab.addons.toolbox.packageToolbox('pyraview.prj', 'Pyraview.mltbx');

# Upload the .mltbx as an artifact so the release job can pick it up
- name: Upload Toolbox Artifact
Expand All @@ -175,7 +181,7 @@ jobs:
release:
name: Create GitHub Release
needs: [build_and_test, package-matlab]
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write # Required to create releases
Expand Down