Creates a multi arch (fat) pkg MacOS installer for stackql and StackQL Workbench, notarizes the package with Apple, staples the notarization ticket to the package and uploads it to the matching GitHub release.
stackql_darwin_multiarch.pkg is a product archive that holds two component packages:
| Package | Installs | Notes |
|---|---|---|
com.stackql.pkg |
/usr/local/bin/stackql |
Universal binary, on every supported macOS |
io.stackql.workbench.pkg |
/Applications/StackQL Workbench.app |
Universal app, only on the macOS version the app needs (13 or later today) or newer |
sudo installer -pkg stackql_darwin_multiarch.pkg -target / installs both. On a macOS older than the app needs, only stackql is installed.
The package runs no scripts at install time and writes nothing to a home folder. The app keeps its providers in ~/.stackql, the folder the stackql command uses when it is started in the home folder, and creates it itself as the user. Do not create it from an install script, it would belong to root.
Neither component package resets the owner or mode of a folder that already exists, so /usr/local/bin and /Applications are left as they are (see keep_folder_permissions in create-installer.sh).
The script is designed to run on a dedicated packaging Mac. It needs:
- Xcode command line tools (
lipo,codesign,pkgbuild,productbuild,pkgutil,xcrun notarytool,xcrun stapler) - Apple Developer ID Application and Developer ID Installer certificates installed in the login keychain
- GitHub CLI (
gh), authenticated with an account that can read workflow artifacts and upload release assets instackql/stackql(gh auth login, the defaultrepoandworkflowscopes are sufficient) jq- Network access to
github.com, where the StackQL Workbench release is downloaded from withcurl(public)
Copy vars.sh.example to vars.sh and populate it. vars.sh is gitignored and holds the machine specific values: team id, Apple ID, signing identities, the login keychain password and the app specific password used for notarization.
cp vars.sh.example vars.shPass the stackql build number and the StackQL Workbench release to bundle. The build number is the run number of the Build workflow in stackql/stackql and is the patch component of the version (for example build 669 is v0.11.669). The StackQL Workbench release can be given with or without the leading v.
bash create-installer.sh 669 v0.1.0The script will:
- Check that the
stackql/stackql-workbenchrelease (v0.1.0above) holdsstackql-workbench_darwin_multiarch.app.tar.gzand its.sha256 - Unlock the login keychain and store the notarization credentials as the
stackqlnotarytool profile - Look up the
Buildworkflow run for the build number and download thestackql_darwin_amd64andstackql_darwin_arm64artifacts todownloads/(gitignored) - Extract both binaries, combine them into a universal binary with
lipoand read the version fromstackql --version - Look up the GitHub release for the version, if it does not exist the script stops with
Release x.x.x does not exist, please create it first - Check whether
stackql_darwin_multiarch.pkgand its.sha256sidecar are already assets of that release, and read the SHA-256 digest GitHub recorded for the package - Download
stackql-workbench_darwin_multiarch.app.tar.gzand its.sha256fromhttps://github.com/stackql/stackql-workbench/releases/download/<workbench release>/, check it withshasum -a 256 -cand unpack it withtar -xzf. The script stops if the app is notio.stackql.workbench, itsCFBundleShortVersionStringis not the release version, it is not universal, or it holds code other than its main executable - Sign the
stackqlbinary. Replace the ad hoc signature of the app with the Developer ID Application one (hardened runtime, timestamp), verify it withcodesign --verify --deep --strict, notarize the app and staple its ticket - Build the two component packages with
pkgbuild, each from a folder underbuild/(gitignored) that holds only what is installed, and check the payload of each one withpkgutil --payload-files - Combine them into one product archive with
productbuild, signed with the Developer ID Installer identity, then notarize it and staple the ticket - Compute
stackql_darwin_multiarch.pkg.sha256(sha256sum format) from the stapled package, upload the package and the sidecar to the release and verify the digest GitHub recorded for the attached package, or, if the package already exists, leave it indist/package/for a manual update and upload the sidecar only if the attached package is byte-identical to the local one
Outputs are written to dist/package/stackql_darwin_multiarch.pkg, dist/package/stackql_darwin_multiarch.pkg.sha256 and dist/package/stackql_<version>_darwin_multiarch.pkg.
To try a change to the script without publishing anything, run it for a build whose release already holds the package. The script then uploads nothing and leaves the new package in dist/package/.
| File | Purpose |
|---|---|
config/component.plist |
Component plist of the app package. BundleIsRelocatable is false, so Installer puts the app in /Applications and not where it finds another copy of it |
config/Distribution.xml |
Distribution file of the product archive. Sets hostArchitectures="x86_64,arm64" and selects the app package only on a macOS the app can run on. The version it compares against is filled in by the script from the LSMinimumSystemVersion of the app |
The identifiers and file names of the two component packages are in create-installer.sh and in config/Distribution.xml, and the app name is also in config/component.plist. Change them together.
The following can be overridden with environment variables if needed:
| Variable | Default | Purpose |
|---|---|---|
GH_REPO |
stackql/stackql |
Repo to read artifacts from and upload the release asset to |
GH_WORKFLOW |
build.yml |
Workflow whose run number is the build number |
GH_RUN_LOOKUP_LIMIT |
500 |
How many recent workflow runs to search for the build number |
The script checks the signatures, the payloads, the stapled tickets and Gatekeeper acceptance while it builds. The checks below are for a Mac the package is installed on. Run them on Apple Silicon and on Intel. The folder check matters most on a Mac where a package manager owns /usr/local/bin.
Before installing:
PKG=dist/package/stackql_darwin_multiarch.pkg
pkgutil --check-signature "$PKG"
xcrun stapler validate "$PKG"
spctl -a -vv -t install "$PKG"
# only ., ./stackql and ./StackQL Workbench.app with its contents
pkgutil --payload-files "$PKG"Install, and check that the owner and mode of the two folders are the same before and after:
stat -f '%Su:%Sg %Lp %N' /usr/local/bin /Applications
sudo installer -pkg "$PKG" -target /
stat -f '%Su:%Sg %Lp %N' /usr/local/bin /ApplicationsAfter installing:
/usr/local/bin/stackql --version
pkgutil --files com.stackql.pkg
pkgutil --files io.stackql.workbench.pkg
codesign --verify --deep --strict --verbose=2 "/Applications/StackQL Workbench.app"
spctl -a -vv "/Applications/StackQL Workbench.app"
xcrun stapler validate "/Applications/StackQL Workbench.app"
open "/Applications/StackQL Workbench.app"The app opens with no Gatekeeper prompt. In its Settings the engine is /usr/local/bin/stackql, "installed with the app", and the data folder is ~/.stackql, owned by the user and not by root.