📦 Build an installer package

This commit is contained in:
Ben Chatelain 2018-10-15 22:17:07 -06:00
parent 343c27b517
commit f64b071468
5 changed files with 88 additions and 13 deletions

29
Homebrew/Components.plist Normal file
View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>BundleIsVersionChecked</key>
<false/>
<key>BundleOverwriteAction</key>
<string>upgrade</string>
<key>ChildBundles</key>
<array>
<dict>
<key>BundleOverwriteAction</key>
<string></string>
<key>RootRelativeBundlePath</key>
<string>Library/Frameworks/MasKit.framework/Versions/A/Frameworks/Commandant.framework</string>
</dict>
<dict>
<key>BundleOverwriteAction</key>
<string></string>
<key>RootRelativeBundlePath</key>
<string>Library/Frameworks/MasKit.framework/Versions/A/Frameworks/Result.framework</string>
</dict>
</array>
<key>RootRelativeBundlePath</key>
<string>Library/Frameworks/MasKit.framework</string>
</dict>
</array>
</plist>

View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="2">
<pkg-ref id="com.mphys.mas-cli"/>
<domains enable_localSystem="true" enable_anywhere="true" enable_currentUserHome="false" />
<options customize="never" require-scripts="false"/>
<volume-check>
<allowed-os-versions>
<os-version min="10.10"/>
</allowed-os-versions>
</volume-check>
<choices-outline>
<line choice="default">
<line choice="com.mphys.mas-cli"/>
</line>
</choices-outline>
<choice id="default"/>
<choice id="com.mphys.mas-cli" visible="false">
<pkg-ref id="com.mphys.mas-cli"/>
</choice>
<pkg-ref id="com.mphys.mas-cli" version="1.0.0" onConclusion="none">MasTemp.pkg</pkg-ref>
</installer-gui-script>

View file

@ -785,12 +785,10 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO;
COPY_PHASE_STRIP = NO;
DEPLOYMENT_LOCATION = YES;
DSTROOT = "$(SRCROOT)";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
INSTALL_PATH = /build;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/. @executable_path/MasKit.framework/Versions/Current/Frameworks /Library/Frameworks /Library/Frameworks/MasKit.framework/Versions/Current/Frameworks $(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.mphys.mas-cli";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -825,13 +823,11 @@
FRAMEWORK_VERSION = A;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MasKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = at.phatbl.MasKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_INCLUDE_PATHS = "$(inherited) $(SRCROOT)/PrivateFrameworks/CommerceKit $(SRCROOT)/PrivateFrameworks/StoreFoundation";
SWIFT_VERSION = 4.2;
@ -864,12 +860,10 @@
FRAMEWORK_VERSION = A;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MasKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = at.phatbl.MasKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "$(inherited) $(SRCROOT)/PrivateFrameworks/CommerceKit $(SRCROOT)/PrivateFrameworks/StoreFoundation";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;

View file

@ -1,9 +1,11 @@
#!/bin/bash -e
BUILD_DIR=build
INSTALL_DIR=/tmp/mas-cli.dst
main() {
rm -rf $BUILD_DIR/
rm -rf ${BUILD_DIR:?}
rm -rf ${INSTALL_DIR:?}
}
main

View file

@ -1,4 +1,6 @@
#!/bin/bash -e
#!/bin/bash -ex
xcodebuild install
pushd build
@ -6,12 +8,39 @@ echo "==> 🗜️ Compressing mas.xcarchive"
zip -r mas.xcarchive.zip mas.xcarchive
echo "==> ️🗜️ Compressing binary and framework"
pushd mas.xcarchive/Products/build
zip -r mas-cli.zip mas MasKit.framework
mv mas-cli.zip ../../../
pushd mas.xcarchive/Products
zip -r \
mas-cli.zip \
usr/local/bin/mas \
Library/Frameworks/MasKit.framework
mv mas-cli.zip ../../
popd
echo -n "==> 🔢 SHA256: "
shasum -a 256 mas-cli.zip
echo "==> 📦 Assemble an installer package"
IDENTIFIER=com.mphys.mas-cli
COMPONENTS_PLIST=../Homebrew/Components.plist
DISTRIBUTION_PLIST=../Homebrew/Distribution.plist
INSTALL_TEMPORARY_FOLDER=/tmp/mas-cli.dst
INTERNAL_PACKAGE=mas_temp.pkg
OUTPUT_PACKAGE=mas.pkg
VERSION_STRING=1.1.1
tree "$INSTALL_TEMPORARY_FOLDER"
pkgbuild \
--component-plist "$COMPONENTS_PLIST" \
--identifier "$IDENTIFIER" \
--install-location "/" \
--root "$INSTALL_TEMPORARY_FOLDER" \
--version "$VERSION_STRING" \
"$INTERNAL_PACKAGE"
productbuild \
--distribution "$DISTRIBUTION_PLIST" \
--package-path "$INTERNAL_PACKAGE" \
"$OUTPUT_PACKAGE"
echo -n "==> 🔢 SHA256 "
shasum -a 256 mas-cli.zip mas.xcarchive.zip mas.pkg
popd