For examples to publish an interface, see:

For requirements, see Requirements for Building Interface to C++ Libraries.
For Step 1: Generate, see clibgen.generateLibraryDefinition.
For Step 2: Define, see Define MATLAB Interface for C++ Library.
For Step 3: Build, see Build C++ Library Interface and Review Contents.
For Step 4: Test, see Call Functions in Windows Interface to C++ Shared Library or Call Functions in Linux Interface to C++ Shared Library.
For Step 5: Distribute, see Create and Share Toolboxes.
For examples, see:
build | clibgen.generateLibraryDefinition