mas/script/package
Ben Chatelain d583e74951 📜 Make version dynamic in package script
Also call install script instead of separate xcodebuild install command

Fixes #179
2018-12-20 19:03:14 -07:00

41 lines
1.4 KiB
Bash
Executable file

#!/bin/bash -ex
BUILD_DIR="$PWD/build"
INTERNAL_PACKAGE="$BUILD_DIR/mas_temp.pkg"
OUTPUT_PACKAGE="$BUILD_DIR/mas.pkg"
IDENTIFIER="com.mphys.mas-cli"
COMPONENTS_PLIST="Homebrew/Components.plist"
DISTRIBUTION_PLIST="Homebrew/Distribution.plist"
# Destination for `xcodebuild install`
# DSTROOT will be updated if unset.
INSTALL_TEMPORARY_FOLDER=${DSTROOT:-build/distributions}
VERSION=$(agvtool what-marketing-version -terse1)
# Run Xcode's install process
script/install
echo "==> 📦 Assemble an installer package"
# Assemble pkg. Using /usr/local prefix to avoid the following errors with "/"
# - installer: The install failed (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance.)
# - GUI warning: This package is incompatible with this version of macOS and may fail to install. (may damage your system... )
pkgbuild \
--component-plist "$COMPONENTS_PLIST" \
--identifier "$IDENTIFIER" \
--install-location "/usr/local" \
--root "$INSTALL_TEMPORARY_FOLDER" \
--version "$VERSION" \
"$INTERNAL_PACKAGE"
# Build 2nd pkg from 1st. Not sure why, but this is how Carthage does it.
# https://github.com/Carthage/Carthage/blob/master/Makefile#L87
productbuild \
--distribution "$DISTRIBUTION_PLIST" \
--package-path "$INTERNAL_PACKAGE" \
"$OUTPUT_PACKAGE"
echo "==> 🔢 Files Hashes"
shasum -a 256 mas.pkg