diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index fa8542d..fa00ae2 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -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 @@ -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 }} @@ -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 }} @@ -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 @@ -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(['' ... - '' ... - '' ... - '%s' ... - ''], 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 = [... + '', ... + '', ... + '', ... + 'Pyraview', ... + 'Pyraview Team', ... + 'High-performance decimation engine.', ... + '' version '', ... + '${PROJECT_ROOT}/Pyraview.mltbx', ... + '' guid '', ... + '${PROJECT_ROOT}/src/matlab', ... + '${PROJECT_ROOT}/src/matlab', ... + '${PROJECT_ROOT}/Pyraview.mltbx', ... + '', ... + '/usr/local/matlab', ... + '']; + + % 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 @@ -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