Recently I made a Jenkins Pipeline to build a QT Application for multiple Linux distributions, Windows and macOS. In the process I had to figure out how to package a macOS Application.
I ended up building it with a script similar to what I did for Linux.
#!/bin/bash# Compile and prepare a signed .dmg package for distribution# Assumes the environment-variable QTDIR to point to the# Qt installation## Example:# Jarles-Mac-mini:scripts jgaa$ QTDIR=/Users/jgaa/Qt/5.10.0/clang_64 ./package-macos.shif [; then WHID_VERSION="2.0.0" fiif [;then DIST_DIR=fiif [;then SIGN_CERT="Developer ID Application"fiif [; then BUILD_DIR=fiif [;then# Just assume we are run from the scipts directory SRC_DIR=fi && As you can see, I use qmake and make to build the application. That is great, because it can be done from a script, and scripts can be started from Jenkins.
To build the actual dmg package, I use a utility shipped with QT, macdeployqt. This makes sure that all the required libraries are properly packaged into the bundle. My first attempt worked fine on my local machine, but when I downloaded the package from the build machine, I was unable to install it because it was unsigned.
Signing
It turned out that macdeployqt can sign the package. However I needed to create a certificate signed by Apple, of the correct type, issued to the correct entity.
In order to do that, you must be a registered Apple Developer. Then you must go to xcode, open preferences and accounts. I have enrolled my company, rather than myself, in the Apple Developer program, so I had to select the "The Last Viking LTD" team (rather than the personal, team), click on "Manage Certificates", and then create a "Developer ID Application" certificate.

The name of the certificate is then given to macdeployqt after the -codesign option.
So with this in place, I can build a deployable package for macOS directly from Jenkins.