Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
matlab-actions

GitHub Action

Run MATLAB Build

v1.0.1

Run MATLAB Build

matlab-actions

Run MATLAB Build

Run a build with the MATLAB build tool

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Run MATLAB Build

uses: matlab-actions/run-build@v1.0.1

Learn more about this action in matlab-actions/run-build

Choose a version

Action for Running MATLAB Builds

Starting in R2022b, the MATLAB® build tool provides a standard programming interface to create and run software-build tasks in a uniform and efficient way. For example, you can create tasks that identify code issues, run tests, and package a toolbox in a single build file in your project root folder, and then invoke the build tool to run these tasks. For more information, see Overview of MATLAB Build Tool.

The Run MATLAB Build action enables you to invoke the MATLAB build tool on a self-hosted or GitHub®-hosted runner:

  • To use a self-hosted runner, you must set up a computer with MATLAB as your runner. The runner uses the topmost MATLAB version on the system path to execute your workflow.

  • To use a GitHub-hosted runner, you must include the Setup MATLAB action in your workflow to set up MATLAB on the runner. Currently, this action is available only for public projects. It does not set up transformation products, such as MATLAB Coder™ and MATLAB Compiler™.

Examples

Use the Run MATLAB Build action to run a build using the MATLAB build tool. You can use this action to run the tasks specified in a file named buildfile.m in the root of your repository.

Run MATLAB Build on Self-Hosted Runner

Use a self-hosted runner to run the default tasks in your build plan as well as all the tasks on which they depend.

name: Run MATLAB Build on Self-Hosted Runner
on: [push]
jobs:
  my-job:
    name: Run MATLAB Build
    runs-on: self-hosted
    steps:
      - name: Check out repository
        uses: actions/checkout@v3
      - name: Run build
        uses: matlab-actions/run-build@v1

Run MATLAB Build on GitHub-Hosted Runner

Before you run MATLAB code or Simulink models on a GitHub-hosted runner, first use the Setup MATLAB action. The action sets up your specified MATLAB release (R2020a or later) on a Linux® virtual machine. If you do not specify a release, the action sets up the latest release of MATLAB. To use the Run MATLAB Build action, you need MATLAB R2022b or a later release.

For example, set up the latest release of MATLAB on a GitHub-hosted runner, and then use the Run MATLAB Build action to run a specific task and the tasks on which it depends.

name: Run MATLAB Build on GitHub-Hosted Runner
on: [push]
jobs:
  my-job:
    name: Run MATLAB Build
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v3
      - name: Set up MATLAB
        uses: matlab-actions/setup-matlab@v1
      - name: Run build
        uses: matlab-actions/run-build@v1
        with:
          tasks: mytask

Run MATLAB Build

When you define your workflow in the .github/workflows directory of your repository, specify the Run MATLAB Build action as matlab-actions/run-build@v1. The action accepts an optional input.

Input Description
tasks (Optional) Space-separated list of tasks to run. If not specified, the action runs the default tasks in buildfile.m as well as all the tasks on which they depend.
Example: test
Example: compile test

MATLAB exits with exit code 0 if the tasks run without error. Otherwise, MATLAB terminates with a nonzero exit code, which causes the workflow to fail.

When you use this action, a file named buildfile.m must be in the project root directory.

Notes

  • The Run MATLAB Build action uses the -batch option to invoke the buildtool command noninteractively. Preferences do not persist across different MATLAB sessions launched with the -batch option. To run code that requires the same preferences, use a single action.

  • When you use the Run MATLAB Build action, you execute third-party code that is licensed under separate terms.

See Also

Contact Us

If you have any questions or suggestions, please contact MathWorks® at continuous-integration@mathworks.com.