Skip to content

Commit 7018da4

Browse files
Merge pull request #6 from VH-Lab/fix-windows-zip-failures-10291462098558351599
Fix Windows zip failures and update MATLAB toolbox packaging
2 parents 1964e72 + 021e8fb commit 7018da4

1 file changed

Lines changed: 43 additions & 37 deletions

File tree

.github/workflows/build_and_release.yml

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
4545
# Zip binaries for release (naming by OS/Architecture)
4646
- name: Package Binaries
47-
if: startsWith(github.ref, 'refs/tags/')
47+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
4848
shell: bash
4949
run: |
5050
mkdir -p dist
@@ -57,7 +57,7 @@ jobs:
5757
fi
5858
5959
- name: Upload Artifacts
60-
if: startsWith(github.ref, 'refs/tags/')
60+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
6161
uses: actions/upload-artifact@v4
6262
with:
6363
name: binaries-${{ matrix.os }}
@@ -96,7 +96,7 @@ jobs:
9696
select-by-folder: src/matlab
9797

9898
- name: Upload MEX Artifact
99-
if: startsWith(github.ref, 'refs/tags/')
99+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
100100
uses: actions/upload-artifact@v4
101101
with:
102102
name: mex-${{ matrix.os }}
@@ -106,7 +106,7 @@ jobs:
106106
package-matlab:
107107
name: Package Matlab Toolbox
108108
needs: build-matlab
109-
if: startsWith(github.ref, 'refs/tags/')
109+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
110110
runs-on: ubuntu-latest
111111
steps:
112112
- uses: actions/checkout@v4
@@ -127,43 +127,49 @@ jobs:
127127
- name: Package Toolbox
128128
uses: matlab-actions/run-command@v2
129129
env:
130-
RELEASE_TAG: ${{ github.ref_name }}
130+
GITHUB_REF_NAME: ${{ github.ref_name }}
131131
with:
132132
command: |
133-
% 1. Create a dummy .prj content with a GUID so the constructor doesn't crash
134-
guid = char(java.util.UUID.randomUUID());
135-
prjContent = sprintf(['<?xml version="1.0" encoding="UTF-8"?>' ...
136-
'<deployment-project plugin="plugin.toolbox" v3.0>' ...
137-
'<configuration file="pyraview.prj" name="pyraview" target="target.toolbox" target-name="Package Toolbox">' ...
138-
'<param.guid>%s</param.guid>' ...
139-
'</configuration></deployment-project>'], guid);
140-
141-
% 2. Write it to a temporary file
142-
fid = fopen('temp_packaging.prj', 'w');
143-
fprintf(fid, '%s', prjContent);
144-
fclose(fid);
145-
146-
% Create the options object from the temporary PRJ
147-
opts = matlab.addons.toolbox.ToolboxOptions('temp_packaging.prj');
148-
opts.ToolboxName = 'Pyraview';
149-
150-
% Grab version from environment variable
151-
v = getenv('RELEASE_TAG');
152-
if startsWith(v, 'v')
153-
v = v(2:end);
133+
% 1. Use a fixed, permanent UUID for the project
134+
% This ensures MATLAB treats every build as an update to the same toolbox
135+
guid = '6e14a2b9-7f3c-4d8e-9a1b-3c5d7e9f2a4b';
136+
137+
% 2. Grab the version from the GitHub Tag environment variable
138+
% Default to 1.0.0 if not running in a tagged action
139+
version = getenv('GITHUB_REF_NAME');
140+
if isempty(version) || ~startsWith(version, 'v')
141+
version = '1.0.0';
142+
else
143+
% Remove the 'v' prefix (e.g., 'v1.2.3' -> '1.2.3')
144+
version = erase(version, 'v');
154145
end
155-
opts.ToolboxVersion = v;
156146
157-
opts.AuthorName = 'Van Hooser lab';
158-
opts.ToolboxImage = '';
159-
opts.Description = 'High-performance multi-resolution decimation engine.';
160-
opts.OutputFile = 'Pyraview.mltbx';
161-
162-
% Important: Include the folder with the MEX files
163-
opts.ToolboxFiles = {fullfile(pwd, 'src', 'matlab')};
147+
% 3. Create a structurally complete, valid Toolbox PRJ XML
148+
xmlCode = [...
149+
'<?xml version="1.0" encoding="UTF-8"?>', ...
150+
'<deployment-project plugin="plugin.toolbox" v3.0>', ...
151+
'<configuration file="pyraview.prj" name="pyraview" target="target.toolbox" target-name="Package Toolbox">', ...
152+
'<param.appname>Pyraview</param.appname>', ...
153+
'<param.authnamewatermark>Pyraview Team</param.authnamewatermark>', ...
154+
'<param.summary>High-performance decimation engine.</param.summary>', ...
155+
'<param.version>' version '</param.version>', ...
156+
'<param.output>${PROJECT_ROOT}/Pyraview.mltbx</param.output>', ...
157+
'<param.guid>' guid '</param.guid>', ...
158+
'<fileset.rootdir><file>${PROJECT_ROOT}/src/matlab</file></fileset.rootdir>', ...
159+
'<fileset.rootfiles><file>${PROJECT_ROOT}/src/matlab</file></fileset.rootfiles>', ...
160+
'<build-deliverables><file location="${PROJECT_ROOT}" name="Pyraview.mltbx" optional="false">${PROJECT_ROOT}/Pyraview.mltbx</file></build-deliverables>', ...
161+
'<workflow />', ...
162+
'<matlab><root>/usr/local/matlab</root><toolboxes /></matlab>', ...
163+
'</configuration></deployment-project>'];
164+
165+
% 4. Write the file
166+
fid = fopen('pyraview.prj', 'w');
167+
fprintf(fid, '%s', xmlCode);
168+
fclose(fid);
164169
165-
% Package it
166-
matlab.addons.toolbox.packageToolbox(opts);
170+
% 5. Package using the file directly
171+
fprintf('Packaging Pyraview version %s with GUID %s...\n', version, guid);
172+
matlab.addons.toolbox.packageToolbox('pyraview.prj', 'Pyraview.mltbx');
167173
168174
# Upload the .mltbx as an artifact so the release job can pick it up
169175
- name: Upload Toolbox Artifact
@@ -175,7 +181,7 @@ jobs:
175181
release:
176182
name: Create GitHub Release
177183
needs: [build_and_test, package-matlab]
178-
if: startsWith(github.ref, 'refs/tags/')
184+
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
179185
runs-on: ubuntu-latest
180186
permissions:
181187
contents: write # Required to create releases

0 commit comments

Comments
 (0)