mirror of
https://github.com/mas-cli/mas
synced 2024-11-21 19:23:01 +00:00
Use double quotes around bash substitutions.
Use braces around bash variable uses. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
parent
5b96b77e22
commit
f1a9cde9fd
16 changed files with 73 additions and 73 deletions
16
.github/workflows/release.yml
vendored
16
.github/workflows/release.yml
vendored
|
@ -43,7 +43,7 @@ jobs:
|
|||
|
||||
- id: pre_release
|
||||
run: |
|
||||
echo "PRE_RELEASE=$(grep -q '-' <<<$MAS_VERSION && echo 'true' || echo 'false')" >>"$GITHUB_OUTPUT"
|
||||
echo "PRE_RELEASE=$(grep -q '-' <<<"${MAS_VERSION}" && echo 'true' || echo 'false')" >>"${GITHUB_OUTPUT}"
|
||||
|
||||
- id: release_branch
|
||||
run: |
|
||||
|
@ -129,7 +129,7 @@ jobs:
|
|||
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
||||
if: ${{ needs.start.outputs.dry_run == 'false' }}
|
||||
run: |
|
||||
gh release upload ${MAS_VERSION} \
|
||||
gh release upload "${MAS_VERSION}" \
|
||||
.build/mas.pkg
|
||||
|
||||
homebrew-tap:
|
||||
|
@ -187,7 +187,7 @@ jobs:
|
|||
git switch "${RELEASE_BRANCH}"
|
||||
|
||||
cp -v \
|
||||
${GITHUB_WORKSPACE}/Homebrew/mas-tap.rb \
|
||||
"${GITHUB_WORKSPACE}/Homebrew/mas-tap.rb" \
|
||||
Formula/mas.rb
|
||||
|
||||
git add Formula/mas.rb
|
||||
|
@ -210,8 +210,8 @@ jobs:
|
|||
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
||||
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
||||
run: |
|
||||
DRY_RUN=${DRY_RUN} \
|
||||
script/brew_tap_update ${MAS_VERSION}
|
||||
DRY_RUN="${DRY_RUN}" \
|
||||
script/brew_tap_update "${MAS_VERSION}"
|
||||
|
||||
- name: 🚀 Upload Bottles
|
||||
env:
|
||||
|
@ -220,7 +220,7 @@ jobs:
|
|||
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
||||
if: ${{ needs.start.outputs.dry_run == 'false' }}
|
||||
run: |
|
||||
gh release upload ${MAS_VERSION} \
|
||||
gh release upload "${MAS_VERSION}" \
|
||||
.build/bottles/mas-*.bottle.tar.gz
|
||||
|
||||
homebrew-core:
|
||||
|
@ -250,5 +250,5 @@ jobs:
|
|||
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
||||
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
||||
run: |
|
||||
DRY_RUN=${DRY_RUN} \
|
||||
script/brew_core_update ${MAS_VERSION}
|
||||
DRY_RUN="${DRY_RUN}" \
|
||||
script/brew_core_update "${MAS_VERSION}"
|
||||
|
|
|
@ -8,8 +8,8 @@ _mas() {
|
|||
COMPREPLY=()
|
||||
_get_comp_words_by_ref cur prev words cword
|
||||
fi
|
||||
if [[ $cword -eq 1 ]]; then
|
||||
COMPREPLY=($(compgen -W "$(mas help | tail -n +3 | awk '{print $1}')" -- "$cur"))
|
||||
if [[ "${cword}" -eq 1 ]]; then
|
||||
COMPREPLY=($(compgen -W "$(mas help | tail -n +3 | awk '{print $1}')" -- "${cur}"))
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
function __fish_mas_list_available -d "Lists applications available to install from the Mac App Store"
|
||||
set query (commandline -ct)
|
||||
if set results (command mas search $query 2>/dev/null)
|
||||
for res in $results
|
||||
echo $res
|
||||
if set results (command mas search "${query}" 2>/dev/null)
|
||||
for res in ${results}
|
||||
echo "${res}"
|
||||
end | string trim --left | string replace -r '\s+' '\t'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
BUILD_DIR="${PWD}/.build"
|
||||
BOTTLE_DIR="${BUILD_DIR}/bottles"
|
||||
CORE_TAP_PATH="$(brew --repo homebrew/core)"
|
||||
MAS_VERSION=$(script/version)
|
||||
MAS_VERSION="$(script/version)"
|
||||
ROOT_URL="https://github.com/mas-cli/mas/releases/download/v${MAS_VERSION}"
|
||||
|
||||
# Supports macOS 10.13 and later
|
||||
|
@ -41,8 +41,8 @@ OS_NAMES=(
|
|||
|
||||
# Semantic version number split into a list using ugly, bash 3 compatible syntax
|
||||
IFS=" " read -r -a CURRENT_OS_VERSION <<<"$(sw_vers -productVersion | sed 's/\./ /g')"
|
||||
CURRENT_OS_VERSION_MAJOR=${CURRENT_OS_VERSION[0]}
|
||||
CURRENT_OS_VERSION_MINOR=${CURRENT_OS_VERSION[1]}
|
||||
CURRENT_OS_VERSION_MAJOR="${CURRENT_OS_VERSION[0]}"
|
||||
CURRENT_OS_VERSION_MINOR="${CURRENT_OS_VERSION[1]}"
|
||||
|
||||
echo "CURRENT_OS_VERSION_MAJOR: ${CURRENT_OS_VERSION_MAJOR}"
|
||||
echo "CURRENT_OS_VERSION_MINOR: ${CURRENT_OS_VERSION_MINOR}"
|
||||
|
@ -121,17 +121,17 @@ if ! test -e "${OLD_FILENAME}"; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
SHA256=$(shasum -a 256 "${OLD_FILENAME}" | cut -f 1 -d ' ' -)
|
||||
SHA256="$(shasum -a 256 "${OLD_FILENAME}" | cut -f 1 -d ' ' -)"
|
||||
|
||||
mkdir -p "${BOTTLE_DIR}"
|
||||
|
||||
# Start of bottle block
|
||||
BOTTLE_BLOCK=$(
|
||||
BOTTLE_BLOCK="$(
|
||||
cat <<-EOF
|
||||
bottle do
|
||||
root_url "${ROOT_URL}"
|
||||
EOF
|
||||
)
|
||||
)"
|
||||
|
||||
################################################################################
|
||||
#
|
||||
|
@ -145,21 +145,21 @@ for os in "${OS_NAMES[@]}"; do
|
|||
|
||||
# Append each os
|
||||
# BOTTLE_BLOCK="$(printf "${BOTTLE_BLOCK}\n sha256 cellar: :any_skip_relocation, %-15s %s" "${os}:" "${SHA256}")"
|
||||
BOTTLE_BLOCK="${BOTTLE_BLOCK}"$(
|
||||
BOTTLE_BLOCK="${BOTTLE_BLOCK}$(
|
||||
cat <<-EOF
|
||||
|
||||
sha256 cellar: :any_skip_relocation, ${os}: "${SHA256}"
|
||||
EOF
|
||||
)
|
||||
)"
|
||||
done
|
||||
|
||||
# End of bottle block
|
||||
BOTTLE_BLOCK=$(
|
||||
BOTTLE_BLOCK="$(
|
||||
cat <<-EOF
|
||||
|
||||
end
|
||||
EOF
|
||||
)
|
||||
)"
|
||||
|
||||
rm "${OLD_FILENAME}"
|
||||
ls -l "${BOTTLE_DIR}"
|
||||
|
|
|
@ -24,7 +24,7 @@ function usage {
|
|||
}
|
||||
|
||||
# Max 3 arguments
|
||||
if [[ $# -gt 3 ]]; then
|
||||
if [[ "${#}" -gt 3 ]]; then
|
||||
usage 1>&2
|
||||
fi
|
||||
|
||||
|
@ -41,11 +41,11 @@ while getopts "d" o; do
|
|||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
shift "$((OPTIND - 1))"
|
||||
|
||||
# DRY_RUN environment variable
|
||||
# shellcheck disable=SC2153
|
||||
if [[ $DRY_RUN == 'true' ]]; then
|
||||
if [[ "${DRY_RUN}" == 'true' ]]; then
|
||||
dry_run='-d'
|
||||
fi
|
||||
|
||||
|
@ -63,7 +63,7 @@ if [[ -n "${2}" ]]; then
|
|||
REVISION="${2}"
|
||||
else
|
||||
# Derive revision from version. Fails if MAS_VERSION is not a tag.
|
||||
REVISION=$(git rev-parse "${MAS_VERSION}")
|
||||
REVISION="$(git rev-parse "${MAS_VERSION}")"
|
||||
fi
|
||||
|
||||
echo "REVISION: ${REVISION}"
|
||||
|
@ -139,13 +139,13 @@ brew bump-formula-pr \
|
|||
mas
|
||||
|
||||
# brew exit status
|
||||
status=$?
|
||||
if [[ ${status} -ne 0 ]]; then
|
||||
status="${?}"
|
||||
if [[ "${status}" -ne 0 ]]; then
|
||||
echo "Formula did not validate using 'brew bump-formula-pr'" 1>&2
|
||||
exit ${status}
|
||||
exit "${status}"
|
||||
fi
|
||||
|
||||
if [[ $dry_run == '-d' ]]; then
|
||||
if [[ "${dry_run}" == '-d' ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ function usage {
|
|||
}
|
||||
|
||||
# Max 2 arguments
|
||||
if [[ $# -gt 2 ]]; then
|
||||
if [[ "${#}" -gt 2 ]]; then
|
||||
usage 1>&2
|
||||
fi
|
||||
|
||||
|
@ -33,7 +33,7 @@ if [[ -n "${2}" ]]; then
|
|||
REVISION="${2}"
|
||||
else
|
||||
# Derive revision from version. Fails if MAS_VERSION is not a tag.
|
||||
REVISION=$(git rev-parse "${MAS_VERSION}")
|
||||
REVISION="$(git rev-parse "${MAS_VERSION}")"
|
||||
fi
|
||||
|
||||
echo "REVISION: ${REVISION}"
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# Runs all related scripts for generating all artifacts.
|
||||
#
|
||||
|
||||
MAS_VERSION=$(script/version)
|
||||
MAS_VERSION="$(script/version)"
|
||||
|
||||
echo "Building mas $MAS_VERSION artifacts"
|
||||
echo "Building mas ${MAS_VERSION} artifacts"
|
||||
|
||||
script/clean
|
||||
script/build --universal
|
||||
|
|
|
@ -20,7 +20,7 @@ fi
|
|||
printf $'==> 🚨 Formatting mas\n'
|
||||
|
||||
for LINTER in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do
|
||||
if [[ ! -x "$(command -v ${LINTER})" ]]; then
|
||||
if [[ ! -x "$(command -v "${LINTER}")" ]]; then
|
||||
printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${LINTER}" "${LINTER}"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -10,24 +10,24 @@
|
|||
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb
|
||||
#
|
||||
|
||||
ARCH=$(uname -m)
|
||||
RELEASE=.build/${ARCH}-apple-macosx/release
|
||||
MAS_VERSION=$(script/version)
|
||||
ARCH="$(uname -m)"
|
||||
RELEASE=".build/${ARCH}-apple-macosx/release"
|
||||
MAS_VERSION="$(script/version)"
|
||||
PREFIX=/usr/local
|
||||
|
||||
while test -n "$1"; do
|
||||
if [[ "$1" == '--universal' ]]; then
|
||||
while test -n "${1}"; do
|
||||
if [[ "${1}" == '--universal' ]]; then
|
||||
ARCH=universal
|
||||
RELEASE=.build/release
|
||||
else
|
||||
# Override default prefix path with optional arg
|
||||
PREFIX="$1"
|
||||
PREFIX="${1}"
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
echo "==> 📲 Installing mas ($MAS_VERSION) for $ARCH to $PREFIX"
|
||||
echo "==> 📲 Installing mas (${MAS_VERSION}) for ${ARCH} to ${PREFIX}"
|
||||
ditto -v \
|
||||
"$RELEASE/mas" \
|
||||
"$PREFIX/bin/mas"
|
||||
"${RELEASE}/mas" \
|
||||
"${PREFIX}/bin/mas"
|
||||
|
|
|
@ -22,7 +22,7 @@ fi
|
|||
printf $'==> 🚨 Linting mas (%s)\n' "$(script/version --write)"
|
||||
|
||||
for linter in git markdownlint periphery shellcheck shfmt swift-format swiftformat swiftlint yamllint; do
|
||||
if [[ ! -x "$(command -v ${linter})" ]]; then
|
||||
if [[ ! -x "$(command -v "${linter}")" ]]; then
|
||||
printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# Builds macOS installer component and distribution packages.
|
||||
#
|
||||
|
||||
BUILD_DIR="$PWD/.build"
|
||||
COMPONENT_PACKAGE="$BUILD_DIR/mas_components.pkg"
|
||||
DISTRIBUTION_PACKAGE="$BUILD_DIR/mas.pkg"
|
||||
BUILD_DIR="${PWD}/.build"
|
||||
COMPONENT_PACKAGE="${BUILD_DIR}/mas_components.pkg"
|
||||
DISTRIBUTION_PACKAGE="${BUILD_DIR}/mas.pkg"
|
||||
|
||||
IDENTIFIER="com.mphys.mas-cli"
|
||||
|
||||
|
@ -18,26 +18,26 @@ DISTRIBUTION_PLIST="Package/Distribution.plist"
|
|||
|
||||
# Destination for install root
|
||||
DSTROOT=.build/distributions
|
||||
script/install "$DSTROOT/usr/local" --universal
|
||||
script/install "${DSTROOT}/usr/local" --universal
|
||||
|
||||
MAS_VERSION=$(script/version)
|
||||
MAS_VERSION="$(script/version)"
|
||||
|
||||
echo "==> 📦 Assemble an installer package"
|
||||
|
||||
# Assemble macOS installer component package (aka "product archive").
|
||||
pkgbuild \
|
||||
--identifier "$IDENTIFIER" \
|
||||
--identifier "${IDENTIFIER}" \
|
||||
--install-location "/" \
|
||||
--version "$MAS_VERSION" \
|
||||
--root "$DSTROOT" \
|
||||
"$COMPONENT_PACKAGE"
|
||||
--version "${MAS_VERSION}" \
|
||||
--root "${DSTROOT}" \
|
||||
"${COMPONENT_PACKAGE}"
|
||||
|
||||
# Build distribution package (aka "product archive"). Not sure why, but this is how Carthage does it.
|
||||
# https://github.com/Carthage/Carthage/blob/master/Makefile#L69
|
||||
productbuild \
|
||||
--distribution "$DISTRIBUTION_PLIST" \
|
||||
--package-path "$BUILD_DIR" \
|
||||
"$DISTRIBUTION_PACKAGE"
|
||||
--distribution "${DISTRIBUTION_PLIST}" \
|
||||
--package-path "${BUILD_DIR}" \
|
||||
"${DISTRIBUTION_PACKAGE}"
|
||||
|
||||
echo "==> 🔢 File Hash"
|
||||
shasum -a 256 "$DISTRIBUTION_PACKAGE"
|
||||
shasum -a 256 "${DISTRIBUTION_PACKAGE}"
|
||||
|
|
|
@ -14,6 +14,6 @@ sudo installer \
|
|||
-pkg .build/mas.pkg \
|
||||
-target /
|
||||
|
||||
pkgutil --pkg-info "$IDENTIFIER"
|
||||
pkgutil --pkg-info "${IDENTIFIER}"
|
||||
|
||||
pkgutil --files "$IDENTIFIER"
|
||||
pkgutil --files "${IDENTIFIER}"
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
#
|
||||
|
||||
# Override default prefix path with optional 1st arg
|
||||
if test -n "$1"; then
|
||||
PREFIX="$1"
|
||||
if test -n "${1}"; then
|
||||
PREFIX="${1}"
|
||||
else
|
||||
PREFIX=$(brew --prefix)
|
||||
PREFIX="$(brew --prefix)"
|
||||
fi
|
||||
|
||||
echo "==> 🔥 Uninstalling mas from $PREFIX"
|
||||
echo "==> 🔥 Uninstalling mas from ${PREFIX}"
|
||||
|
||||
trash -F "$PREFIX/bin/mas" || true
|
||||
trash -F "${PREFIX}/bin/mas" || true
|
||||
|
|
|
@ -22,11 +22,11 @@ check_class_dump() {
|
|||
}
|
||||
|
||||
extract_private_framework_headers() {
|
||||
local framework_name="$1"
|
||||
local framework_name="${1}"
|
||||
shift
|
||||
local directory="Sources/PrivateFrameworks/${framework_name}"
|
||||
mkdir -p "$directory"
|
||||
class-dump -Ho "$directory" "/System/Library/PrivateFrameworks/${framework_name}.framework"
|
||||
mkdir -p "${directory}"
|
||||
class-dump -Ho "${directory}" "/System/Library/PrivateFrameworks/${framework_name}.framework"
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
@ -15,7 +15,7 @@ fi
|
|||
|
||||
if [[ -z "${MAS_VERSION:-}" ]] && git describe >/dev/null 2>&1; then
|
||||
# Use last tag if MAS_VERSION environment variable is unset or empty
|
||||
MAS_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null || true)
|
||||
MAS_VERSION="$(git describe --abbrev=0 --tags 2>/dev/null || true)"
|
||||
fi
|
||||
echo "${MAS_VERSION#v}"
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ function usage {
|
|||
exit 1
|
||||
}
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
if [[ "${#}" -lt 1 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
|
@ -35,7 +35,7 @@ MAS_VERSION="${1}"
|
|||
if [[ "${#}" -ge 2 ]]; then
|
||||
REVISION="${2}"
|
||||
else
|
||||
REVISION=$(git rev-parse "${MAS_VERSION}")
|
||||
REVISION="$(git rev-parse "${MAS_VERSION}")"
|
||||
fi
|
||||
|
||||
echo "MAS_VERSION: ${MAS_VERSION}"
|
||||
|
@ -53,7 +53,7 @@ echo
|
|||
cat "${SWIFT_PACKAGE}"
|
||||
|
||||
# Write new version into brew formulae
|
||||
for file in ${LOCAL_MAS_FORMULA_PATH} ${LOCAL_TAP_FORMULA_PATH}; do
|
||||
for file in "${LOCAL_MAS_FORMULA_PATH}" "${LOCAL_TAP_FORMULA_PATH}"; do
|
||||
echo "${file}"
|
||||
sd '( +tag: +)"[^"]+"' "\$1\"${MAS_VERSION}\"" "${file}"
|
||||
sd '( +revision: +)"[^"]+"' "\$1\"${REVISION}\"" "${file}"
|
||||
|
|
Loading…
Reference in a new issue