|
| 1 | +name: Compile, Test and Release toolbox |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + # This workflow contains two jobs called "compile-and-test-mex" and "create-and-release-toolbox" |
| 9 | + compile-and-test-mex: |
| 10 | + # A job will run for all the OS present in the matrix |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 14 | + |
| 15 | + # The type of runner that the job will run on |
| 16 | + runs-on: ${{ matrix.os }} |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + |
| 21 | + # Sets up MATLAB on the GitHub Actions runner |
| 22 | + - name: Setup MATLAB |
| 23 | + uses: matlab-actions/setup-matlab@v2 |
| 24 | + |
| 25 | + # Runs build to create MEX file and then run tests |
| 26 | + - name: Run MATLAB build |
| 27 | + uses: matlab-actions/run-build@v2 |
| 28 | + with: |
| 29 | + tasks: test |
| 30 | + |
| 31 | + # Uploads the test results and MEX files to GitHub |
| 32 | + - name: Upload test results |
| 33 | + uses: actions/upload-artifact@v4 |
| 34 | + with: |
| 35 | + name: test-results-${{ matrix.os }} |
| 36 | + path: test-results/results.xml |
| 37 | + |
| 38 | + - name: Upload mex file |
| 39 | + uses: actions/upload-artifact@v4 |
| 40 | + with: |
| 41 | + name: mex-${{ matrix.os }} |
| 42 | + path: toolbox/**/*.mex* |
| 43 | + |
| 44 | + create-and-release-toolbox: |
| 45 | + # This job executes only after a successful completion of 'compile-and-test-mex' job |
| 46 | + needs: compile-and-test-mex |
| 47 | + runs-on: ubuntu-latest |
| 48 | + |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v3 |
| 51 | + |
| 52 | + # Sets up MATLAB on the GitHub Actions runner |
| 53 | + - name: Setup MATLAB |
| 54 | + uses: matlab-actions/setup-matlab@v2 |
| 55 | + |
| 56 | + # Downloads all mex files uploaded to GitHub in the previous job |
| 57 | + - name: Download mex files |
| 58 | + uses: actions/download-artifact@v4 |
| 59 | + with: |
| 60 | + path: toolbox |
| 61 | + pattern: mex-* |
| 62 | + merge-multiple: true |
| 63 | + |
| 64 | + # Packages all files in toolbox folder into a mltbx toolbox package |
| 65 | + - name: Run MATLAB build |
| 66 | + uses: matlab-actions/run-build@v2 |
| 67 | + with: |
| 68 | + tasks: packageToolbox |
| 69 | + |
| 70 | + # The packaged toolbox is distributed as a GitHub release |
| 71 | + - name: Create relase and upload asset |
| 72 | + run: | |
| 73 | + gh release create ${{github.run_id}} --title "Cross-Platform Array Product Toolbox" toolbox.mltbx |
| 74 | + env: |
| 75 | + GH_TOKEN: ${{ github.token }} |
0 commit comments