-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Makefile for building signed, notarized pkg of SwiftPM package
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
*.pkg | ||
pkg | ||
.DS_Store | ||
*.log | ||
.build | ||
build | ||
artifacts | ||
|
||
.swiftpm | ||
.vscode | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
PRODUCT = $(shell /usr/bin/plutil -extract CFBundleName raw Sources/Resources/Info.plist) | ||
VERSION = $(shell /usr/bin/plutil -extract CFBundleShortVersionString raw Sources/Resources/Info.plist) | ||
BUNDLE_ID = $(shell /usr/bin/plutil -extract CFBundleIdentifier raw Sources/Resources/Info.plist) | ||
|
||
BINARY = .build/apple/Products/Release/${PRODUCT} | ||
PKG_ROOT = ./pkg/${PRODUCT}-${VERSION} | ||
PKG_DIR = ${PKG_ROOT}/usr/local/bin | ||
ARTIFACTS_DIR = "artifacts" | ||
NONDIST_PKG = ${ARTIFACTS_DIR}/intermediary_${PRODUCT}-${VERSION}.pkg | ||
PKG = ${ARTIFACTS_DIR}/${PRODUCT}-${VERSION}.pkg | ||
|
||
CODESIGN_IDENTITY = "Developer ID Application: Kyle Crawford (Z5J8CJBUWC)" | ||
PKG_CODESIGN_IDENTITY = "Developer ID Installer: Kyle Crawford (Z5J8CJBUWC)" | ||
NOTARY_KEYCHAIN_PROFILE = "notarytool.dockutil.com" | ||
|
||
|
||
${BINARY}: | ||
swift build -c release --product ${PRODUCT} --arch arm64 --arch x86_64 | ||
xcrun codesign -s ${CODESIGN_IDENTITY} \ | ||
--options=runtime \ | ||
--timestamp \ | ||
${BINARY} | ||
|
||
${PKG}: ${BINARY} | ||
rm -rf "${PKG_ROOT}" || true | ||
mkdir -p ${PKG_DIR} | ||
mkdir -p ${ARTIFACTS_DIR} | ||
cp ${BINARY} ${PKG_DIR} | ||
xcrun pkgbuild --root ${PKG_ROOT} \ | ||
--identifier "${BUNDLE_ID}" \ | ||
--version "${VERSION}" \ | ||
--install-location "/" \ | ||
--sign ${PKG_CODESIGN_IDENTITY} \ | ||
${NONDIST_PKG} | ||
productbuild --package ${NONDIST_PKG} \ | ||
--identifier "${BUNDLE_ID}" \ | ||
--version "${VERSION}" \ | ||
--sign ${PKG_CODESIGN_IDENTITY} \ | ||
${PKG} | ||
|
||
.PHONY: build | ||
build: ${BINARY} | ||
|
||
.PHONY: package | ||
package: ${PKG} | ||
|
||
.PHONY: notarize | ||
notarize: ${PKG} | ||
xcrun notarytool submit ${PKG} \ | ||
--keychain-profile ${NOTARY_KEYCHAIN_PROFILE} \ | ||
--wait | ||
|
||
.PHONY: staple | ||
staple: | ||
xcrun stapler staple "${PKG}" | ||
|
||
.PHONY: clean | ||
clean: | ||
swift package clean | ||
|
||
.PHONY: release | ||
release: clean package notarize staple |