Mac Package Generator streamlines the creation of macOS packages by leveraging GitHub Actions. With built-in git source control, this end-to-end solution automates the process of building, signing, and notarizing a macOS package into a GitHub Release. Creating a new package project is simple with the one-line "create project" script.
- Scripts to support the workflow
create_project.sh
- initiate a new git project using this repository as a templatebuild_package.sh
- builds, signs and notarizes a packageinstall_munkipkg.sh
- install the munkipkg dependency as requiredpre-commit
- a git Hook to ensure git compatibility via a BOM.txt fileinstall_dependencies.sh
- run this script after you clone an existing project
This solution comes with a guided install script. On your local machine cd
into a working directory for your packages and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/jorks/MacPkgGen/main/helpers/create_project.sh)"
The script will:
- Prompt you for the name of your new package project
- Prompt you for the URL of the remote GitHub repository (optional)
- Install XCode Command Line Tools (if not installed)
- Clone this project and initiate a new git project
- Install Munki PKG in a tmp directory
- Create a new Munki PKG project
- Add a pre-commit git hook to the local git project
- If a remote URL is provided, push the initial commit
This solution uses Munki PKG to do the heavy lifting in building the package. Please refer to their guide for detailed instructions using Munki PKG. After creating a new project, you would typically:
Setup the Package
- Update the
build-info
file with your package details - Add Folders and Files to the
payload
directory and set ownership and permissions as desired - Add any required
preinstall
andpostinstall
scripts to thescripts
directory.
Use git to commit and push your changes to GitHub
git add .
to add all the changes and new filesgit commit
the changes which will trigger thepre-commit
git hook scriptgit push
and head over to GitHub and kick off the workflow in the actions tab.
You may also wish to update some of the text or triggers in the .git/workflow
files.
This project requires some specific GitHub settings and secrets to be configured in the repository.
Enable Write Permissions:
GITHUB_TOKEN
- this is an automatically created token used in workflow files. You will need to enable write permissions for this token:
Go to Settings > Actions > General and set the "Workflow permissions" to "Read and write permissions".
Secrets Required for Package Signing:
Key | Value Description |
---|---|
PKG_CERTIFICATES_P12 | A base64 output of the developer certificate P12 file. Use this command: base64 -i <certificate_name>.p12 | pbcopy |
PKG_CERTIFICATES_P12_PASSWORD | The password used to decrypt the developer certificate P12 file |
PKG_KEYCHAIN_PASSWORD | Any randomly generated password. |
Secrets Required for Notarization:
Optional - if these are not configured your package will simply skip notarization.
Key | Value Description |
---|---|
NOTARIZE_APPLE_ID | Apple ID for the Apple Developer account to submit the package for notarization |
NOTARIZE_PASSWORD | App Specific Password generated for this account at appleid.apple.com |
NOTARIZE_TEAM_ID | The Team ID from the developer certificate. |
All the workflows are configured to run manually when you click "Run Workflow" via the GUI.
This is defined with on: [workflow_dispatch]
in the workflow files.
You may wish to change this, please refer to the GitHub documentation.
When you clone an existing project you will need to run the install_dependencies.sh
script. This will:
- Check for Xcode CLT and prompt you to install them if they are missing
- Install MunkiPKG
- Add the git pre-commit hook
- Sync the BOM file into the local git project.