From b774f7efa97463e12f08002d026fabf1b2a2c1d9 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 19 Nov 2024 06:52:22 -0500 Subject: [PATCH 001/131] Fix format violations in `.swiftlint.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .swiftlint.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 10d31447b..da0b88578 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -36,10 +36,11 @@ disabled_rules: - unused_capture_list - vertical_whitespace_between_cases file_types_order: - order: [ - [main_type], - [supporting_type], - [extension], - [preview_provider], - [library_content_provider] - ] + order: + [ + [main_type], + [supporting_type], + [extension], + [preview_provider], + [library_content_provider], + ] From eba98594ae88a7f7bd27ceba15c14778d07dd5b5 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:37:06 -0500 Subject: [PATCH 002/131] Upgrade danger from 3.18.0 to 3.20.2. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/danger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index f278c8df3..6717f744a 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - name: Danger # https://github.com/orgs/danger/packages/container/package/danger-swift - uses: docker://ghcr.io/danger/danger-swift:3.18.0 + uses: docker://ghcr.io/danger/danger-swift:3.20.2 with: args: --failOnErrors --no-publish-check env: From 4c8d21f8cef6e2fa3ab87132882db83e355bdd1b Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:39:30 -0500 Subject: [PATCH 003/131] Use `/bin/bash` instead of `bash` from the `$PATH` to keep things consistent with the shebangs that are used throughout. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/build-test.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 451d38a20..357cca22f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -28,7 +28,7 @@ jobs: # https://github.com/actions/runner/issues/805#issuecomment-942784948 # https://github.com/rolpdog/cffi-mirror/blob/release-1.15/.github/workflows/ci.yaml#L81-L141 # https://github.com/actions/virtual-environments/issues/2187#issuecomment-790507204 - shell: arch -arm64 bash --noprofile --norc -eo pipefail {0} + shell: arch -arm64 /bin/bash --noprofile --norc -eo pipefail {0} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 428fee5c5..2286a8e98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ name: release defaults: run: # Prefixes all `run` commands with the following command to force them to run outside Rosetta. - shell: arch -arm64 bash --noprofile --norc -eo pipefail {0} + shell: arch -arm64 /bin/bash --noprofile --norc -eo pipefail {0} on: release: types: [published] From 7cdd3c4e220c209faad384457034899c69f86d5c Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:43:56 -0500 Subject: [PATCH 004/131] `event.json` has placeholder values, and incorrect & inconsistent version values. It only seems to be used for testing with `act`. `event.json` should either be generated or be manually created; in either case, it should reside somewhere that is ignored by git, as the only source of version info in git should be version tags. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/event.json | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .github/event.json diff --git a/.github/event.json b/.github/event.json deleted file mode 100644 index 85ba787b1..000000000 --- a/.github/event.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "inputs": { - "NAME": "Manual Workflow", - "SOME_VALUE": "ABC" - }, - "release": { - "name": "v1.8.6-beta.1: macOS only test build", - "tag_name": "v1.8.7-beta.1", - "target_commitish": "f8be3e9aaa6c78490277976f17041f2577f5dc21", - "body": "This is a pre-release to facilitate testing for the following fix:\n\n - 🖥️ Only search, outdated and update macOS apps (#505, #496, #491, #336)" - } -} \ No newline at end of file From 30a9daa835ea1c7d00f7ee1972738718abfe83c1 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 12:59:36 -0500 Subject: [PATCH 005/131] mise is installed via `brew bundle`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 3 --- 1 file changed, 3 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index 8af2285a1..d3b8f3c60 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -47,9 +47,6 @@ else brew bundle install --verbose fi -if [[ ! -x "$(command -v mise)" ]]; then - brew install mise -fi mise settings set experimental true mise install --verbose mise list --verbose From 0db6d5d10dce93be788bd55efc017dd5c8394a37 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:00:49 -0500 Subject: [PATCH 006/131] `clean` seems unnecessary in `bootstrap`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 2 -- 1 file changed, 2 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index d3b8f3c60..e9427d826 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -33,8 +33,6 @@ while getopts "f" opt; do esac done -script/clean - printf $'==> 👢 Bootstrapping (%s)\n' "$(script/version)" # Install Homebrew tools From 41aa732ce86619ed912da77ead19150e9357be3b Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:04:30 -0500 Subject: [PATCH 007/131] Remove unused `$echo` variable. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/brew_core_update | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/script/brew_core_update b/script/brew_core_update index af8f46e44..bea52eaa9 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -28,14 +28,12 @@ if [[ $# -gt 3 ]]; then usage 1>&2 fi -echo='' dry_run='' # Detect presence of `-d` dry run option while getopts "d" o; do case "${o}" in d) - echo='echo (DRY-RUN):' dry_run='-d' ;; *) @@ -48,7 +46,6 @@ shift $((OPTIND - 1)) # DRY_RUN environment variable # shellcheck disable=SC2153 if [[ $DRY_RUN == 'true' ]]; then - echo='echo (DRY-RUN):' dry_run='-d' fi @@ -156,7 +153,7 @@ pushd "${CORE_TAP_PATH}" echo "Updating homebrew/core formula with a PR" -$echo brew bump-formula-pr \ +brew bump-formula-pr \ --tag="${MAS_VERSION}" \ --revision="${REVISION}" \ --strict \ From 2c25210278a95e9c5e5fb1b35ff9d4b847a4f4a3 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:05:47 -0500 Subject: [PATCH 008/131] Remove seemingly unnecessary `pushd` & `popd`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/brew_core_update | 4 ---- 1 file changed, 4 deletions(-) diff --git a/script/brew_core_update b/script/brew_core_update index bea52eaa9..78126979a 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -149,8 +149,6 @@ if [[ $dry_run == '-d' ]]; then exit 0 fi -pushd "${CORE_TAP_PATH}" - echo "Updating homebrew/core formula with a PR" brew bump-formula-pr \ @@ -162,5 +160,3 @@ brew bump-formula-pr \ --no-browse \ --fork-org mas-cli \ mas - -popd From 44f9c5f0874ed0eedc6686230d6395cb3052fdbb Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:08:07 -0500 Subject: [PATCH 009/131] Output error to stderr instead of stdout. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/brew_core_update | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/brew_core_update b/script/brew_core_update index 78126979a..f4325de2b 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -141,7 +141,7 @@ brew bump-formula-pr \ # brew exit status status=$? if [[ ${status} -ne 0 ]]; then - echo "Formula did not validate using 'brew bump-formula-pr'" + echo "Formula did not validate using 'brew bump-formula-pr'" 1>&2 exit ${status} fi From b1936d2fc7d81f4740f9c79371c63741afbeb8bf Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:13:30 -0500 Subject: [PATCH 010/131] =?UTF-8?q?Makefile:=20Mirror=20bash=20by=20using?= =?UTF-8?q?=20`${=E2=80=A6}`=20&=20`$(=E2=80=A6)`=20for=20all=20variables?= =?UTF-8?q?=20&=20command=20substitutions,=20respectively.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Makefile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index fabe1b40f..1f3335b65 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,8 @@ SWIFT_VERSION = 5.7.1 # run swift build and see where the output executable is created # OS specific differences -UNAME = ${shell uname} -ARCH = ${shell uname -m} - -ifeq ($(UNAME), Darwin) -PLATFORM = $(ARCH)-apple-macosx +ifeq ($(shell uname), Darwin) +PLATFORM = $(shell uname -m)-apple-macosx EXECUTABLE_DIRECTORY = ./.build/${PLATFORM}/debug endif @@ -39,7 +36,7 @@ help: ## (default) Displays this message @echo "mas Makefile" @echo "" @echo "Targets:" - @grep -E '^[a-zA-Z0-9_-]*:.*?##' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?##"}; {printf $(MAKEFILE_FMT), $$1, $$2}' + @grep -E '^[a-zA-Z0-9_-]*:.*?##' ${MAKEFILE_LIST} | awk 'BEGIN {FS = ":.*?##"}; {printf ${MAKEFILE_FMT}, $$1, $$2}' : # Hacky way to display a newline ## ################################################################################ @@ -56,8 +53,8 @@ version: ## Prints versions of tools used by this Makefile. .PHONY: init init: ## Installs tools. - - swiftenv install $(SWIFT_VERSION) - swiftenv local $(SWIFT_VERSION) + - swiftenv install ${SWIFT_VERSION} + swiftenv local ${SWIFT_VERSION} ################################################################################ # @@ -100,7 +97,7 @@ test: build ## Runs tests. # make run ARGS="asdf" .PHONY: run run: build - ${EXECUTABLE_DIRECTORY}/${CMD_NAME} $(ARGS) + ${EXECUTABLE_DIRECTORY}/${CMD_NAME} ${ARGS} .PHONY: update-headers update-headers: ## Updates private macOS headers. @@ -138,7 +135,7 @@ build-universal: ## Builds a "fat" universal binary. .PHONY: install install: build ## Installs the binary. - script/install $(PREFIX) + script/install ${PREFIX} .PHONY: install-universal install-universal: build-universal ## Installs a universal binary. From 16dd4328ab7a904265b95d894efa312a8774e9c4 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:05:55 -0500 Subject: [PATCH 011/131] `script/bottle`: reword "better" as "newer". Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bottle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/bottle b/script/bottle index e4c7bb04c..96bc48c39 100755 --- a/script/bottle +++ b/script/bottle @@ -67,7 +67,7 @@ case "${CURRENT_OS_VERSION_MAJOR}" in CURRENT_PLATFORM=catalina ;; *) - echo "Unsupported macOS version. This script requires Catalina or better." + echo "Unsupported macOS version. This script requires Catalina or newer." exit 1 ;; esac From 491a1b8ec2401b234c84ddd547ba47aba2f947a1 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:08:44 -0500 Subject: [PATCH 012/131] Upgrade Xcode dependency to 14.2. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Homebrew/mas-tap.rb | 7 +------ Homebrew/mas.rb | 7 +------ script/build | 2 +- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Homebrew/mas-tap.rb b/Homebrew/mas-tap.rb index 4195b6d3b..d477cd7da 100644 --- a/Homebrew/mas-tap.rb +++ b/Homebrew/mas-tap.rb @@ -28,13 +28,8 @@ class Mas < Formula sha256 cellar: :any_skip_relocation, el_capitan: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" end + depends_on xcode: ["14.2", :build] depends_on :macos - on_arm do - depends_on xcode: ["12.2", :build] - end - on_intel do - depends_on xcode: ["12.0", :build] - end def install system "script/build" diff --git a/Homebrew/mas.rb b/Homebrew/mas.rb index 050648f6a..7e1373205 100644 --- a/Homebrew/mas.rb +++ b/Homebrew/mas.rb @@ -23,13 +23,8 @@ class Mas < Formula sha256 cellar: :any_skip_relocation, catalina: "d241d3b9156b033f3d2c31684a44de726297e07fd9bd5e3ccc4c36e4f1c3baf3" end + depends_on xcode: ["14.2", :build] depends_on :macos - on_arm do - depends_on xcode: ["12.2", :build] - end - on_intel do - depends_on xcode: ["12.0", :build] - end def install system "script/build" diff --git a/script/build b/script/build index fd84a9a31..1f327635b 100755 --- a/script/build +++ b/script/build @@ -22,7 +22,7 @@ if [[ "${#}" -ge 1 && "${1}" == '--universal' ]]; then ) fi -# Disable the manifest cache on Xcode 12.5 and later. +# Disable the manifest cache. CACHE=() if [[ "$(swift build --help)" =~ manifest-cache ]]; then CACHE=(--manifest-cache none) From 3918bf29e0fe864bb7b16c0fbd1a8d5e441abfc1 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:52:41 -0500 Subject: [PATCH 013/131] Obtain path to tap via `brew --repo mas-cli/tap` instead of hardcoding it. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2286a8e98..1a96c6f74 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,7 @@ jobs: mas_version: ${{ steps.mas_version.outputs.mas_version }} pre_release: ${{ steps.pre_release.outputs.pre_release }} release_branch: ${{ steps.release_branch.outputs.release_branch }} + tap_path: ${{ steps.tap_path.outputs.tap_path }} steps: # Logs event details and sets `DRY_RUN` env var # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable @@ -48,6 +49,10 @@ jobs: run: | echo "RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT" + - id: tap_path + run: | + echo "TAP_PATH=\"$(brew --repo mas-cli/tap)\"" >>"$GITHUB_OUTPUT" + prepare-release: runs-on: macos-15 needs: [start] @@ -148,11 +153,14 @@ jobs: # This is necessary to avoid the following error: # Error: No available formula or cask with the name "mas-cli/tap/mas". - name: 🚰 Checkout mas tap + env: + TAP_PATH: ${{ needs.start.outputs.tap_path }} run: | - rm -rf /opt/homebrew/Library/Taps + TAPS_PATH="$(realpath "$(brew --repo mas-cli/tap)/../..")" + rm -rf "${TAPS_PATH}" mkdir Taps - ln -s $(realpath Taps) /opt/homebrew/Library/Taps - ls -l /opt/homebrew/Library/Taps + ln -s "$(realpath Taps)" "${TAPS_PATH}" + ls -l "${TAPS_PATH}" brew tap mas-cli/tap brew tap @@ -176,7 +184,7 @@ jobs: DRY_RUN: ${{ needs.start.outputs.dry_run }} RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }} MAS_VERSION: ${{ needs.start.outputs.mas_version }} - working-directory: /opt/homebrew/Library/Taps/mas-cli/homebrew-tap + working-directory: ${{ needs.start.outputs.tap_path }} run: | git branch "${RELEASE_BRANCH}" git switch "${RELEASE_BRANCH}" From 9672313d533a916b0882ebae6b0cedc6286d432d Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:58:42 -0500 Subject: [PATCH 014/131] `release.yml`: remove unnecessary output. Remove commented code. Improve step name. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a96c6f74..75b476fd6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -152,7 +152,7 @@ jobs: # must be run for Homebrew to see the dir as a tap. # This is necessary to avoid the following error: # Error: No available formula or cask with the name "mas-cli/tap/mas". - - name: 🚰 Checkout mas tap + - name: 🚰 Tap mas tap env: TAP_PATH: ${{ needs.start.outputs.tap_path }} run: | @@ -160,9 +160,7 @@ jobs: rm -rf "${TAPS_PATH}" mkdir Taps ln -s "$(realpath Taps)" "${TAPS_PATH}" - ls -l "${TAPS_PATH}" brew tap mas-cli/tap - brew tap # Checkout with a token for write access - name: 🚰 Re-clone mas tap @@ -170,7 +168,6 @@ jobs: with: repository: mas-cli/homebrew-tap token: ${{ secrets.DEPLOY_TOKEN }} - # brew --repository mas-cli/tap path: Taps/mas-cli/homebrew-tap - name: 🔧 Configure Git Author From e83bd1ed9fe031ae1130ec87bd49267f45e277a8 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:02:05 -0500 Subject: [PATCH 015/131] `release.yml`: Check `pre_release` once for all of `homebrew-core` job instead of once per each step of that job. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75b476fd6..bfdea0012 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -226,23 +226,19 @@ jobs: homebrew-core: runs-on: macos-15 needs: [start, prepare-release, homebrew-tap] - env: - PRE_RELEASE: ${{ needs.start.outputs.pre_release }} + if: ${{ needs.start.outputs.pre_release == 'false' }} steps: - uses: actions/checkout@v4 - if: env.PRE_RELEASE == 'false' with: # A fetch-depth of 0 includes all history and tags for script/version fetch-depth: 0 ref: ${{ needs.start.outputs.release_branch }} - name: 👢 Bootstrap - if: env.PRE_RELEASE == 'false' run: | script/bootstrap -f - name: 🔧 Configure Git Author - if: env.PRE_RELEASE == 'false' run: | git config --global user.name 'masclibot' git config --global user.email 'masclibot@users.noreply.github.com' @@ -253,7 +249,6 @@ jobs: HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} DRY_RUN: ${{ needs.start.outputs.dry_run }} MAS_VERSION: ${{ needs.start.outputs.mas_version }} - if: env.PRE_RELEASE == 'false' run: | DRY_RUN=${DRY_RUN} \ script/brew_core_update ${MAS_VERSION} From ea610a5ba52f14cd014efa0f2b626fee7e44d379 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:16:33 -0500 Subject: [PATCH 016/131] Improve `script/lint` output. Change YAML emoji to fix spacing issue. Move YAML lint before Git lint to keep the names getting progressively shorter. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/lint | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/script/lint b/script/lint index d655a52a2..f2421e8f3 100755 --- a/script/lint +++ b/script/lint @@ -60,12 +60,12 @@ printf -- $'--> 〽️ Markdown\n' markdownlint --config .markdownlint.json .github . ((exit_code |= "${?}")) -printf -- $'--> 🌳 Git\n' -PAGER='cat' git diff --check +printf -- $'--> 📝 YAML\n' +yamllint . ((exit_code |= "${?}")) -printf -- $'--> 🖊 YAML\n' -yamllint . +printf -- $'--> 🌳 Git\n' +PAGER='cat' git diff --check ((exit_code |= "${?}")) printf -- $'--> 🌀 Periphery\n' From 9bd0d9224fbee18f07f4a224a8d14af122c3ca23 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:23:25 -0500 Subject: [PATCH 017/131] Simplify `script/bootstrap`. We shouldn't need to delete `Brewfile.lock.json` because it doesn't actually lock anything; it just records versions that were installed. If we don't delete it, new `brew bundle install` run just adds info about what was installed during its run to the existing info about previous bundle installs. By not deleting, the code can be simplified as per this commit. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index e9427d826..395e9b037 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -19,13 +19,12 @@ function usage { exit 1 } -frozen='' - # Detect presence of `-f` frozen option +frozen= while getopts "f" opt; do case "${opt}" in f) - frozen='-f' + frozen='--no-lock --no-upgrade' ;; *) usage 1>&2 @@ -35,15 +34,8 @@ done printf $'==> 👢 Bootstrapping (%s)\n' "$(script/version)" -# Install Homebrew tools -if [[ "${frozen}" == "-f" ]]; then - # --no-lock Don't touch Brewfile.lock.json - brew bundle install --no-lock --no-upgrade --verbose -else - # Allow upgrades - rm -f Brewfile.lock.json - brew bundle install --verbose -fi +# shellcheck disable=SC2086 +brew bundle install ${frozen} --verbose mise settings set experimental true mise install --verbose From 378f90db0e2d75f7b858a3ebcc9bb300deef5df4 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:30:33 -0500 Subject: [PATCH 018/131] Install tools via Homebrew instead of via mise. Remove mise. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .mise.toml | 11 ------ Brewfile | 3 +- Brewfile.lock.json | 94 ++++++++++++++++++++++++++-------------------- script/bootstrap | 4 -- 4 files changed, 56 insertions(+), 56 deletions(-) delete mode 100644 .mise.toml diff --git a/.mise.toml b/.mise.toml deleted file mode 100644 index c0c7b45af..000000000 --- a/.mise.toml +++ /dev/null @@ -1,11 +0,0 @@ -# -# .mise.toml -# https://mise.jdx.dev/configuration.html -# - -[tools] -act = "0.2.60" -"npm:prettier" = "3.2.5" - -[settings] -experimental = true diff --git a/Brewfile b/Brewfile index f39a5c1ab..b1276705d 100644 --- a/Brewfile +++ b/Brewfile @@ -1,5 +1,6 @@ +brew "act" brew "markdownlint-cli" -brew "mise" +brew "prettier" brew "sd" brew "shellcheck" brew "shfmt" diff --git a/Brewfile.lock.json b/Brewfile.lock.json index 2f0d39161..a4de42f91 100644 --- a/Brewfile.lock.json +++ b/Brewfile.lock.json @@ -40,45 +40,6 @@ } } }, - "mise": { - "version": "2024.10.11", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:3d1ce9664736b5039466ceeb8286f87150a220d76cf62e5c5538ed4c42c01ff0", - "sha256": "3d1ce9664736b5039466ceeb8286f87150a220d76cf62e5c5538ed4c42c01ff0" - }, - "arm64_sonoma": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:d28afbc2017aa2d5904da9ca14e1fc9d01d341bfd0adc5168ace961e326b5b1c", - "sha256": "d28afbc2017aa2d5904da9ca14e1fc9d01d341bfd0adc5168ace961e326b5b1c" - }, - "arm64_ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:c4005d63d073861cef944841aa88925b1b929bc150d94bebe65322a4c7a6886f", - "sha256": "c4005d63d073861cef944841aa88925b1b929bc150d94bebe65322a4c7a6886f" - }, - "sonoma": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:d392eae34949295556f9c3598ce97bf44f5392b996b02ea31956169332a41f1c", - "sha256": "d392eae34949295556f9c3598ce97bf44f5392b996b02ea31956169332a41f1c" - }, - "ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:fd1afe999715d971c78f4bfa90b74fae7b7f8688477b07ea89c67ee36ea8463a", - "sha256": "fd1afe999715d971c78f4bfa90b74fae7b7f8688477b07ea89c67ee36ea8463a" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:22601cf4faf8764cf29d6cea72ef0e0789b10da581d899a229aace4e0069b2c4", - "sha256": "22601cf4faf8764cf29d6cea72ef0e0789b10da581d899a229aace4e0069b2c4" - } - } - } - }, "sd": { "version": "1.0.0", "bottle": { @@ -401,13 +362,66 @@ } } } + }, + "act": { + "version": "0.2.69", + "bottle": { + "rebuild": 0, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "arm64_sequoia": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:b506a62f7a79cb1274f1b4e2ac063e99e8b21c48303f037a8d072fa7e72d51f1", + "sha256": "b506a62f7a79cb1274f1b4e2ac063e99e8b21c48303f037a8d072fa7e72d51f1" + }, + "arm64_sonoma": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:fc7f50bc0659b145e63576379ec94f799d4a18b05442126828cb78a4579e44d0", + "sha256": "fc7f50bc0659b145e63576379ec94f799d4a18b05442126828cb78a4579e44d0" + }, + "arm64_ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:b55f6f6d877ca04e0e8416d0659655f4b5949d43f054799760d36c985331fc9c", + "sha256": "b55f6f6d877ca04e0e8416d0659655f4b5949d43f054799760d36c985331fc9c" + }, + "sonoma": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:04027bfea83f4a73d50c788cc5cdecf8a06866fc7e208a89d9c0b1271e6b0f58", + "sha256": "04027bfea83f4a73d50c788cc5cdecf8a06866fc7e208a89d9c0b1271e6b0f58" + }, + "ventura": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:ca92a0306d5f17988f137e0711b1fffc1a4aa7038f2bbe96b50ec52ed788f846", + "sha256": "ca92a0306d5f17988f137e0711b1fffc1a4aa7038f2bbe96b50ec52ed788f846" + }, + "x86_64_linux": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:30819c65f4c708e7cf5443017a5c16e27ffdccef8f2e1177b01886cdde982a4c", + "sha256": "30819c65f4c708e7cf5443017a5c16e27ffdccef8f2e1177b01886cdde982a4c" + } + } + } + }, + "prettier": { + "version": "3.3.3", + "bottle": { + "rebuild": 2, + "root_url": "https://ghcr.io/v2/homebrew/core", + "files": { + "all": { + "cellar": ":any_skip_relocation", + "url": "https://ghcr.io/v2/homebrew/core/prettier/blobs/sha256:34c3eb047777201bc1fd28e71876301232bdecf8ee36d35787e621a412244be3", + "sha256": "34c3eb047777201bc1fd28e71876301232bdecf8ee36d35787e621a412244be3" + } + } + } } } }, "system": { "macos": { "monterey": { - "HOMEBREW_VERSION": "4.4.2-62-g59d56f8", + "HOMEBREW_VERSION": "4.4.5-42-g640d52c", "HOMEBREW_PREFIX": "/usr/local", "Homebrew/homebrew-core": "api", "CLT": "14.2.0.0.1.1668646533", diff --git a/script/bootstrap b/script/bootstrap index 395e9b037..7fb45b946 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -36,7 +36,3 @@ printf $'==> 👢 Bootstrapping (%s)\n' "$(script/version)" # shellcheck disable=SC2086 brew bundle install ${frozen} --verbose - -mise settings set experimental true -mise install --verbose -mise list --verbose From 696d1a398adf3f3412fb19cae4fd3d6c48cbdf05 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:35:22 -0500 Subject: [PATCH 019/131] Fix typo. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .yamllint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamllint.yml b/.yamllint.yml index bf64f88ce..d91890d7f 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -13,5 +13,5 @@ rules: truthy: allowed-values: ["true", "false"] check-keys: false - # Disables fallse positives on GHA workflow `on:` + # Disables false positives on GHA workflow `on:` level: warning From 9a0ee97cfd4a51040f363ed1784b67c774bea39b Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:50:35 -0500 Subject: [PATCH 020/131] If a bottle & its checksum are the same for multiple versions of the same OS, then a checksum is required only for the oldest OS version that shares that bottle/checksum; all later versions of the OS will use that checksum. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Homebrew/mas-tap.rb | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Homebrew/mas-tap.rb b/Homebrew/mas-tap.rb index d477cd7da..4d52cf06a 100644 --- a/Homebrew/mas-tap.rb +++ b/Homebrew/mas-tap.rb @@ -13,19 +13,7 @@ class Mas < Formula bottle do root_url "https://github.com/mas-cli/mas/releases/download/v1.8.7-beta.1" - sha256 cellar: :any_skip_relocation, arm64_sonoma: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, arm64_ventura: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, arm64_monterey: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, arm64_big_sur: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, sonoma: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, ventura: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, monterey: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, big_sur: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, catalina: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, mojave: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, high_sierra: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, sierra: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - sha256 cellar: :any_skip_relocation, el_capitan: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" + sha256 cellar: :any_skip_relocation, el_capitan: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" end depends_on xcode: ["14.2", :build] From eca95102e785e08ef5fb3b444fabdb9d7ad26a66 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:18:44 -0500 Subject: [PATCH 021/131] Update Homebrew formula URL. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/brew_core_update | 2 +- script/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/brew_core_update b/script/brew_core_update index f4325de2b..fa0524d7b 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -4,7 +4,7 @@ # mas # # Updates mas Homebrew core formula: -# https://github.com/Homebrew/homebrew-core/blob/master/Formula/mas.rb +# https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb # # brew bump-formula-pr --help # diff --git a/script/install b/script/install index c771518e5..222002a33 100755 --- a/script/install +++ b/script/install @@ -7,7 +7,7 @@ # # NOTE: This script is called by the mas Homebrew formula so it has only system # dependencies aside from Swift. -# https://github.com/Homebrew/homebrew-core/blob/master/Formula/mas.rb +# https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb # ARCH=$(uname -m) From b971d4dbd4b42d1d478cd1253f74cc19e8937f10 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:27:12 -0500 Subject: [PATCH 022/131] Update script usage output. Fix acceptable argument count. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/brew_core_update | 2 +- script/brew_tap_update | 7 +++---- script/version_bump | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/script/brew_core_update b/script/brew_core_update index fa0524d7b..e84c93250 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -16,7 +16,7 @@ PROJECT_PATH="$(git rev-parse --show-toplevel)" LOCAL_MAS_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas.rb" function usage { - echo "Usage: brew_core_update [-d] v0.0 [sha1_hash]" + echo "Usage: brew_core_update [-d] [ []]" echo " -d option enables dry run mode" echo " version will be inferred using version script if not provided" echo " sha will be inferred from the current commit if not provided" diff --git a/script/brew_tap_update b/script/brew_tap_update index 6dd7a88e4..a6c0bffc1 100755 --- a/script/brew_tap_update +++ b/script/brew_tap_update @@ -8,15 +8,14 @@ # function usage { - echo "Usage: brew_tap_update [-d] v0.0 [sha1_hash]" - echo " -d option enables dry run mode" + echo "Usage: brew_tap_update [ []]" echo " version will be inferred using version script if not provided" echo " sha will be inferred from the current commit if not provided" exit 1 } -# Max 3 arguments -if [[ $# -gt 3 ]]; then +# Max 2 arguments +if [[ $# -gt 2 ]]; then usage 1>&2 fi diff --git a/script/version_bump b/script/version_bump index 10b22aadc..58df1bf0e 100755 --- a/script/version_bump +++ b/script/version_bump @@ -18,9 +18,9 @@ LOCAL_TAP_FORMULA_PATH="Homebrew/mas-tap.rb" SWIFT_PACKAGE="Sources/mas/Package.swift" function usage { - echo "Usage: version_bump v0.0 [sha1_hash]" - echo "- existing tag name" - echo "- sha will be inferred from the given tag if not provided" + echo "Usage: version_bump []" + echo " existing tag name" + echo " sha will be inferred from the given tag if not provided" exit 1 } From 615be3b8e1a18fc59c99413978ee309a881e5761 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 21:41:56 -0500 Subject: [PATCH 023/131] Use short/abbreviated options for consistency. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bottle | 4 ++-- script/brew_core_update | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/script/bottle b/script/bottle index 96bc48c39..54c43242f 100755 --- a/script/bottle +++ b/script/bottle @@ -16,7 +16,7 @@ BUILD_DIR="${PWD}/.build" BOTTLE_DIR="${BUILD_DIR}/bottles" -CORE_TAP_PATH="$(brew --repository homebrew/core)" +CORE_TAP_PATH="$(brew --repo homebrew/core)" MAS_VERSION=$(script/version) ROOT_URL="https://github.com/mas-cli/mas/releases/download/v${MAS_VERSION}" @@ -121,7 +121,7 @@ if ! test -e "${OLD_FILENAME}"; then exit 1 fi -SHA256=$(shasum --algorithm 256 "${OLD_FILENAME}" | cut -f 1 -d ' ' -) +SHA256=$(shasum -a 256 "${OLD_FILENAME}" | cut -f 1 -d ' ' -) mkdir -p "${BOTTLE_DIR}" diff --git a/script/brew_core_update b/script/brew_core_update index e84c93250..d2e5797b0 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -9,7 +9,7 @@ # brew bump-formula-pr --help # -CORE_TAP_PATH="$(brew --repository homebrew/core)" +CORE_TAP_PATH="$(brew --repo homebrew/core)" CORE_MAS_FORMULA_FILE="${CORE_TAP_PATH}/Formula/m/mas.rb" PROJECT_PATH="$(git rev-parse --show-toplevel)" From 3205a6d2f45cf140aed9f999644ff732513ae0cf Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 21:46:11 -0500 Subject: [PATCH 024/131] Fix bash subcommand completion. Use double quotes around bash & fish substitutions. Use braces around bash variable uses. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 16 ++++++++-------- contrib/completion/mas-completion.bash | 16 ++++++++++++++-- contrib/completion/mas.fish | 4 ++-- script/bottle | 20 ++++++++++---------- script/brew_core_update | 16 ++++++++-------- script/brew_tap_update | 4 ++-- script/build_artifacts | 4 ++-- script/format | 2 +- script/install | 18 +++++++++--------- script/lint | 2 +- script/package | 26 +++++++++++++------------- script/package_install | 4 ++-- script/uninstall | 10 +++++----- script/update_headers | 6 +++--- script/version | 2 +- script/version_bump | 6 +++--- 16 files changed, 84 insertions(+), 72 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfdea0012..0aec58fc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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}" diff --git a/contrib/completion/mas-completion.bash b/contrib/completion/mas-completion.bash index 31d9a0934..c383d9ca0 100644 --- a/contrib/completion/mas-completion.bash +++ b/contrib/completion/mas-completion.bash @@ -8,8 +8,20 @@ _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 + local -r ifs_old="${IFS}" + IFS=$'\n' + local -a mas_help=($(mas help)) + mas_help=("${mas_help[@]:5:${#mas_help[@]}-6}") + mas_help=("${mas_help[@]# }") + local -a commands=(help) + for line in "${mas_help[@]}"; do + if [[ ! "${line}" =~ ^\ ]]; then + commands+=("${line%% *}") + fi + done + COMPREPLY=($(compgen -W "${commands[*]}" -- "${cur}")) + IFS="${ifs_old}" return 0 fi } diff --git a/contrib/completion/mas.fish b/contrib/completion/mas.fish index 05101e571..be4278a93 100644 --- a/contrib/completion/mas.fish +++ b/contrib/completion/mas.fish @@ -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) + if set results (command mas search "$query" 2>/dev/null) for res in $results - echo $res + echo "$res" end | string trim --left | string replace -r '\s+' '\t' end end diff --git a/script/bottle b/script/bottle index 54c43242f..5bf7ac452 100755 --- a/script/bottle +++ b/script/bottle @@ -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}" diff --git a/script/brew_core_update b/script/brew_core_update index d2e5797b0..a9a16843a 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -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 diff --git a/script/brew_tap_update b/script/brew_tap_update index a6c0bffc1..98a155949 100755 --- a/script/brew_tap_update +++ b/script/brew_tap_update @@ -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}" diff --git a/script/build_artifacts b/script/build_artifacts index 6414d1609..a89c9acb4 100755 --- a/script/build_artifacts +++ b/script/build_artifacts @@ -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 diff --git a/script/format b/script/format index b942cb26e..7d82f4cdd 100755 --- a/script/format +++ b/script/format @@ -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 diff --git a/script/install b/script/install index 222002a33..fff643878 100755 --- a/script/install +++ b/script/install @@ -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" diff --git a/script/lint b/script/lint index f2421e8f3..39bff52ce 100755 --- a/script/lint +++ b/script/lint @@ -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 diff --git a/script/package b/script/package index 30df8f8c9..20fae4273 100755 --- a/script/package +++ b/script/package @@ -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}" diff --git a/script/package_install b/script/package_install index 3419135c9..5d05a7b47 100755 --- a/script/package_install +++ b/script/package_install @@ -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}" diff --git a/script/uninstall b/script/uninstall index e672d2832..a03566d33 100755 --- a/script/uninstall +++ b/script/uninstall @@ -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 diff --git a/script/update_headers b/script/update_headers index 0fabab6ac..f42c10274 100755 --- a/script/update_headers +++ b/script/update_headers @@ -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 diff --git a/script/version b/script/version index 73b1464cb..d6af92d63 100755 --- a/script/version +++ b/script/version @@ -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}" diff --git a/script/version_bump b/script/version_bump index 58df1bf0e..4b42292cb 100755 --- a/script/version_bump +++ b/script/version_bump @@ -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}" From 06e0f401b6a4bee009706b1193be315a8a4fef0a Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:11:51 -0500 Subject: [PATCH 025/131] Simplify defaults for unsupplied script arguments. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/brew_core_update | 14 +++----------- script/brew_tap_update | 14 +++----------- script/uninstall | 6 +----- script/version_bump | 7 ++----- 4 files changed, 9 insertions(+), 32 deletions(-) diff --git a/script/brew_core_update b/script/brew_core_update index a9a16843a..33df90dd4 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -50,21 +50,13 @@ if [[ "${DRY_RUN}" == 'true' ]]; then fi # arg 1 - version tag -if [[ -n "${1}" ]]; then - MAS_VERSION="${1}" -else - MAS_VERSION="v$(script/version)" -fi +MAS_VERSION="${1:-"v$(script/version)"}" echo "MAS_VERSION: ${MAS_VERSION}" # arg 2 - revision (commit hash) -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}")" -fi +# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag +REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}" echo "REVISION: ${REVISION}" diff --git a/script/brew_tap_update b/script/brew_tap_update index 98a155949..edfe45a1e 100755 --- a/script/brew_tap_update +++ b/script/brew_tap_update @@ -20,21 +20,13 @@ if [[ "${#}" -gt 2 ]]; then fi # arg 1 - version tag -if [[ -n "${1}" ]]; then - MAS_VERSION="${1}" -else - MAS_VERSION="v$(script/version)" -fi +MAS_VERSION="${1:-"v$(script/version)"}" echo "MAS_VERSION: ${MAS_VERSION}" # arg 2 - revision (commit hash) -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}")" -fi +# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag +REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}" echo "REVISION: ${REVISION}" diff --git a/script/uninstall b/script/uninstall index a03566d33..12ff608b3 100755 --- a/script/uninstall +++ b/script/uninstall @@ -7,11 +7,7 @@ # # Override default prefix path with optional 1st arg -if test -n "${1}"; then - PREFIX="${1}" -else - PREFIX="$(brew --prefix)" -fi +PREFIX="${1:-"$(brew --prefix)"}" echo "==> 🔥 Uninstalling mas from ${PREFIX}" diff --git a/script/version_bump b/script/version_bump index 4b42292cb..ee7b016c1 100755 --- a/script/version_bump +++ b/script/version_bump @@ -32,11 +32,8 @@ fi MAS_VERSION="${1}" # arg 2 - revision (commit hash) -if [[ "${#}" -ge 2 ]]; then - REVISION="${2}" -else - REVISION="$(git rev-parse "${MAS_VERSION}")" -fi +# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag +REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}" echo "MAS_VERSION: ${MAS_VERSION}" echo "REVISION: ${REVISION}" From fc753f69b2ae82627cb20d6604a613518f999f37 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:15:05 -0500 Subject: [PATCH 026/131] Replace bash `test` with `[[ ]]`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bottle | 2 +- script/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/bottle b/script/bottle index 5bf7ac452..914645052 100755 --- a/script/bottle +++ b/script/bottle @@ -114,7 +114,7 @@ brew install --build-bottle mas-cli/tap/mas # Generate bottle do block, dropping last 2 lines brew bottle --verbose --no-rebuild --root-url="${ROOT_URL}" mas-cli/tap/mas -if ! test -e "${OLD_FILENAME}"; then +if [[ ! -e "${OLD_FILENAME}" ]]; then echo "Bottle not found: ${OLD_FILENAME}" echo "If an old version is showing in the log and filename, then make sure the formula has been updated in:" echo "${CORE_TAP_PATH}" diff --git a/script/install b/script/install index fff643878..b653875be 100755 --- a/script/install +++ b/script/install @@ -15,7 +15,7 @@ RELEASE=".build/${ARCH}-apple-macosx/release" MAS_VERSION="$(script/version)" PREFIX=/usr/local -while test -n "${1}"; do +while [[ -n "${1}" ]]; do if [[ "${1}" == '--universal' ]]; then ARCH=universal RELEASE=.build/release From 542356936db28ee0181f30ce4dc3d42250462e63 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:21:37 -0500 Subject: [PATCH 027/131] `cd` into root of mas project at beginning of every bash script. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bottle | 9 ++++++++- script/brew_build_interactive | 7 +++++++ script/brew_core_update | 10 ++++++++-- script/brew_release_validate | 7 +++++++ script/brew_tap_update | 7 +++++++ script/build_artifacts | 7 +++++++ script/clean | 7 +++++++ script/install | 7 +++++++ script/package | 11 +++++++++-- script/package_install | 7 +++++++ script/uninstall | 7 +++++++ script/update_headers | 7 +++++++ 12 files changed, 88 insertions(+), 5 deletions(-) diff --git a/script/bottle b/script/bottle index 914645052..17cdf141b 100755 --- a/script/bottle +++ b/script/bottle @@ -14,7 +14,14 @@ # Variables # -BUILD_DIR="${PWD}/.build" +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + +BUILD_DIR=.build BOTTLE_DIR="${BUILD_DIR}/bottles" CORE_TAP_PATH="$(brew --repo homebrew/core)" MAS_VERSION="$(script/version)" diff --git a/script/brew_build_interactive b/script/brew_build_interactive index 654bb4911..d93a039ba 100755 --- a/script/brew_build_interactive +++ b/script/brew_build_interactive @@ -6,6 +6,13 @@ # https://docs.brew.sh/Formula-Cookbook#check-the-build-system # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + HOMEBREW_NO_INSTALL_FROM_API=1 \ brew reinstall \ --interactive mas diff --git a/script/brew_core_update b/script/brew_core_update index 33df90dd4..b44f2a7ad 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -9,11 +9,17 @@ # brew bump-formula-pr --help # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + CORE_TAP_PATH="$(brew --repo homebrew/core)" CORE_MAS_FORMULA_FILE="${CORE_TAP_PATH}/Formula/m/mas.rb" -PROJECT_PATH="$(git rev-parse --show-toplevel)" -LOCAL_MAS_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas.rb" +LOCAL_MAS_FORMULA_PATH=Homebrew/mas.rb function usage { echo "Usage: brew_core_update [-d] [ []]" diff --git a/script/brew_release_validate b/script/brew_release_validate index bc4f76709..abb51e101 100755 --- a/script/brew_release_validate +++ b/script/brew_release_validate @@ -7,6 +7,13 @@ # https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md#to-contribute-a-fix-to-the-foo-formula # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + brew uninstall --force mas brew install --build-from-source mas brew test mas diff --git a/script/brew_tap_update b/script/brew_tap_update index edfe45a1e..7447ea8ba 100755 --- a/script/brew_tap_update +++ b/script/brew_tap_update @@ -7,6 +7,13 @@ # https://github.com/mas-cli/homebrew-tap/blob/main/Formula/mas.rb # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + function usage { echo "Usage: brew_tap_update [ []]" echo " version will be inferred using version script if not provided" diff --git a/script/build_artifacts b/script/build_artifacts index a89c9acb4..a8ee44aaf 100755 --- a/script/build_artifacts +++ b/script/build_artifacts @@ -6,6 +6,13 @@ # Runs all related scripts for generating all artifacts. # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + MAS_VERSION="$(script/version)" echo "Building mas ${MAS_VERSION} artifacts" diff --git a/script/clean b/script/clean index ded54c5be..d08285bdb 100755 --- a/script/clean +++ b/script/clean @@ -6,5 +6,12 @@ # Deletes the build directory. # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + swift package clean swift package reset diff --git a/script/install b/script/install index b653875be..cb992be54 100755 --- a/script/install +++ b/script/install @@ -10,6 +10,13 @@ # https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + ARCH="$(uname -m)" RELEASE=".build/${ARCH}-apple-macosx/release" MAS_VERSION="$(script/version)" diff --git a/script/package b/script/package index 20fae4273..1e049a379 100755 --- a/script/package +++ b/script/package @@ -6,7 +6,14 @@ # Builds macOS installer component and distribution packages. # -BUILD_DIR="${PWD}/.build" +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + +BUILD_DIR=.build COMPONENT_PACKAGE="${BUILD_DIR}/mas_components.pkg" DISTRIBUTION_PACKAGE="${BUILD_DIR}/mas.pkg" @@ -17,7 +24,7 @@ IDENTIFIER="com.mphys.mas-cli" DISTRIBUTION_PLIST="Package/Distribution.plist" # Destination for install root -DSTROOT=.build/distributions +DSTROOT="${BUILD_DIR}/distributions" script/install "${DSTROOT}/usr/local" --universal MAS_VERSION="$(script/version)" diff --git a/script/package_install b/script/package_install index 5d05a7b47..67f6cc3f2 100755 --- a/script/package_install +++ b/script/package_install @@ -6,6 +6,13 @@ # Installs the mas distribution package. Requires sudo access. # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + IDENTIFIER=com.mphys.mas-cli echo "==> 📲 Installing mas" diff --git a/script/uninstall b/script/uninstall index 12ff608b3..e5b163e89 100755 --- a/script/uninstall +++ b/script/uninstall @@ -6,6 +6,13 @@ # Removes mas from PREFIX. # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + # Override default prefix path with optional 1st arg PREFIX="${1:-"$(brew --prefix)"}" diff --git a/script/update_headers b/script/update_headers index f42c10274..b44c2556c 100755 --- a/script/update_headers +++ b/script/update_headers @@ -6,6 +6,13 @@ # Runs class-dump to generate headers for Apple private frameworks. # +mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi + main() { check_class_dump extract_private_framework_headers "CommerceKit" From 2ebda42f2bc9d7c24c0ad70b2ac170c688ab46cb Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:35:25 -0500 Subject: [PATCH 028/131] Ensure single newline at end of every file. Ensure no newlines at beginning of any file. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Sources/PrivateFrameworks/CommerceKit/CKServiceInterface.h | 1 - Sources/PrivateFrameworks/StoreFoundation/SSDownload.h | 1 - Tests/masTests/JSON/lookup/fantastical.json | 2 +- Tests/masTests/JSON/lookup/notability.json | 2 +- Tests/masTests/JSON/lookup/things.json | 2 +- Tests/masTests/JSON/search/nonexistent.json | 5 ----- 6 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Sources/PrivateFrameworks/CommerceKit/CKServiceInterface.h b/Sources/PrivateFrameworks/CommerceKit/CKServiceInterface.h index 14a263943..7792c287e 100644 --- a/Sources/PrivateFrameworks/CommerceKit/CKServiceInterface.h +++ b/Sources/PrivateFrameworks/CommerceKit/CKServiceInterface.h @@ -11,4 +11,3 @@ } @end - diff --git a/Sources/PrivateFrameworks/StoreFoundation/SSDownload.h b/Sources/PrivateFrameworks/StoreFoundation/SSDownload.h index 827d425d5..f5519c389 100644 --- a/Sources/PrivateFrameworks/StoreFoundation/SSDownload.h +++ b/Sources/PrivateFrameworks/StoreFoundation/SSDownload.h @@ -62,4 +62,3 @@ - (void)cancel; @end - diff --git a/Tests/masTests/JSON/lookup/fantastical.json b/Tests/masTests/JSON/lookup/fantastical.json index e36d8c912..64478878b 100644 --- a/Tests/masTests/JSON/lookup/fantastical.json +++ b/Tests/masTests/JSON/lookup/fantastical.json @@ -61,4 +61,4 @@ "userRatingCount": 1342 } ] -} \ No newline at end of file +} diff --git a/Tests/masTests/JSON/lookup/notability.json b/Tests/masTests/JSON/lookup/notability.json index 9aa1c90ee..fab3501c8 100644 --- a/Tests/masTests/JSON/lookup/notability.json +++ b/Tests/masTests/JSON/lookup/notability.json @@ -69,4 +69,4 @@ "userRatingCount": 1840 } ] -} \ No newline at end of file +} diff --git a/Tests/masTests/JSON/lookup/things.json b/Tests/masTests/JSON/lookup/things.json index 64141dd27..b73839342 100644 --- a/Tests/masTests/JSON/lookup/things.json +++ b/Tests/masTests/JSON/lookup/things.json @@ -65,4 +65,4 @@ "userRatingCount": 1412 } ] -} \ No newline at end of file +} diff --git a/Tests/masTests/JSON/search/nonexistent.json b/Tests/masTests/JSON/search/nonexistent.json index 9a683b1cf..ed4da7187 100644 --- a/Tests/masTests/JSON/search/nonexistent.json +++ b/Tests/masTests/JSON/search/nonexistent.json @@ -1,9 +1,4 @@ - - - { "resultCount":0, "results": [] } - - From 3789cbdc092c8f7505d533e6cfdcd606c991423b Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 15 Nov 2024 23:57:37 -0500 Subject: [PATCH 029/131] Delete unnecessary bash comment. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/update_headers | 1 - 1 file changed, 1 deletion(-) diff --git a/script/update_headers b/script/update_headers index b44c2556c..1050704e6 100755 --- a/script/update_headers +++ b/script/update_headers @@ -20,7 +20,6 @@ main() { } check_class_dump() { - # command: usage: command [-pVv] command [arg ...] if ! command -v class-dump; then echo "class-dump is not installed." >&2 echo "Download from http://stevenygard.com/projects/class-dump/" >&2 From 4d05199fd2d59f8e0c7aaf82bcb82f303b42be65 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:12:21 -0500 Subject: [PATCH 030/131] =?UTF-8?q?Use=20bash=20`'=E2=80=A6'`,=20`$'?= =?UTF-8?q?=E2=80=A6'`,=20or=20unquoted=20word=20instead=20of=20`"?= =?UTF-8?q?=E2=80=A6"`=20whenever=20possible.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 24 ++++++++++++------------ script/bootstrap | 6 +++--- script/bottle | 8 ++++---- script/brew_core_update | 24 ++++++++++++------------ script/brew_tap_update | 6 +++--- script/package | 14 +++++++------- script/package_install | 2 +- script/update_headers | 8 ++++---- script/version_bump | 12 ++++++------ 9 files changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0aec58fc8..cd4fa2f5c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,19 +27,19 @@ jobs: # This step will only run for a real 'release' event. if: ${{ github.event.release.name != '' }} run: | - echo "Triggered by a release publication event (wet run)" - echo "release.name: ${{ github.event.release.name }}" - echo "release.tag_name: ${{ github.event.release.tag_name }}" - echo "release.target_commitish: ${{ github.event.release.target_commitish }}" - echo -e "release.body: \n${{ github.event.release.body }}" + echo 'Triggered by a release publication event (wet run)' + echo 'release.name: ${{ github.event.release.name }}' + echo 'release.tag_name: ${{ github.event.release.tag_name }}' + echo 'release.target_commitish: ${{ github.event.release.target_commitish }}' + echo $'release.body: \n${{ github.event.release.body }}' - id: dry_run run: | - echo "DRY_RUN=false" >>"$GITHUB_OUTPUT" + echo DRY_RUN=false >>"${GITHUB_OUTPUT}" - id: mas_version run: | - echo "MAS_VERSION=${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT" + echo 'MAS_VERSION=${{ github.event.release.tag_name }}' >>"${GITHUB_OUTPUT}" - id: pre_release run: | @@ -47,11 +47,11 @@ jobs: - id: release_branch run: | - echo "RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT" + echo 'RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}' >>"${GITHUB_OUTPUT}" - id: tap_path run: | - echo "TAP_PATH=\"$(brew --repo mas-cli/tap)\"" >>"$GITHUB_OUTPUT" + echo "TAP_PATH='$(brew --repo mas-cli/tap)'" >>"${GITHUB_OUTPUT}" prepare-release: runs-on: macos-15 @@ -90,9 +90,9 @@ jobs: RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }} run: | git add \ - "Homebrew/mas.rb" \ - "Homebrew/mas-tap.rb" \ - "Package.swift" + Homebrew/mas.rb \ + Homebrew/mas-tap.rb \ + Package.swift git commit \ --message="🔖 Version ${MAS_VERSION}" git push \ diff --git a/script/bootstrap b/script/bootstrap index 7fb45b946..6c57ce2a1 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -14,14 +14,14 @@ if ! cd -- "${mas_dir}"; then fi function usage { - echo "Usage: bootstrap [-f]" - echo " -f option enables frozen mode" + echo 'Usage: bootstrap [-f]' + echo ' -f option enables frozen mode' exit 1 } # Detect presence of `-f` frozen option frozen= -while getopts "f" opt; do +while getopts 'f' opt; do case "${opt}" in f) frozen='--no-lock --no-upgrade' diff --git a/script/bottle b/script/bottle index 17cdf141b..8b91584ad 100755 --- a/script/bottle +++ b/script/bottle @@ -47,7 +47,7 @@ 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')" +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]}" @@ -74,13 +74,13 @@ case "${CURRENT_OS_VERSION_MAJOR}" in CURRENT_PLATFORM=catalina ;; *) - echo "Unsupported macOS version. This script requires Catalina or newer." + echo 'Unsupported macOS version. This script requires Catalina or newer.' exit 1 ;; esac # Prefix platform with architecture -if [[ "arm64" == "$(uname -m)" ]]; then +if [[ 'arm64' == "$(uname -m)" ]]; then CURRENT_PLATFORM="arm64_${CURRENT_PLATFORM}" fi @@ -123,7 +123,7 @@ brew install --build-bottle mas-cli/tap/mas brew bottle --verbose --no-rebuild --root-url="${ROOT_URL}" mas-cli/tap/mas if [[ ! -e "${OLD_FILENAME}" ]]; then echo "Bottle not found: ${OLD_FILENAME}" - echo "If an old version is showing in the log and filename, then make sure the formula has been updated in:" + echo 'If an old version is showing in the log and filename, then make sure the formula has been updated in:' echo "${CORE_TAP_PATH}" exit 1 fi diff --git a/script/brew_core_update b/script/brew_core_update index b44f2a7ad..10b4275d1 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -22,10 +22,10 @@ CORE_MAS_FORMULA_FILE="${CORE_TAP_PATH}/Formula/m/mas.rb" LOCAL_MAS_FORMULA_PATH=Homebrew/mas.rb function usage { - echo "Usage: brew_core_update [-d] [ []]" - echo " -d option enables dry run mode" - echo " version will be inferred using version script if not provided" - echo " sha will be inferred from the current commit if not provided" + echo 'Usage: brew_core_update [-d] [ []]' + echo ' -d option enables dry run mode' + echo ' version will be inferred using version script if not provided' + echo ' sha will be inferred from the current commit if not provided' exit 1 } @@ -34,13 +34,13 @@ if [[ "${#}" -gt 3 ]]; then usage 1>&2 fi -dry_run='' +dry_run= # Detect presence of `-d` dry run option -while getopts "d" o; do +while getopts 'd' o; do case "${o}" in d) - dry_run='-d' + dry_run=-d ;; *) usage 1>&2 @@ -52,7 +52,7 @@ shift "$((OPTIND - 1))" # DRY_RUN environment variable # shellcheck disable=SC2153 if [[ "${DRY_RUN}" == 'true' ]]; then - dry_run='-d' + dry_run=-d fi # arg 1 - version tag @@ -120,12 +120,12 @@ popd # Update Homebrew # -# echo "Checking to see if this update can be a simple bump." +# echo 'Checking to see if this update can be a simple bump.' # diff "${LOCAL_MAS_FORMULA_PATH}" "${CORE_MAS_FORMULA_FILE}" echo "==> 🧪 Updating homebrew-core formula mas (${MAS_VERSION}, ${REVISION})" -echo "Validating formula" +echo 'Validating formula' brew bump-formula-pr \ --tag="${MAS_VERSION}" \ --revision="${REVISION}" \ @@ -139,7 +139,7 @@ brew bump-formula-pr \ # brew exit status status="${?}" if [[ "${status}" -ne 0 ]]; then - echo "Formula did not validate using 'brew bump-formula-pr'" 1>&2 + echo $'Formula did not validate using \'brew bump-formula-pr\'' 1>&2 exit "${status}" fi @@ -147,7 +147,7 @@ if [[ "${dry_run}" == '-d' ]]; then exit 0 fi -echo "Updating homebrew/core formula with a PR" +echo 'Updating homebrew/core formula with a PR' brew bump-formula-pr \ --tag="${MAS_VERSION}" \ diff --git a/script/brew_tap_update b/script/brew_tap_update index 7447ea8ba..e6c01c2cf 100755 --- a/script/brew_tap_update +++ b/script/brew_tap_update @@ -15,9 +15,9 @@ if ! cd -- "${mas_dir}"; then fi function usage { - echo "Usage: brew_tap_update [ []]" - echo " version will be inferred using version script if not provided" - echo " sha will be inferred from the current commit if not provided" + echo 'Usage: brew_tap_update [ []]' + echo ' version will be inferred using version script if not provided' + echo ' sha will be inferred from the current commit if not provided' exit 1 } diff --git a/script/package b/script/package index 1e049a379..324df3f66 100755 --- a/script/package +++ b/script/package @@ -17,11 +17,11 @@ BUILD_DIR=.build COMPONENT_PACKAGE="${BUILD_DIR}/mas_components.pkg" DISTRIBUTION_PACKAGE="${BUILD_DIR}/mas.pkg" -IDENTIFIER="com.mphys.mas-cli" +IDENTIFIER=com.mphys.mas-cli # Distribution package definition # https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html -DISTRIBUTION_PLIST="Package/Distribution.plist" +DISTRIBUTION_PLIST=Package/Distribution.plist # Destination for install root DSTROOT="${BUILD_DIR}/distributions" @@ -29,22 +29,22 @@ script/install "${DSTROOT}/usr/local" --universal MAS_VERSION="$(script/version)" -echo "==> 📦 Assemble an installer package" +echo '==> 📦 Assemble an installer package' -# Assemble macOS installer component package (aka "product archive"). +# Assemble macOS installer component package (aka 'product archive'). pkgbuild \ --identifier "${IDENTIFIER}" \ - --install-location "/" \ + --install-location '/' \ --version "${MAS_VERSION}" \ --root "${DSTROOT}" \ "${COMPONENT_PACKAGE}" -# Build distribution package (aka "product archive"). Not sure why, but this is how Carthage does it. +# 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}" -echo "==> 🔢 File Hash" +echo '==> 🔢 File Hash' shasum -a 256 "${DISTRIBUTION_PACKAGE}" diff --git a/script/package_install b/script/package_install index 67f6cc3f2..e68edce16 100755 --- a/script/package_install +++ b/script/package_install @@ -15,7 +15,7 @@ fi IDENTIFIER=com.mphys.mas-cli -echo "==> 📲 Installing mas" +echo '==> 📲 Installing mas' sudo installer \ -pkg .build/mas.pkg \ diff --git a/script/update_headers b/script/update_headers index 1050704e6..c99034e73 100755 --- a/script/update_headers +++ b/script/update_headers @@ -15,14 +15,14 @@ fi main() { check_class_dump - extract_private_framework_headers "CommerceKit" - extract_private_framework_headers "StoreFoundation" + extract_private_framework_headers CommerceKit + extract_private_framework_headers StoreFoundation } check_class_dump() { if ! command -v class-dump; then - echo "class-dump is not installed." >&2 - echo "Download from http://stevenygard.com/projects/class-dump/" >&2 + echo 'class-dump is not installed.' >&2 + echo 'Download from http://stevenygard.com/projects/class-dump/' >&2 exit 1 fi } diff --git a/script/version_bump b/script/version_bump index ee7b016c1..16e666a4c 100755 --- a/script/version_bump +++ b/script/version_bump @@ -13,14 +13,14 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -LOCAL_MAS_FORMULA_PATH="Homebrew/mas.rb" -LOCAL_TAP_FORMULA_PATH="Homebrew/mas-tap.rb" -SWIFT_PACKAGE="Sources/mas/Package.swift" +LOCAL_MAS_FORMULA_PATH=Homebrew/mas.rb +LOCAL_TAP_FORMULA_PATH=Homebrew/mas-tap.rb +SWIFT_PACKAGE=Sources/mas/Package.swift function usage { - echo "Usage: version_bump []" - echo " existing tag name" - echo " sha will be inferred from the given tag if not provided" + echo 'Usage: version_bump []' + echo ' existing tag name' + echo ' sha will be inferred from the given tag if not provided' exit 1 } From 8fa8ae949307f088b8ea4b54f725141648b8cac9 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:31:59 -0500 Subject: [PATCH 031/131] Move bash variable to left of test. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bottle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/bottle b/script/bottle index 8b91584ad..053bce03c 100755 --- a/script/bottle +++ b/script/bottle @@ -80,7 +80,7 @@ case "${CURRENT_OS_VERSION_MAJOR}" in esac # Prefix platform with architecture -if [[ 'arm64' == "$(uname -m)" ]]; then +if [[ "$(uname -m)" == 'arm64' ]]; then CURRENT_PLATFORM="arm64_${CURRENT_PLATFORM}" fi From b3dca79a9348bd4e531c635a3cbb844170d73bed Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:32:53 -0500 Subject: [PATCH 032/131] Inline bash variables. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bottle | 3 +-- script/brew_core_update | 8 +------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/script/bottle b/script/bottle index 053bce03c..d057673ca 100755 --- a/script/bottle +++ b/script/bottle @@ -147,8 +147,7 @@ EOF # Fix filename for os in "${OS_NAMES[@]}"; do - new_filename="mas-${MAS_VERSION}.${os}.bottle.tar.gz" - cp -v "${OLD_FILENAME}" "${BOTTLE_DIR}/${new_filename}" + cp -v "${OLD_FILENAME}" "${BOTTLE_DIR}/mas-${MAS_VERSION}.${os}.bottle.tar.gz" # Append each os # BOTTLE_BLOCK="$(printf "${BOTTLE_BLOCK}\n sha256 cellar: :any_skip_relocation, %-15s %s" "${os}:" "${SHA256}")" diff --git a/script/brew_core_update b/script/brew_core_update index 10b4275d1..63c730cb0 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -17,9 +17,6 @@ if ! cd -- "${mas_dir}"; then fi CORE_TAP_PATH="$(brew --repo homebrew/core)" -CORE_MAS_FORMULA_FILE="${CORE_TAP_PATH}/Formula/m/mas.rb" - -LOCAL_MAS_FORMULA_PATH=Homebrew/mas.rb function usage { echo 'Usage: brew_core_update [-d] [ []]' @@ -93,7 +90,7 @@ brew update # # Update mas formula in core (temporary) -cp -v "${LOCAL_MAS_FORMULA_PATH}" "${CORE_MAS_FORMULA_FILE}" +cp -v Homebrew/mas.rb "${CORE_TAP_PATH}/Formula/m/mas.rb" # Install mas from source # HOMEBREW_NO_INSTALL_FROM_API: @@ -120,9 +117,6 @@ popd # Update Homebrew # -# echo 'Checking to see if this update can be a simple bump.' -# diff "${LOCAL_MAS_FORMULA_PATH}" "${CORE_MAS_FORMULA_FILE}" - echo "==> 🧪 Updating homebrew-core formula mas (${MAS_VERSION}, ${REVISION})" echo 'Validating formula' From ce4205ee661156b75839f2cc7986b7f3c3ba4696 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:45:49 -0500 Subject: [PATCH 033/131] Write to stderr where appropriate. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 6 +++--- script/bottle | 8 ++++---- script/brew_core_update | 14 +++++++------- script/brew_tap_update | 8 ++++---- script/format | 2 +- script/lint | 2 +- script/version_bump | 6 +++--- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index 6c57ce2a1..a823c3a7a 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -14,8 +14,8 @@ if ! cd -- "${mas_dir}"; then fi function usage { - echo 'Usage: bootstrap [-f]' - echo ' -f option enables frozen mode' + echo 'Usage: bootstrap [-f]' >&2 + echo ' -f option enables frozen mode' >&2 exit 1 } @@ -27,7 +27,7 @@ while getopts 'f' opt; do frozen='--no-lock --no-upgrade' ;; *) - usage 1>&2 + usage ;; esac done diff --git a/script/bottle b/script/bottle index d057673ca..b52943bc2 100755 --- a/script/bottle +++ b/script/bottle @@ -74,7 +74,7 @@ case "${CURRENT_OS_VERSION_MAJOR}" in CURRENT_PLATFORM=catalina ;; *) - echo 'Unsupported macOS version. This script requires Catalina or newer.' + echo 'Unsupported macOS version. This script requires Catalina or newer.' >&2 exit 1 ;; esac @@ -122,9 +122,9 @@ brew install --build-bottle mas-cli/tap/mas # Generate bottle do block, dropping last 2 lines brew bottle --verbose --no-rebuild --root-url="${ROOT_URL}" mas-cli/tap/mas if [[ ! -e "${OLD_FILENAME}" ]]; then - echo "Bottle not found: ${OLD_FILENAME}" - echo 'If an old version is showing in the log and filename, then make sure the formula has been updated in:' - echo "${CORE_TAP_PATH}" + echo "Bottle not found: ${OLD_FILENAME}" >&2 + echo 'If an old version is showing in the log and filename, then make sure the formula has been updated in:' >&2 + echo "${CORE_TAP_PATH}" >&2 exit 1 fi diff --git a/script/brew_core_update b/script/brew_core_update index 63c730cb0..316b5f9d6 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -19,16 +19,16 @@ fi CORE_TAP_PATH="$(brew --repo homebrew/core)" function usage { - echo 'Usage: brew_core_update [-d] [ []]' - echo ' -d option enables dry run mode' - echo ' version will be inferred using version script if not provided' - echo ' sha will be inferred from the current commit if not provided' + echo 'Usage: brew_core_update [-d] [ []]' >&2 + echo ' -d option enables dry run mode' >&2 + echo ' version will be inferred using version script if not provided' >&2 + echo ' sha will be inferred from the current commit if not provided' >&2 exit 1 } # Max 3 arguments if [[ "${#}" -gt 3 ]]; then - usage 1>&2 + usage fi dry_run= @@ -40,7 +40,7 @@ while getopts 'd' o; do dry_run=-d ;; *) - usage 1>&2 + usage ;; esac done @@ -133,7 +133,7 @@ brew bump-formula-pr \ # brew exit status status="${?}" if [[ "${status}" -ne 0 ]]; then - echo $'Formula did not validate using \'brew bump-formula-pr\'' 1>&2 + echo $'Formula did not validate using \'brew bump-formula-pr\'' >&2 exit "${status}" fi diff --git a/script/brew_tap_update b/script/brew_tap_update index e6c01c2cf..d9f7139ee 100755 --- a/script/brew_tap_update +++ b/script/brew_tap_update @@ -15,15 +15,15 @@ if ! cd -- "${mas_dir}"; then fi function usage { - echo 'Usage: brew_tap_update [ []]' - echo ' version will be inferred using version script if not provided' - echo ' sha will be inferred from the current commit if not provided' + echo 'Usage: brew_tap_update [ []]' >&2 + echo ' version will be inferred using version script if not provided' >&2 + echo ' sha will be inferred from the current commit if not provided' >&2 exit 1 } # Max 2 arguments if [[ "${#}" -gt 2 ]]; then - usage 1>&2 + usage fi # arg 1 - version tag diff --git a/script/format b/script/format index 7d82f4cdd..d323255a8 100755 --- a/script/format +++ b/script/format @@ -21,7 +21,7 @@ printf $'==> 🚨 Formatting mas\n' for LINTER in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do if [[ ! -x "$(command -v "${LINTER}")" ]]; then - printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${LINTER}" "${LINTER}" + printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${LINTER}" "${LINTER}" >&2 exit 1 fi done diff --git a/script/lint b/script/lint index 39bff52ce..03dca6b84 100755 --- a/script/lint +++ b/script/lint @@ -23,7 +23,7 @@ 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 - printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}" + printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}" >&2 exit 1 fi done diff --git a/script/version_bump b/script/version_bump index 16e666a4c..f8a4e8452 100755 --- a/script/version_bump +++ b/script/version_bump @@ -18,9 +18,9 @@ LOCAL_TAP_FORMULA_PATH=Homebrew/mas-tap.rb SWIFT_PACKAGE=Sources/mas/Package.swift function usage { - echo 'Usage: version_bump []' - echo ' existing tag name' - echo ' sha will be inferred from the given tag if not provided' + echo 'Usage: version_bump []' >&2 + echo ' existing tag name' >&2 + echo ' sha will be inferred from the given tag if not provided' >&2 exit 1 } From b7a6948169776b6a25daf0ae5c85b1ae195e8fb8 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:56:52 -0500 Subject: [PATCH 034/131] Simplify `script/update_headers`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/update_headers | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/script/update_headers b/script/update_headers index c99034e73..dee624661 100755 --- a/script/update_headers +++ b/script/update_headers @@ -13,26 +13,18 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -main() { - check_class_dump - extract_private_framework_headers CommerceKit - extract_private_framework_headers StoreFoundation -} - -check_class_dump() { - if ! command -v class-dump; then - echo 'class-dump is not installed.' >&2 - echo 'Download from http://stevenygard.com/projects/class-dump/' >&2 - exit 1 - fi -} +if ! command -v class-dump; then + echo 'class-dump is not installed.' >&2 + echo 'Download from http://stevenygard.com/projects/class-dump/' >&2 + exit 1 +fi extract_private_framework_headers() { local framework_name="${1}" - shift local directory="Sources/PrivateFrameworks/${framework_name}" mkdir -p "${directory}" class-dump -Ho "${directory}" "/System/Library/PrivateFrameworks/${framework_name}.framework" } -main +extract_private_framework_headers CommerceKit +extract_private_framework_headers StoreFoundation From 12d0fe9c5c45e119077a992802ca185546526360 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 00:59:43 -0500 Subject: [PATCH 035/131] Suppress output for `class-dump` executable check. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/update_headers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/update_headers b/script/update_headers index dee624661..d0f2d018a 100755 --- a/script/update_headers +++ b/script/update_headers @@ -13,7 +13,7 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -if ! command -v class-dump; then +if ! command -v class-dump >/dev/null; then echo 'class-dump is not installed.' >&2 echo 'Download from http://stevenygard.com/projects/class-dump/' >&2 exit 1 From 019c9b9580ff56ba68b090e87b98d1ddb22b56dd Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 01:49:12 -0500 Subject: [PATCH 036/131] Rename `OLD_FILENAME` as `generated_bottle_filename`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bottle | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/script/bottle b/script/bottle index b52943bc2..0098d05e2 100755 --- a/script/bottle +++ b/script/bottle @@ -86,9 +86,6 @@ fi echo "CURRENT_PLATFORM: ${CURRENT_PLATFORM}" -# Output filename from build-bottle command -OLD_FILENAME="mas--${MAS_VERSION}.${CURRENT_PLATFORM}.bottle.tar.gz" - ################################################################################ # # Preflight checks @@ -121,14 +118,18 @@ brew install --build-bottle mas-cli/tap/mas # Generate bottle do block, dropping last 2 lines brew bottle --verbose --no-rebuild --root-url="${ROOT_URL}" mas-cli/tap/mas -if [[ ! -e "${OLD_FILENAME}" ]]; then - echo "Bottle not found: ${OLD_FILENAME}" >&2 + +# Output filename from brew bottle +generated_bottle_filename="mas--${MAS_VERSION}.${CURRENT_PLATFORM}.bottle.tar.gz" + +if [[ ! -e "${generated_bottle_filename}" ]]; then + echo "Bottle not found: ${generated_bottle_filename}" >&2 echo 'If an old version is showing in the log and filename, then make sure the formula has been updated in:' >&2 echo "${CORE_TAP_PATH}" >&2 exit 1 fi -SHA256="$(shasum -a 256 "${OLD_FILENAME}" | cut -f 1 -d ' ' -)" +SHA256="$(shasum -a 256 "${generated_bottle_filename}" | cut -f 1 -d ' ' -)" mkdir -p "${BOTTLE_DIR}" @@ -147,7 +148,7 @@ EOF # Fix filename for os in "${OS_NAMES[@]}"; do - cp -v "${OLD_FILENAME}" "${BOTTLE_DIR}/mas-${MAS_VERSION}.${os}.bottle.tar.gz" + cp -v "${generated_bottle_filename}" "${BOTTLE_DIR}/mas-${MAS_VERSION}.${os}.bottle.tar.gz" # Append each os # BOTTLE_BLOCK="$(printf "${BOTTLE_BLOCK}\n sha256 cellar: :any_skip_relocation, %-15s %s" "${os}:" "${SHA256}")" @@ -167,6 +168,6 @@ end EOF )" -rm "${OLD_FILENAME}" +rm "${generated_bottle_filename}" ls -l "${BOTTLE_DIR}" echo "${BOTTLE_BLOCK}" From 68bdbfe0b936b76837507f282b16169621342198 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 02:43:50 -0500 Subject: [PATCH 037/131] Only set bash variables once. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/build b/script/build index 1f327635b..345d7de4d 100755 --- a/script/build +++ b/script/build @@ -14,18 +14,20 @@ if ! cd -- "${mas_dir}"; then fi # Build for the host architecture by default. -ARCH=() if [[ "${#}" -ge 1 && "${1}" == '--universal' ]]; then ARCH=( --arch arm64 --arch x86_64 ) +else + ARCH=() fi # Disable the manifest cache. -CACHE=() if [[ "$(swift build --help)" =~ manifest-cache ]]; then CACHE=(--manifest-cache none) +else + CACHE=() fi echo "==> 🏗️ Building mas ($(script/version --write))" From 28266c473416363354c3cb2994eb270a4db2e6e2 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 05:16:39 -0500 Subject: [PATCH 038/131] Simplify `script/bottle`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bottle | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/script/bottle b/script/bottle index 0098d05e2..3760f1db6 100755 --- a/script/bottle +++ b/script/bottle @@ -21,8 +21,7 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -BUILD_DIR=.build -BOTTLE_DIR="${BUILD_DIR}/bottles" +BOTTLE_DIR=".build/bottles" CORE_TAP_PATH="$(brew --repo homebrew/core)" MAS_VERSION="$(script/version)" ROOT_URL="https://github.com/mas-cli/mas/releases/download/v${MAS_VERSION}" @@ -46,15 +45,8 @@ OS_NAMES=( el_capitan ) -# 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]}" - -echo "CURRENT_OS_VERSION_MAJOR: ${CURRENT_OS_VERSION_MAJOR}" -echo "CURRENT_OS_VERSION_MINOR: ${CURRENT_OS_VERSION_MINOR}" - -case "${CURRENT_OS_VERSION_MAJOR}" in +macos_version="$(sw_vers -productVersion)" +case "${macos_version%%.*}" in 15) CURRENT_PLATFORM=sequoia ;; From 3414328426017f704c4d7d94683ecf7ad8991aa3 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 05:29:13 -0500 Subject: [PATCH 039/131] Cleanup `.editorconfig`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .editorconfig | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1f913cdf8..43131279a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,38 +2,29 @@ root = true [*] -indent_style = space -indent_size = 4 -end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true +end_of_line = lf +indent_size = 4 +indent_style = space insert_final_newline = true +trim_trailing_whitespace = true -[script/*] -indent_size = 2 - -[*.{yml,yaml}] +[*.json] indent_size = 2 -# Use 2 spaces for Ruby files -[{Podfile,Rakefile,script/*,*.{podspec,rb,yml}}] -indent_size = 2 -indent_style = space -max_line_length = 80 +# Trailing spaces have meaning in Markdown +[*.md] +trim_trailing_whitespace = false -# Use tabs for property lists [*.plist] indent_style = tab -# JSON files contain newlines inconsistently -[*.json] +[*.yml] indent_size = 2 -insert_final_newline = ignore -# Makefiles always use tabs for indentation [Makefile] indent_style = tab -# Trailing spaces have meaning in Markdown -[*.md] -trim_trailing_whitespace = false +[script/*] +indent_size = 2 +max_line_length = 80 From c2f1bf8e8d93369a6b155550ed9b8948a884f8de Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 13:47:13 -0500 Subject: [PATCH 040/131] Simplify & standardize script output headers & mas version handling. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 2 +- script/bottle | 12 +++++------- script/build | 2 +- script/build_artifacts | 4 +--- script/install | 3 +-- script/lint | 2 +- script/package | 6 +++--- script/test | 2 +- script/version | 7 ++----- 9 files changed, 16 insertions(+), 24 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index a823c3a7a..fa10d29d6 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -32,7 +32,7 @@ while getopts 'f' opt; do esac done -printf $'==> 👢 Bootstrapping (%s)\n' "$(script/version)" +printf $'==> 👢 Bootstrapping mas %s\n' "$(script/version)" # shellcheck disable=SC2086 brew bundle install ${frozen} --verbose diff --git a/script/bottle b/script/bottle index 3760f1db6..695510ffb 100755 --- a/script/bottle +++ b/script/bottle @@ -23,8 +23,8 @@ fi BOTTLE_DIR=".build/bottles" CORE_TAP_PATH="$(brew --repo homebrew/core)" -MAS_VERSION="$(script/version)" -ROOT_URL="https://github.com/mas-cli/mas/releases/download/v${MAS_VERSION}" +version="$(script/version)" +ROOT_URL="https://github.com/mas-cli/mas/releases/download/v${version}" # Supports macOS 10.13 and later OS_NAMES=( @@ -76,8 +76,6 @@ if [[ "$(uname -m)" == 'arm64' ]]; then CURRENT_PLATFORM="arm64_${CURRENT_PLATFORM}" fi -echo "CURRENT_PLATFORM: ${CURRENT_PLATFORM}" - ################################################################################ # # Preflight checks @@ -105,14 +103,14 @@ brew style Homebrew/mas-tap.rb # Build the formula for the current macOS version and architecture. # -echo "==> 🍼 Bottling mas ${MAS_VERSION} for: ${OS_NAMES[*]}" +echo "==> 🍼 Bottling mas ${version} on ${CURRENT_PLATFORM} for ${OS_NAMES[*]}" brew install --build-bottle mas-cli/tap/mas # Generate bottle do block, dropping last 2 lines brew bottle --verbose --no-rebuild --root-url="${ROOT_URL}" mas-cli/tap/mas # Output filename from brew bottle -generated_bottle_filename="mas--${MAS_VERSION}.${CURRENT_PLATFORM}.bottle.tar.gz" +generated_bottle_filename="mas--${version}.${CURRENT_PLATFORM}.bottle.tar.gz" if [[ ! -e "${generated_bottle_filename}" ]]; then echo "Bottle not found: ${generated_bottle_filename}" >&2 @@ -140,7 +138,7 @@ EOF # Fix filename for os in "${OS_NAMES[@]}"; do - cp -v "${generated_bottle_filename}" "${BOTTLE_DIR}/mas-${MAS_VERSION}.${os}.bottle.tar.gz" + cp -v "${generated_bottle_filename}" "${BOTTLE_DIR}/mas-${version}.${os}.bottle.tar.gz" # Append each os # BOTTLE_BLOCK="$(printf "${BOTTLE_BLOCK}\n sha256 cellar: :any_skip_relocation, %-15s %s" "${os}:" "${SHA256}")" diff --git a/script/build b/script/build index 345d7de4d..b6ac981fb 100755 --- a/script/build +++ b/script/build @@ -30,7 +30,7 @@ else CACHE=() fi -echo "==> 🏗️ Building mas ($(script/version --write))" +echo "==> 🏗️ Building mas $(script/version --write)" swift build \ --configuration release \ "${ARCH[@]+"${ARCH[@]}"}" \ diff --git a/script/build_artifacts b/script/build_artifacts index a8ee44aaf..d81148b37 100755 --- a/script/build_artifacts +++ b/script/build_artifacts @@ -13,9 +13,7 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -MAS_VERSION="$(script/version)" - -echo "Building mas ${MAS_VERSION} artifacts" +echo "==> 👑 Building mas $(script/version) artifacts" script/clean script/build --universal diff --git a/script/install b/script/install index cb992be54..90a4978e0 100755 --- a/script/install +++ b/script/install @@ -19,7 +19,6 @@ fi ARCH="$(uname -m)" RELEASE=".build/${ARCH}-apple-macosx/release" -MAS_VERSION="$(script/version)" PREFIX=/usr/local while [[ -n "${1}" ]]; do @@ -34,7 +33,7 @@ while [[ -n "${1}" ]]; do shift done -echo "==> 📲 Installing mas (${MAS_VERSION}) for ${ARCH} to ${PREFIX}" +echo "==> 📲 Installing mas $(script/version) for ${ARCH} to ${PREFIX}" ditto -v \ "${RELEASE}/mas" \ "${PREFIX}/bin/mas" diff --git a/script/lint b/script/lint index 03dca6b84..844b80470 100755 --- a/script/lint +++ b/script/lint @@ -19,7 +19,7 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -printf $'==> 🚨 Linting mas (%s)\n' "$(script/version --write)" +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 diff --git a/script/package b/script/package index 324df3f66..0f40291e8 100755 --- a/script/package +++ b/script/package @@ -27,15 +27,15 @@ DISTRIBUTION_PLIST=Package/Distribution.plist DSTROOT="${BUILD_DIR}/distributions" script/install "${DSTROOT}/usr/local" --universal -MAS_VERSION="$(script/version)" +version="$(script/version)" -echo '==> 📦 Assemble an installer package' +echo "==> 📦 Assembling installer package for mas ${version}" # Assemble macOS installer component package (aka 'product archive'). pkgbuild \ --identifier "${IDENTIFIER}" \ --install-location '/' \ - --version "${MAS_VERSION}" \ + --version "${version}" \ --root "${DSTROOT}" \ "${COMPONENT_PACKAGE}" diff --git a/script/test b/script/test index 7c5f41cd9..02c5eecf3 100755 --- a/script/test +++ b/script/test @@ -13,6 +13,6 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -printf $'==> ✅ Testing mas (%s)\n' "$(script/version --write)" +printf $'==> ✅ Testing mas %s\n' "$(script/version --write)" swift test diff --git a/script/version b/script/version index d6af92d63..067c184a5 100755 --- a/script/version +++ b/script/version @@ -13,11 +13,8 @@ if ! cd -- "${mas_dir}"; then exit 1 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)" -fi -echo "${MAS_VERSION#v}" +version_tag="$(git describe --abbrev=0 --tags 2>/dev/null)" +printf $'%s\n' "${version_tag#v}" if [[ "${#}" -ge 1 && "${1}" == '--write' ]]; then # Write new version into swift package From 009ac1b9bdbc120eb9c6285c2842e3676783eb12 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 19:10:06 -0500 Subject: [PATCH 041/131] Rename `script/version_bump` as `script/generate_version_info_for_swift`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- script/{version_bump => generate_version_info_for_swift} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename script/{version_bump => generate_version_info_for_swift} (88%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd4fa2f5c..54b6d0db7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,7 +77,7 @@ jobs: env: MAS_VERSION: ${{ needs.start.outputs.mas_version }} run: | - script/version_bump "${MAS_VERSION}" + script/generate_version_info_for_swift "${MAS_VERSION}" - name: 🔧 Configure Git Author run: | diff --git a/script/version_bump b/script/generate_version_info_for_swift similarity index 88% rename from script/version_bump rename to script/generate_version_info_for_swift index f8a4e8452..fd3afc5a4 100755 --- a/script/version_bump +++ b/script/generate_version_info_for_swift @@ -1,6 +1,6 @@ #!/bin/bash -eu # -# script/version_bump +# script/generate_version_info_for_swift # mas # # Increments the marketing version of mas. @@ -18,7 +18,7 @@ LOCAL_TAP_FORMULA_PATH=Homebrew/mas-tap.rb SWIFT_PACKAGE=Sources/mas/Package.swift function usage { - echo 'Usage: version_bump []' >&2 + echo 'Usage: generate_version_info_for_swift []' >&2 echo ' existing tag name' >&2 echo ' sha will be inferred from the given tag if not provided' >&2 exit 1 @@ -40,7 +40,7 @@ echo "REVISION: ${REVISION}" # Write new version into swift package cat <"${SWIFT_PACKAGE}" -/// Generated by \`script/version_bump\`. +/// Generated by \`script/generate_version_info_for_swift\`. enum Package { static let version = "${MAS_VERSION#v}" } From 460718fe3ea5847cfb2773d845cd5f0326db7306 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 04:05:35 -0500 Subject: [PATCH 042/131] Unfinished: Only bump formulae; don't generate them or store them in git. Obtain version & revision from most recent version tag in the current branch, not from environment variable or argument. Do not branch or commit on release. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 103 ++++------------------- Brewfile | 1 - Brewfile.lock.json | 49 ----------- Homebrew/mas-tap.rb | 34 -------- Homebrew/mas.rb | 41 --------- script/bottle | 62 -------------- script/brew_core_update | 111 +++---------------------- script/brew_tap_update | 41 --------- script/build | 4 +- script/generate_version_info_for_swift | 44 +--------- script/lint | 4 +- script/test | 4 +- script/version | 12 +-- 13 files changed, 41 insertions(+), 469 deletions(-) delete mode 100644 Homebrew/mas-tap.rb delete mode 100644 Homebrew/mas.rb delete mode 100755 script/brew_tap_update diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 54b6d0db7..fa7cb0ffc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,6 @@ jobs: dry_run: ${{ steps.dry_run.outputs.dry_run }} mas_version: ${{ steps.mas_version.outputs.mas_version }} pre_release: ${{ steps.pre_release.outputs.pre_release }} - release_branch: ${{ steps.release_branch.outputs.release_branch }} tap_path: ${{ steps.tap_path.outputs.tap_path }} steps: # Logs event details and sets `DRY_RUN` env var @@ -45,68 +44,19 @@ jobs: run: | echo "PRE_RELEASE=$(grep -q '-' <<<"${MAS_VERSION}" && echo 'true' || echo 'false')" >>"${GITHUB_OUTPUT}" - - id: release_branch - run: | - echo 'RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}' >>"${GITHUB_OUTPUT}" - - id: tap_path run: | echo "TAP_PATH='$(brew --repo mas-cli/tap)'" >>"${GITHUB_OUTPUT}" - prepare-release: - runs-on: macos-15 - needs: [start] - steps: - - uses: actions/checkout@v4 - with: - # A fetch-depth of 0 includes all history and tags for script/version - fetch-depth: 0 - - - name: 👢 Bootstrap - run: | - script/bootstrap -f - - - name: 🔀 Create mas release branch - env: - RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }} - run: | - git branch "${RELEASE_BRANCH}" - git switch "${RELEASE_BRANCH}" - - - name: 🔖 Update version - env: - MAS_VERSION: ${{ needs.start.outputs.mas_version }} - run: | - script/generate_version_info_for_swift "${MAS_VERSION}" - - - name: 🔧 Configure Git Author - run: | - git config --global user.name 'masclibot' - git config --global user.email 'masclibot@users.noreply.github.com' - - - name: 💾 Commit changes - env: - MAS_VERSION: ${{ needs.start.outputs.mas_version }} - RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }} - run: | - git add \ - Homebrew/mas.rb \ - Homebrew/mas-tap.rb \ - Package.swift - git commit \ - --message="🔖 Version ${MAS_VERSION}" - git push \ - --set-upstream origin "${RELEASE_BRANCH}" - pkg-installer: runs-on: macos-15 - needs: [start, prepare-release] + needs: start steps: - uses: actions/checkout@v4 with: # A fetch-depth of 0 includes all history and tags for script/version fetch-depth: 0 - ref: ${{ needs.start.outputs.release_branch }} + ref: ${{ needs.start.outputs.mas_version }} - name: 👢 Bootstrap run: | @@ -126,22 +76,21 @@ jobs: env: GH_TOKEN: ${{ github.token }} DRY_RUN: ${{ needs.start.outputs.dry_run }} - MAS_VERSION: ${{ needs.start.outputs.mas_version }} if: ${{ needs.start.outputs.dry_run == 'false' }} run: | - gh release upload "${MAS_VERSION}" \ + gh release upload '${{ needs.start.outputs.mas_version }}' \ .build/mas.pkg homebrew-tap: runs-on: macos-15 - needs: [start, prepare-release] + needs: start steps: - name: 📺 Checkout mas repo uses: actions/checkout@v4 with: # A fetch-depth of 0 includes all history and tags for script/version fetch-depth: 0 - ref: ${{ needs.start.outputs.release_branch }} + ref: ${{ needs.start.outputs.mas_version }} - name: 👢 Bootstrap run: | @@ -179,60 +128,42 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }} DRY_RUN: ${{ needs.start.outputs.dry_run }} - RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }} - MAS_VERSION: ${{ needs.start.outputs.mas_version }} working-directory: ${{ needs.start.outputs.tap_path }} run: | - git branch "${RELEASE_BRANCH}" - git switch "${RELEASE_BRANCH}" - - cp -v \ - "${GITHUB_WORKSPACE}/Homebrew/mas-tap.rb" \ - Formula/mas.rb - - git add Formula/mas.rb - git commit --message="🔖 Version ${MAS_VERSION}" - - git push \ - --set-upstream origin "${RELEASE_BRANCH}" - - gh pr create \ - --assignee phatblat \ - --base main \ - --head "${RELEASE_BRANCH}" \ - --title "🔖 Version ${MAS_VERSION}" \ - --body "This PR contains the changes from releasing version \ - [${MAS_VERSION}](https://github.com/mas-cli/mas/releases/tag/${MAS_VERSION})." + brew bump-formula-pr \ + --strict \ + --online \ + --tag '${{ needs.start.outputs.mas_version }}' \ + --revision "$(git rev-list -n 1 '${{ needs.start.outputs.mas_version }}')" \ + mas-cli/tap/mas - name: 🚰 Update mas tap formula env: GH_TOKEN: ${{ github.token }} 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}" + script/bottle - name: 🚀 Upload Bottles env: GH_TOKEN: ${{ github.token }} DRY_RUN: ${{ needs.start.outputs.dry_run }} - MAS_VERSION: ${{ needs.start.outputs.mas_version }} if: ${{ needs.start.outputs.dry_run == 'false' }} run: | - gh release upload "${MAS_VERSION}" \ + gh release upload '${{ needs.start.outputs.mas_version }}' \ .build/bottles/mas-*.bottle.tar.gz homebrew-core: runs-on: macos-15 - needs: [start, prepare-release, homebrew-tap] + needs: [start, homebrew-tap] if: ${{ needs.start.outputs.pre_release == 'false' }} steps: - uses: actions/checkout@v4 with: # A fetch-depth of 0 includes all history and tags for script/version fetch-depth: 0 - ref: ${{ needs.start.outputs.release_branch }} + ref: ${{ needs.start.outputs.mas_version }} - name: 👢 Bootstrap run: | @@ -248,7 +179,5 @@ jobs: GH_TOKEN: ${{ github.token }} HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} 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 diff --git a/Brewfile b/Brewfile index b1276705d..693f5cd22 100644 --- a/Brewfile +++ b/Brewfile @@ -1,7 +1,6 @@ brew "act" brew "markdownlint-cli" brew "prettier" -brew "sd" brew "shellcheck" brew "shfmt" brew "swift-format" diff --git a/Brewfile.lock.json b/Brewfile.lock.json index a4de42f91..05b809322 100644 --- a/Brewfile.lock.json +++ b/Brewfile.lock.json @@ -40,55 +40,6 @@ } } }, - "sd": { - "version": "1.0.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sd/blobs/sha256:3cf7ab4495f622a4f245bb1c7c30225ef881dc390ee5edc59a1d3c4381cecca1", - "sha256": "3cf7ab4495f622a4f245bb1c7c30225ef881dc390ee5edc59a1d3c4381cecca1" - }, - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sd/blobs/sha256:6bc773a70934364157591cd888e617601a42ed1f615fda8f77364fa45631d08d", - "sha256": "6bc773a70934364157591cd888e617601a42ed1f615fda8f77364fa45631d08d" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sd/blobs/sha256:946a44f567e3528d380fbbee742c3abeed9952f53f7de172a846b63d2e21d5b1", - "sha256": "946a44f567e3528d380fbbee742c3abeed9952f53f7de172a846b63d2e21d5b1" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sd/blobs/sha256:60f079d38aa238a1e7109c6a0f988fe7033449d20f05db3b87219cbfd945fe58", - "sha256": "60f079d38aa238a1e7109c6a0f988fe7033449d20f05db3b87219cbfd945fe58" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sd/blobs/sha256:f83ebe2505106e8c94c4b92d15c0ac3390dc637039043dbafad3e382fa8c61b0", - "sha256": "f83ebe2505106e8c94c4b92d15c0ac3390dc637039043dbafad3e382fa8c61b0" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sd/blobs/sha256:0200b81c386198d39ed7b03e85c771e141d9604075d82aa4caed5d5a775486c8", - "sha256": "0200b81c386198d39ed7b03e85c771e141d9604075d82aa4caed5d5a775486c8" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sd/blobs/sha256:a8fee9e7b0202a27d8dcc599ebd391637107134f139dbe88d6b22c880e63d8a1", - "sha256": "a8fee9e7b0202a27d8dcc599ebd391637107134f139dbe88d6b22c880e63d8a1" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/sd/blobs/sha256:4c098bdfaff013f7a6b6b96a65b9cfef86926e1cd901b363e1bdb84734ee6e3f", - "sha256": "4c098bdfaff013f7a6b6b96a65b9cfef86926e1cd901b363e1bdb84734ee6e3f" - } - } - } - }, "shellcheck": { "version": "0.10.0", "bottle": { diff --git a/Homebrew/mas-tap.rb b/Homebrew/mas-tap.rb deleted file mode 100644 index 4d52cf06a..000000000 --- a/Homebrew/mas-tap.rb +++ /dev/null @@ -1,34 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -# mas command formula for custom tap (mas-cli/homebrew-tap). -class Mas < Formula - desc "Mac App Store command-line interface" - homepage "https://github.com/mas-cli/mas" - url "https://github.com/mas-cli/mas.git", - tag: "v1.8.7-beta.1", - revision: "f8be3e9aaa6c78490277976f17041f2577f5dc21" - license "MIT" - head "https://github.com/mas-cli/mas.git", branch: "main" - - bottle do - root_url "https://github.com/mas-cli/mas/releases/download/v1.8.7-beta.1" - sha256 cellar: :any_skip_relocation, el_capitan: "0d042a450d2623e3ea40db0b645454ee88d1a1763a7aa778eec5beea619b9a60" - end - - depends_on xcode: ["14.2", :build] - depends_on :macos - - def install - system "script/build" - system "script/install", prefix - - bash_completion.install "contrib/completion/mas-completion.bash" => "mas" - fish_completion.install "contrib/completion/mas.fish" - end - - test do - assert_equal version.to_s, shell_output("#{bin}/mas version").chomp - assert_includes shell_output("#{bin}/mas info 497799835"), "Xcode" - end -end diff --git a/Homebrew/mas.rb b/Homebrew/mas.rb deleted file mode 100644 index 7e1373205..000000000 --- a/Homebrew/mas.rb +++ /dev/null @@ -1,41 +0,0 @@ -# typed: strict -# frozen_string_literal: true - -# mas command formula for homebrew-core tap. -class Mas < Formula - desc "Mac App Store command-line interface" - homepage "https://github.com/mas-cli/mas" - url "https://github.com/mas-cli/mas.git", - tag: "v1.8.7-beta.1", - revision: "f8be3e9aaa6c78490277976f17041f2577f5dc21" - license "MIT" - head "https://github.com/mas-cli/mas.git", branch: "main" - - bottle do - sha256 cellar: :any_skip_relocation, arm64_sonoma: "7b11bfefcb43e9a423ff301f7bbc29b0fb86044bf93442f243c5a8a67d8d4869" - sha256 cellar: :any_skip_relocation, arm64_ventura: "e49511dd1283813c4420aec9fc3b3167d18f9fdbb51d82b1e479b628d5312342" - sha256 cellar: :any_skip_relocation, arm64_monterey: "379d46e2657be295321f1603dc1df28130ea0b5b264ceb192a9ba488d77c7a98" - sha256 cellar: :any_skip_relocation, arm64_big_sur: "918a1484de106940f7bebc936e1ded87d7b65652054b09204887ad0651937ec4" - sha256 cellar: :any_skip_relocation, sonoma: "24e3057991ea1eed52eb4a27c0f17d794106770621e5a8bb975477dae135b82d" - sha256 cellar: :any_skip_relocation, ventura: "6ef7788e28c46cdc0f916812f49dfeb1fabf2240a8c36f33ce34bcfb9df1502f" - sha256 cellar: :any_skip_relocation, monterey: "6b313f2f66d028cb7782c108d6e502ce73ccb9c08fac3bece0b057fcce5c4689" - sha256 cellar: :any_skip_relocation, big_sur: "50b50f51219143fcb69c730b52b74011a76104f66348ea727d0200f7b375ae25" - sha256 cellar: :any_skip_relocation, catalina: "d241d3b9156b033f3d2c31684a44de726297e07fd9bd5e3ccc4c36e4f1c3baf3" - end - - depends_on xcode: ["14.2", :build] - depends_on :macos - - def install - system "script/build" - system "script/install", prefix - - bash_completion.install "contrib/completion/mas-completion.bash" => "mas" - fish_completion.install "contrib/completion/mas.fish" - end - - test do - assert_equal version.to_s, shell_output("#{bin}/mas version").chomp - assert_includes shell_output("#{bin}/mas info 497799835"), "Xcode" - end -end diff --git a/script/bottle b/script/bottle index 695510ffb..1c45163b1 100755 --- a/script/bottle +++ b/script/bottle @@ -76,33 +76,6 @@ if [[ "$(uname -m)" == 'arm64' ]]; then CURRENT_PLATFORM="arm64_${CURRENT_PLATFORM}" fi -################################################################################ -# -# Preflight checks -# - -# # Uninstall if necessary -# brew remove mas 2>/dev/null || true -# brew remove mas-cli/tap/mas 2>/dev/null || true - -# # Uninstall if still found on path -# if command -v mas >/dev/null; then -# script/uninstall || true -# fi - -# Use formula from custom tap -# brew tap mas-cli/tap -# brew update - -# Audit formula -brew audit --strict --verbose --formula --tap mas-cli/tap mas -brew style Homebrew/mas-tap.rb - -################################################################################ -# -# Build the formula for the current macOS version and architecture. -# - echo "==> 🍼 Bottling mas ${version} on ${CURRENT_PLATFORM} for ${OS_NAMES[*]}" brew install --build-bottle mas-cli/tap/mas @@ -119,45 +92,10 @@ if [[ ! -e "${generated_bottle_filename}" ]]; then exit 1 fi -SHA256="$(shasum -a 256 "${generated_bottle_filename}" | cut -f 1 -d ' ' -)" - mkdir -p "${BOTTLE_DIR}" -# Start of bottle block -BOTTLE_BLOCK="$( - cat <<-EOF -bottle do - root_url "${ROOT_URL}" -EOF -)" - -################################################################################ -# -# Copy the bottle for all macOS version + architecture combinations. -# - -# Fix filename for os in "${OS_NAMES[@]}"; do cp -v "${generated_bottle_filename}" "${BOTTLE_DIR}/mas-${version}.${os}.bottle.tar.gz" - - # Append each os - # BOTTLE_BLOCK="$(printf "${BOTTLE_BLOCK}\n sha256 cellar: :any_skip_relocation, %-15s %s" "${os}:" "${SHA256}")" - BOTTLE_BLOCK="${BOTTLE_BLOCK}$( - cat <<-EOF - - sha256 cellar: :any_skip_relocation, ${os}: "${SHA256}" -EOF - )" done -# End of bottle block -BOTTLE_BLOCK="$( - cat <<-EOF - -end -EOF -)" - rm "${generated_bottle_filename}" -ls -l "${BOTTLE_DIR}" -echo "${BOTTLE_BLOCK}" diff --git a/script/brew_core_update b/script/brew_core_update index 316b5f9d6..8f78ef9fa 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -16,18 +16,14 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -CORE_TAP_PATH="$(brew --repo homebrew/core)" - function usage { - echo 'Usage: brew_core_update [-d] [ []]' >&2 + echo 'Usage: brew_core_update [-d]' >&2 echo ' -d option enables dry run mode' >&2 - echo ' version will be inferred using version script if not provided' >&2 - echo ' sha will be inferred from the current commit if not provided' >&2 exit 1 } -# Max 3 arguments -if [[ "${#}" -gt 3 ]]; then +# Max 1 argument +if [[ "${#}" -gt 1 ]]; then usage fi @@ -37,7 +33,7 @@ dry_run= while getopts 'd' o; do case "${o}" in d) - dry_run=-d + dry_run=--dry-run ;; *) usage @@ -49,106 +45,21 @@ shift "$((OPTIND - 1))" # DRY_RUN environment variable # shellcheck disable=SC2153 if [[ "${DRY_RUN}" == 'true' ]]; then - dry_run=-d -fi - -# arg 1 - version tag -MAS_VERSION="${1:-"v$(script/version)"}" - -echo "MAS_VERSION: ${MAS_VERSION}" - -# arg 2 - revision (commit hash) -# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag -REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}" - -echo "REVISION: ${REVISION}" - -################################################################################ -# -# Preflight checks -# - -# Uninstall if necessary -brew remove mas 2>/dev/null || true -brew remove mas-cli/tap/mas 2>/dev/null || true - -# Uninstall if still found on path -if command -v mas >/dev/null; then - script/uninstall || true -fi - -# Ensure core is tapped -if ! [[ -d "${CORE_TAP_PATH}" ]]; then - brew tap homebrew/core -fi - -brew update - -################################################################################ -# -# Build the formula for the current macOS version and architecture. -# - -# Update mas formula in core (temporary) -cp -v Homebrew/mas.rb "${CORE_TAP_PATH}/Formula/m/mas.rb" - -# Install mas from source -# HOMEBREW_NO_INSTALL_FROM_API: -# Force brew to use the local repository instead of the API. -# Disable API before any install, reinstall or upgrade commands. - -HOMEBREW_NO_INSTALL_FROM_API=1 \ - brew install mas \ - --build-from-source \ - --verbose - -# Audit formula -brew audit --strict mas -brew style mas - -# Revert core formula change after testing -pushd "${CORE_TAP_PATH}" -git diff -git checkout . -popd - -################################################################################ -# -# Update Homebrew -# - -echo "==> 🧪 Updating homebrew-core formula mas (${MAS_VERSION}, ${REVISION})" - -echo 'Validating formula' -brew bump-formula-pr \ - --tag="${MAS_VERSION}" \ - --revision="${REVISION}" \ - --strict \ - --verbose \ - --no-browse \ - --fork-org mas-cli \ - --dry-run \ - mas - -# brew exit status -status="${?}" -if [[ "${status}" -ne 0 ]]; then - echo $'Formula did not validate using \'brew bump-formula-pr\'' >&2 - exit "${status}" + dry_run=--dry-run fi -if [[ "${dry_run}" == '-d' ]]; then - exit 0 -fi +version_tag="v$(script/version)" +revision="$(git rev-parse "${version_tag}")" -echo 'Updating homebrew/core formula with a PR' +echo "==> 🧪 Updating mas homebrew-core formula to version tag ${version_tag} @ revision ${revision}" brew bump-formula-pr \ - --tag="${MAS_VERSION}" \ - --revision="${REVISION}" \ + --tag="${version_tag}" \ + --revision="${revision}" \ --strict \ --verbose \ --online \ --no-browse \ --fork-org mas-cli \ + ${dry_run} \ mas diff --git a/script/brew_tap_update b/script/brew_tap_update deleted file mode 100755 index d9f7139ee..000000000 --- a/script/brew_tap_update +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -ex -# -# script/brew_tap_update -# mas -# -# Updates mas custom tap formula: -# https://github.com/mas-cli/homebrew-tap/blob/main/Formula/mas.rb -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -function usage { - echo 'Usage: brew_tap_update [ []]' >&2 - echo ' version will be inferred using version script if not provided' >&2 - echo ' sha will be inferred from the current commit if not provided' >&2 - exit 1 -} - -# Max 2 arguments -if [[ "${#}" -gt 2 ]]; then - usage -fi - -# arg 1 - version tag -MAS_VERSION="${1:-"v$(script/version)"}" - -echo "MAS_VERSION: ${MAS_VERSION}" - -# arg 2 - revision (commit hash) -# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag -REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}" - -echo "REVISION: ${REVISION}" - -# Build in mas project -script/bottle diff --git a/script/build b/script/build index b6ac981fb..fa843f025 100755 --- a/script/build +++ b/script/build @@ -30,7 +30,9 @@ else CACHE=() fi -echo "==> 🏗️ Building mas $(script/version --write)" +script/generate_version_info_for_swift + +echo "==> 🏗️ Building mas $(script/version)" swift build \ --configuration release \ "${ARCH[@]+"${ARCH[@]}"}" \ diff --git a/script/generate_version_info_for_swift b/script/generate_version_info_for_swift index fd3afc5a4..b276c25cb 100755 --- a/script/generate_version_info_for_swift +++ b/script/generate_version_info_for_swift @@ -3,7 +3,7 @@ # script/generate_version_info_for_swift # mas # -# Increments the marketing version of mas. +# Generates a file to provide the mas version to Swift code. # mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" @@ -13,46 +13,10 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -LOCAL_MAS_FORMULA_PATH=Homebrew/mas.rb -LOCAL_TAP_FORMULA_PATH=Homebrew/mas-tap.rb -SWIFT_PACKAGE=Sources/mas/Package.swift - -function usage { - echo 'Usage: generate_version_info_for_swift []' >&2 - echo ' existing tag name' >&2 - echo ' sha will be inferred from the given tag if not provided' >&2 - exit 1 -} - -if [[ "${#}" -lt 1 ]]; then - usage -fi - -# arg 1 - version tag -MAS_VERSION="${1}" - -# arg 2 - revision (commit hash) -# If arg 2 wasn't supplied or is empty, obtain revision from ${MAS_VERSION} version tag -REVISION="${2:-"$(git rev-parse "${MAS_VERSION}")"}" - -echo "MAS_VERSION: ${MAS_VERSION}" -echo "REVISION: ${REVISION}" - -# Write new version into swift package -cat <"${SWIFT_PACKAGE}" +# Write version to Swift singleton +cat <Sources/mas/Package.swift /// Generated by \`script/generate_version_info_for_swift\`. enum Package { - static let version = "${MAS_VERSION#v}" + static let version = "$(script/version)" } EOF - -echo -cat "${SWIFT_PACKAGE}" - -# Write new version into brew formulae -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}" - sd '( +root_url "https://github.com/mas-cli/mas/releases/download/).+' "\${1}${MAS_VERSION}\"" "${file}" -done diff --git a/script/lint b/script/lint index 844b80470..543aa687c 100755 --- a/script/lint +++ b/script/lint @@ -19,7 +19,9 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -printf $'==> 🚨 Linting mas %s\n' "$(script/version --write)" +script/generate_version_info_for_swift + +printf $'==> 🚨 Linting mas %s\n' "$(script/version)" for linter in git markdownlint periphery shellcheck shfmt swift-format swiftformat swiftlint yamllint; do if [[ ! -x "$(command -v "${linter}")" ]]; then diff --git a/script/test b/script/test index 02c5eecf3..0af4334d0 100755 --- a/script/test +++ b/script/test @@ -13,6 +13,8 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -printf $'==> ✅ Testing mas %s\n' "$(script/version --write)" +script/generate_version_info_for_swift + +printf $'==> ✅ Testing mas %s\n' "$(script/version)" swift test diff --git a/script/version b/script/version index 067c184a5..14581650f 100755 --- a/script/version +++ b/script/version @@ -3,7 +3,7 @@ # script/version # mas # -# Displays the current marketing version of mas. +# Displays the mas version. # mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" @@ -15,13 +15,3 @@ fi version_tag="$(git describe --abbrev=0 --tags 2>/dev/null)" printf $'%s\n' "${version_tag#v}" - -if [[ "${#}" -ge 1 && "${1}" == '--write' ]]; then - # Write new version into swift package - cat <Sources/mas/Package.swift -/// Generated by \`script/version\`. -enum Package { - static let version = "${MAS_VERSION#v}" -} -EOF -fi From 4831ea4ac49d0cf1ad0247eb41303fe127e9922a Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:41:18 -0500 Subject: [PATCH 043/131] Fix `Makefile` comment. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1f3335b65..9303ee314 100644 --- a/Makefile +++ b/Makefile @@ -162,5 +162,5 @@ brew_formula_update: ## Updates homebrew-core formula. script/brew_formula_update .PHONY: brew_release_validate -brew_release_validate: ## Builds Homebrew bottle for the current system. +brew_release_validate: ## Validates Homebrew mas formula. script/brew_release_validate From e1bea1f412288e7c6699d365685eb0b59b7b34e5 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:41:48 -0500 Subject: [PATCH 044/131] Remove obsolete `Makefile` target. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index 9303ee314..012319d1b 100644 --- a/Makefile +++ b/Makefile @@ -157,10 +157,6 @@ package-install: package ## Installs the package. bottle: ## Builds Homebrew bottles. script/bottle -.PHONY: brew_formula_update -brew_formula_update: ## Updates homebrew-core formula. - script/brew_formula_update - .PHONY: brew_release_validate brew_release_validate: ## Validates Homebrew mas formula. script/brew_release_validate From 3b10909c2aa5928fe38a7edbb6a7d4f0abf6c07d Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:42:28 -0500 Subject: [PATCH 045/131] Delete `script/bottle`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 17 ------ Makefile | 4 -- script/bottle | 101 ---------------------------------- 3 files changed, 122 deletions(-) delete mode 100755 script/bottle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa7cb0ffc..919bb17d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -137,23 +137,6 @@ jobs: --revision "$(git rev-list -n 1 '${{ needs.start.outputs.mas_version }}')" \ mas-cli/tap/mas - - name: 🚰 Update mas tap formula - env: - GH_TOKEN: ${{ github.token }} - DRY_RUN: ${{ needs.start.outputs.dry_run }} - run: | - DRY_RUN="${DRY_RUN}" \ - script/bottle - - - name: 🚀 Upload Bottles - env: - GH_TOKEN: ${{ github.token }} - DRY_RUN: ${{ needs.start.outputs.dry_run }} - if: ${{ needs.start.outputs.dry_run == 'false' }} - run: | - gh release upload '${{ needs.start.outputs.mas_version }}' \ - .build/bottles/mas-*.bottle.tar.gz - homebrew-core: runs-on: macos-15 needs: [start, homebrew-tap] diff --git a/Makefile b/Makefile index 012319d1b..1cb6ede2e 100644 --- a/Makefile +++ b/Makefile @@ -153,10 +153,6 @@ package: build ## Packages the project. package-install: package ## Installs the package. script/package_install -.PHONY: bottle -bottle: ## Builds Homebrew bottles. - script/bottle - .PHONY: brew_release_validate brew_release_validate: ## Validates Homebrew mas formula. script/brew_release_validate diff --git a/script/bottle b/script/bottle deleted file mode 100755 index 1c45163b1..000000000 --- a/script/bottle +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -ex -# -# script/bottle -# mas -# -# Builds bottles of mas Homebrew formula for custom tap: -# https://github.com/mas-cli/homebrew-tap -# -# This script should be run _after_ the formula has been updated in Homebrew -# - -################################################################################ -# -# Variables -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -BOTTLE_DIR=".build/bottles" -CORE_TAP_PATH="$(brew --repo homebrew/core)" -version="$(script/version)" -ROOT_URL="https://github.com/mas-cli/mas/releases/download/v${version}" - -# Supports macOS 10.13 and later -OS_NAMES=( - sequoia - arm64_sequoia - sonoma - arm64_sonoma - ventura - arm64_ventura - monterey - arm64_monterey - big_sur - arm64_big_sur - catalina - mojave - high_sierra - sierra - el_capitan -) - -macos_version="$(sw_vers -productVersion)" -case "${macos_version%%.*}" in - 15) - CURRENT_PLATFORM=sequoia - ;; - 14) - CURRENT_PLATFORM=sonoma - ;; - 13) - CURRENT_PLATFORM=ventura - ;; - 12) - CURRENT_PLATFORM=monterey - ;; - 11) - CURRENT_PLATFORM=big_sur - ;; - 10) - CURRENT_PLATFORM=catalina - ;; - *) - echo 'Unsupported macOS version. This script requires Catalina or newer.' >&2 - exit 1 - ;; -esac - -# Prefix platform with architecture -if [[ "$(uname -m)" == 'arm64' ]]; then - CURRENT_PLATFORM="arm64_${CURRENT_PLATFORM}" -fi - -echo "==> 🍼 Bottling mas ${version} on ${CURRENT_PLATFORM} for ${OS_NAMES[*]}" -brew install --build-bottle mas-cli/tap/mas - -# Generate bottle do block, dropping last 2 lines -brew bottle --verbose --no-rebuild --root-url="${ROOT_URL}" mas-cli/tap/mas - -# Output filename from brew bottle -generated_bottle_filename="mas--${version}.${CURRENT_PLATFORM}.bottle.tar.gz" - -if [[ ! -e "${generated_bottle_filename}" ]]; then - echo "Bottle not found: ${generated_bottle_filename}" >&2 - echo 'If an old version is showing in the log and filename, then make sure the formula has been updated in:' >&2 - echo "${CORE_TAP_PATH}" >&2 - exit 1 -fi - -mkdir -p "${BOTTLE_DIR}" - -for os in "${OS_NAMES[@]}"; do - cp -v "${generated_bottle_filename}" "${BOTTLE_DIR}/mas-${version}.${os}.bottle.tar.gz" -done - -rm "${generated_bottle_filename}" From 31e946a69bac5b0e8e788b6389395a9685aca73e Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:46:05 -0500 Subject: [PATCH 046/131] Just bump custom tap formula. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 56 +++++------------------------------ 1 file changed, 7 insertions(+), 49 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 919bb17d7..17a942e61 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,6 @@ jobs: dry_run: ${{ steps.dry_run.outputs.dry_run }} mas_version: ${{ steps.mas_version.outputs.mas_version }} pre_release: ${{ steps.pre_release.outputs.pre_release }} - tap_path: ${{ steps.tap_path.outputs.tap_path }} steps: # Logs event details and sets `DRY_RUN` env var # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable @@ -44,10 +43,6 @@ jobs: run: | echo "PRE_RELEASE=$(grep -q '-' <<<"${MAS_VERSION}" && echo 'true' || echo 'false')" >>"${GITHUB_OUTPUT}" - - id: tap_path - run: | - echo "TAP_PATH='$(brew --repo mas-cli/tap)'" >>"${GITHUB_OUTPUT}" - pkg-installer: runs-on: macos-15 needs: start @@ -85,56 +80,19 @@ jobs: runs-on: macos-15 needs: start steps: - - name: 📺 Checkout mas repo - uses: actions/checkout@v4 - with: - # A fetch-depth of 0 includes all history and tags for script/version - fetch-depth: 0 - ref: ${{ needs.start.outputs.mas_version }} - - - name: 👢 Bootstrap - run: | - script/bootstrap -f - - # The mas-cli/homebrew-tap repo needs to be checked out using the current - # GitHub credentials in order to open a PR. However, the `brew tap` command - # must be run for Homebrew to see the dir as a tap. - # This is necessary to avoid the following error: - # Error: No available formula or cask with the name "mas-cli/tap/mas". - - name: 🚰 Tap mas tap - env: - TAP_PATH: ${{ needs.start.outputs.tap_path }} - run: | - TAPS_PATH="$(realpath "$(brew --repo mas-cli/tap)/../..")" - rm -rf "${TAPS_PATH}" - mkdir Taps - ln -s "$(realpath Taps)" "${TAPS_PATH}" - brew tap mas-cli/tap - - # Checkout with a token for write access - - name: 🚰 Re-clone mas tap - uses: actions/checkout@v4 - with: - repository: mas-cli/homebrew-tap - token: ${{ secrets.DEPLOY_TOKEN }} - path: Taps/mas-cli/homebrew-tap - - - name: 🔧 Configure Git Author - run: | - git config --global user.name 'masclibot' - git config --global user.email 'masclibot@users.noreply.github.com' - - - name: ⤴️ Open mas tap PR + - name: ⤴️ Bump mas tap formula env: - GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }} DRY_RUN: ${{ needs.start.outputs.dry_run }} - working-directory: ${{ needs.start.outputs.tap_path }} + HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} run: | brew bump-formula-pr \ - --strict \ - --online \ --tag '${{ needs.start.outputs.mas_version }}' \ --revision "$(git rev-list -n 1 '${{ needs.start.outputs.mas_version }}')" \ + --strict \ + --verbose \ + --online \ + --no-browse \ + ${{ needs.start.outputs.dry_run }} \ mas-cli/tap/mas homebrew-core: From 4f4a37ec74f8743a848a13ab21d776410268c046 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:48:40 -0500 Subject: [PATCH 047/131] Cleanup `homebrew-core` release job. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 17a942e61..757915a0d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,15 +110,9 @@ jobs: run: | script/bootstrap -f - - name: 🔧 Configure Git Author - run: | - git config --global user.name 'masclibot' - git config --global user.email 'masclibot@users.noreply.github.com' - - - name: 🍺 Update Homebrew mas formula + - name: 🍺 Update homebrew-core mas formula env: - GH_TOKEN: ${{ github.token }} HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} DRY_RUN: ${{ needs.start.outputs.dry_run }} run: | - DRY_RUN="${DRY_RUN}" script/brew_core_update + script/brew_core_update From ce81834035a5309ea2815c021933a94836b7c9fc Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:49:18 -0500 Subject: [PATCH 048/131] Make `brew bump-formula-pr` usages consistent. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/brew_core_update | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/brew_core_update b/script/brew_core_update index 8f78ef9fa..1424eb60e 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -54,11 +54,11 @@ revision="$(git rev-parse "${version_tag}")" echo "==> 🧪 Updating mas homebrew-core formula to version tag ${version_tag} @ revision ${revision}" brew bump-formula-pr \ - --tag="${version_tag}" \ - --revision="${revision}" \ + --tag "${version_tag}" \ + --revision "${revision}" \ --strict \ - --verbose \ --online \ + --verbose \ --no-browse \ --fork-org mas-cli \ ${dry_run} \ From 8c397ae24dd637ad16e2bb038bc95ff1c5de6791 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 05:17:06 -0500 Subject: [PATCH 049/131] `release.yml`: improve comments, remove unnecessary environment variables, and reorder some settings. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 23 ++++++++--------------- script/brew_core_update | 6 ------ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 757915a0d..81a33b1a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ name: release defaults: run: - # Prefixes all `run` commands with the following command to force them to run outside Rosetta. + # Force all run commands to not use Rosetta 2 shell: arch -arm64 /bin/bash --noprofile --norc -eo pipefail {0} on: release: @@ -18,11 +18,8 @@ jobs: mas_version: ${{ steps.mas_version.outputs.mas_version }} pre_release: ${{ steps.pre_release.outputs.pre_release }} steps: - # Logs event details and sets `DRY_RUN` env var - # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable - # https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=published#release - name: 🔈 Log release event - # This step will only run for a real 'release' event. + # Run only for a real release event if: ${{ github.event.release.name != '' }} run: | echo 'Triggered by a release publication event (wet run)' @@ -49,7 +46,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - # A fetch-depth of 0 includes all history and tags for script/version + # Include all history & tags for script/version fetch-depth: 0 ref: ${{ needs.start.outputs.mas_version }} @@ -57,8 +54,7 @@ jobs: run: | script/bootstrap -f - # Important to trigger a universal build first as package just works with - # the `mas` binary in finds in the build dir. + # Run a universal build to produce mas binary for package - name: 🏗️ Build Universal run: | script/build --universal @@ -68,10 +64,9 @@ jobs: script/package - name: 🚀 Upload mas.pkg + if: ${{ needs.start.outputs.dry_run == 'false' }} env: GH_TOKEN: ${{ github.token }} - DRY_RUN: ${{ needs.start.outputs.dry_run }} - if: ${{ needs.start.outputs.dry_run == 'false' }} run: | gh release upload '${{ needs.start.outputs.mas_version }}' \ .build/mas.pkg @@ -82,7 +77,6 @@ jobs: steps: - name: ⤴️ Bump mas tap formula env: - DRY_RUN: ${{ needs.start.outputs.dry_run }} HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} run: | brew bump-formula-pr \ @@ -96,13 +90,13 @@ jobs: mas-cli/tap/mas homebrew-core: + if: ${{ needs.start.outputs.pre_release == 'false' }} runs-on: macos-15 needs: [start, homebrew-tap] - if: ${{ needs.start.outputs.pre_release == 'false' }} steps: - uses: actions/checkout@v4 with: - # A fetch-depth of 0 includes all history and tags for script/version + # Include all history & tags for script/version fetch-depth: 0 ref: ${{ needs.start.outputs.mas_version }} @@ -113,6 +107,5 @@ jobs: - name: 🍺 Update homebrew-core mas formula env: HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} - DRY_RUN: ${{ needs.start.outputs.dry_run }} run: | - script/brew_core_update + script/brew_core_update ${{ needs.start.outputs.dry_run }} diff --git a/script/brew_core_update b/script/brew_core_update index 1424eb60e..6b1e10b54 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -42,12 +42,6 @@ while getopts 'd' o; do done shift "$((OPTIND - 1))" -# DRY_RUN environment variable -# shellcheck disable=SC2153 -if [[ "${DRY_RUN}" == 'true' ]]; then - dry_run=--dry-run -fi - version_tag="v$(script/version)" revision="$(git rev-parse "${version_tag}")" From 1ec76e9d65167d4ae9cf7e1c90ade642a3bce3be Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 05:22:09 -0500 Subject: [PATCH 050/131] Remove extraneous spaces surrounding variables in GitHub workflows. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/build-test.yml | 2 +- .github/workflows/danger.yml | 2 +- .github/workflows/release.yml | 42 ++++++++++++++++---------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 357cca22f..c4897f035 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -12,7 +12,7 @@ on: branches: [main] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{github.workflow}}-${{github.ref}} cancel-in-progress: true jobs: diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 6717f744a..ad4eac49c 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -18,4 +18,4 @@ jobs: with: args: --failOnErrors --no-publish-check env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 81a33b1a7..87637a5b9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,19 +14,19 @@ jobs: start: runs-on: macos-15 outputs: - dry_run: ${{ steps.dry_run.outputs.dry_run }} - mas_version: ${{ steps.mas_version.outputs.mas_version }} - pre_release: ${{ steps.pre_release.outputs.pre_release }} + dry_run: ${{steps.dry_run.outputs.dry_run}} + mas_version: ${{steps.mas_version.outputs.mas_version}} + pre_release: ${{steps.pre_release.outputs.pre_release}} steps: - name: 🔈 Log release event # Run only for a real release event - if: ${{ github.event.release.name != '' }} + if: ${{github.event.release.name != ''}} run: | echo 'Triggered by a release publication event (wet run)' - echo 'release.name: ${{ github.event.release.name }}' - echo 'release.tag_name: ${{ github.event.release.tag_name }}' - echo 'release.target_commitish: ${{ github.event.release.target_commitish }}' - echo $'release.body: \n${{ github.event.release.body }}' + echo 'release.name: ${{github.event.release.name}}' + echo 'release.tag_name: ${{github.event.release.tag_name}}' + echo 'release.target_commitish: ${{github.event.release.target_commitish}}' + echo $'release.body: \n${{github.event.release.body}}' - id: dry_run run: | @@ -34,7 +34,7 @@ jobs: - id: mas_version run: | - echo 'MAS_VERSION=${{ github.event.release.tag_name }}' >>"${GITHUB_OUTPUT}" + echo 'MAS_VERSION=${{github.event.release.tag_name}}' >>"${GITHUB_OUTPUT}" - id: pre_release run: | @@ -48,7 +48,7 @@ jobs: with: # Include all history & tags for script/version fetch-depth: 0 - ref: ${{ needs.start.outputs.mas_version }} + ref: ${{needs.start.outputs.mas_version}} - name: 👢 Bootstrap run: | @@ -64,11 +64,11 @@ jobs: script/package - name: 🚀 Upload mas.pkg - if: ${{ needs.start.outputs.dry_run == 'false' }} + if: ${{needs.start.outputs.dry_run == 'false'}} env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{github.token}} run: | - gh release upload '${{ needs.start.outputs.mas_version }}' \ + gh release upload '${{needs.start.outputs.mas_version}}' \ .build/mas.pkg homebrew-tap: @@ -77,20 +77,20 @@ jobs: steps: - name: ⤴️ Bump mas tap formula env: - HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} + HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | brew bump-formula-pr \ - --tag '${{ needs.start.outputs.mas_version }}' \ - --revision "$(git rev-list -n 1 '${{ needs.start.outputs.mas_version }}')" \ + --tag '${{needs.start.outputs.mas_version}}' \ + --revision "$(git rev-list -n 1 '${{needs.start.outputs.mas_version}}')" \ --strict \ --verbose \ --online \ --no-browse \ - ${{ needs.start.outputs.dry_run }} \ + ${{needs.start.outputs.dry_run}} \ mas-cli/tap/mas homebrew-core: - if: ${{ needs.start.outputs.pre_release == 'false' }} + if: ${{needs.start.outputs.pre_release == 'false'}} runs-on: macos-15 needs: [start, homebrew-tap] steps: @@ -98,7 +98,7 @@ jobs: with: # Include all history & tags for script/version fetch-depth: 0 - ref: ${{ needs.start.outputs.mas_version }} + ref: ${{needs.start.outputs.mas_version}} - name: 👢 Bootstrap run: | @@ -106,6 +106,6 @@ jobs: - name: 🍺 Update homebrew-core mas formula env: - HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }} + HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | - script/brew_core_update ${{ needs.start.outputs.dry_run }} + script/brew_core_update ${{needs.start.outputs.dry_run}} From 41f5cb04e951e23007f4d1ce414cd2131e9ac2b0 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 12:28:58 -0500 Subject: [PATCH 051/131] Remove unnecessary comments from GitHub workflows. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/build-test.yml | 1 - .github/workflows/danger.yml | 2 -- 2 files changed, 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index c4897f035..bdaedca9c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,7 +1,6 @@ # # .github/workflows/build-test.yml # -# https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables --- name: Build, Test, and Lint diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index ad4eac49c..5c5c60f2f 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -1,7 +1,6 @@ # # .github/workflows/danger.yml # -# https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables --- name: danger on: @@ -13,7 +12,6 @@ jobs: steps: - uses: actions/checkout@v4 - name: Danger - # https://github.com/orgs/danger/packages/container/package/danger-swift uses: docker://ghcr.io/danger/danger-swift:3.20.2 with: args: --failOnErrors --no-publish-check From 41b100f02275eaf1c0d0a70d9a9f6b74411baf02 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 12:48:42 -0500 Subject: [PATCH 052/131] Replace external grep dependency with bash conditional. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87637a5b9..fc637e4cf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: - id: pre_release run: | - echo "PRE_RELEASE=$(grep -q '-' <<<"${MAS_VERSION}" && echo 'true' || echo 'false')" >>"${GITHUB_OUTPUT}" + echo "PRE_RELEASE=$([[ "${MAS_VERSION}" == *-* ]] && echo true || echo false)" >>"${GITHUB_OUTPUT}" pkg-installer: runs-on: macos-15 From 0e8e8488e07e25b0616a517972618f94a16274f9 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 21:37:13 -0500 Subject: [PATCH 053/131] `script/install`: fix universal executable path. Cleanup `script/install`. `Makefile`: use `${PREFIX}` for `install-universal`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Makefile | 2 +- script/install | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 1cb6ede2e..9e088518a 100644 --- a/Makefile +++ b/Makefile @@ -139,7 +139,7 @@ install: build ## Installs the binary. .PHONY: install-universal install-universal: build-universal ## Installs a universal binary. - script/install --universal + script/install --universal ${PREFIX} .PHONY: uninstall uninstall: ## Uninstalls the binary. diff --git a/script/install b/script/install index 90a4978e0..32b74ba64 100755 --- a/script/install +++ b/script/install @@ -3,10 +3,11 @@ # script/install # mas # -# Installs mas into PREFIX. +# Install mas into a bin folder under a prefix folder, defaulting to /usr/local. +# +# NOTE: This script is run by the mas Homebrew formula, so, aside from Swift, it +# may only depend on system dependencies. # -# NOTE: This script is called by the mas Homebrew formula so it has only system -# dependencies aside from Swift. # https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb # @@ -17,23 +18,22 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -ARCH="$(uname -m)" -RELEASE=".build/${ARCH}-apple-macosx/release" -PREFIX=/usr/local +arch="$(uname -m)" +release=".build/${arch}-apple-macosx/release" +prefix=/usr/local while [[ -n "${1}" ]]; do if [[ "${1}" == '--universal' ]]; then - ARCH=universal - RELEASE=.build/release + arch=universal + release=.build/apple/Products/Release else - # Override default prefix path with optional arg - PREFIX="${1}" + prefix="${1}" fi shift done -echo "==> 📲 Installing mas $(script/version) for ${ARCH} to ${PREFIX}" -ditto -v \ - "${RELEASE}/mas" \ - "${PREFIX}/bin/mas" +printf $'==> 📲 Installing mas %s for %s to %s\n' \ + "$(script/version)" "${arch}" "${prefix}" + +ditto -v "${release}/mas" "${prefix}/bin/mas" From 5122765a314ccad9788ad53c1581301fd60e4045 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:17:33 -0500 Subject: [PATCH 054/131] Bash scripts: Change all non-environment variable names to lowercase. Inline variables that are only used once. Improve comments. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/build | 12 ++++++------ script/format | 20 ++++++++++---------- script/package | 29 +++++++++++------------------ script/package_install | 6 +++--- script/uninstall | 8 ++++---- 5 files changed, 34 insertions(+), 41 deletions(-) diff --git a/script/build b/script/build index fa843f025..bae69ba40 100755 --- a/script/build +++ b/script/build @@ -15,19 +15,19 @@ fi # Build for the host architecture by default. if [[ "${#}" -ge 1 && "${1}" == '--universal' ]]; then - ARCH=( + arch=( --arch arm64 --arch x86_64 ) else - ARCH=() + arch=() fi # Disable the manifest cache. if [[ "$(swift build --help)" =~ manifest-cache ]]; then - CACHE=(--manifest-cache none) + cache=(--manifest-cache none) else - CACHE=() + cache=() fi script/generate_version_info_for_swift @@ -35,6 +35,6 @@ script/generate_version_info_for_swift echo "==> 🏗️ Building mas $(script/version)" swift build \ --configuration release \ - "${ARCH[@]+"${ARCH[@]}"}" \ + "${arch[@]+"${arch[@]}"}" \ --disable-sandbox \ - "${CACHE[@]+"${CACHE[@]}"}" + "${cache[@]+"${cache[@]}"}" diff --git a/script/format b/script/format index d323255a8..27f04cc19 100755 --- a/script/format +++ b/script/format @@ -19,20 +19,20 @@ fi printf $'==> 🚨 Formatting mas\n' -for LINTER in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do - if [[ ! -x "$(command -v "${LINTER}")" ]]; then - printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${LINTER}" "${LINTER}" >&2 +for linter in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do + if [[ ! -x "$(command -v "${linter}")" ]]; then + printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}" >&2 exit 1 fi done -for SOURCE in Package.swift Sources Tests; do - printf -- $'--> 🕊 %s swift-format\n' "${SOURCE}" - swift-format format --in-place --recursive "${SOURCE}" - printf -- $'--> 🕊 %s swiftformat\n' "${SOURCE}" - swiftformat "${SOURCE}" - printf -- $'--> 🕊 %s swiftlint\n' "${SOURCE}" - swiftlint --fix --strict "${SOURCE}" +for source in Package.swift Sources Tests; do + printf -- $'--> 🕊 %s swift-format\n' "${source}" + swift-format format --in-place --recursive "${source}" + printf -- $'--> 🕊 %s swiftformat\n' "${source}" + swiftformat "${source}" + printf -- $'--> 🕊 %s swiftlint\n' "${source}" + swiftlint --fix --strict "${source}" done printf -- $'--> 📜 Bash shfmt\n' diff --git a/script/package b/script/package index 0f40291e8..58773376e 100755 --- a/script/package +++ b/script/package @@ -13,19 +13,12 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -BUILD_DIR=.build -COMPONENT_PACKAGE="${BUILD_DIR}/mas_components.pkg" -DISTRIBUTION_PACKAGE="${BUILD_DIR}/mas.pkg" - -IDENTIFIER=com.mphys.mas-cli - -# Distribution package definition -# https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html -DISTRIBUTION_PLIST=Package/Distribution.plist +build_dir=.build +distribution_package="${build_dir}/mas.pkg" # Destination for install root -DSTROOT="${BUILD_DIR}/distributions" -script/install "${DSTROOT}/usr/local" --universal +dstroot="${build_dir}/distributions" +script/install "${dstroot}/usr/local" --universal version="$(script/version)" @@ -33,18 +26,18 @@ echo "==> 📦 Assembling installer package for mas ${version}" # Assemble macOS installer component package (aka 'product archive'). pkgbuild \ - --identifier "${IDENTIFIER}" \ + --identifier com.mphys.mas-cli \ --install-location '/' \ --version "${version}" \ - --root "${DSTROOT}" \ - "${COMPONENT_PACKAGE}" + --root "${dstroot}" \ + "${build_dir}/mas_components.pkg" # 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 Package/Distribution.plist \ + --package-path "${build_dir}" \ + "${distribution_package}" echo '==> 🔢 File Hash' -shasum -a 256 "${DISTRIBUTION_PACKAGE}" +shasum -a 256 "${distribution_package}" diff --git a/script/package_install b/script/package_install index e68edce16..524f1b814 100755 --- a/script/package_install +++ b/script/package_install @@ -13,7 +13,7 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -IDENTIFIER=com.mphys.mas-cli +identifier=com.mphys.mas-cli echo '==> 📲 Installing mas' @@ -21,6 +21,6 @@ sudo installer \ -pkg .build/mas.pkg \ -target / -pkgutil --pkg-info "${IDENTIFIER}" +pkgutil --pkg-info "${identifier}" -pkgutil --files "${IDENTIFIER}" +pkgutil --files "${identifier}" diff --git a/script/uninstall b/script/uninstall index e5b163e89..6c7536ece 100755 --- a/script/uninstall +++ b/script/uninstall @@ -3,7 +3,7 @@ # script/uninstall # mas # -# Removes mas from PREFIX. +# Removes mas from a bin folder under a prefix folder, defaulting to /usr/local. # mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" @@ -14,8 +14,8 @@ if ! cd -- "${mas_dir}"; then fi # Override default prefix path with optional 1st arg -PREFIX="${1:-"$(brew --prefix)"}" +prefix="${1:-"$(brew --prefix)"}" -echo "==> 🔥 Uninstalling mas from ${PREFIX}" +echo "==> 🔥 Uninstalling mas from ${prefix}" -trash -F "${PREFIX}/bin/mas" || true +trash -F "${prefix}/bin/mas" || true From 4b6482e1e181bcc325ce0793f28ba5090aa45e23 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:54:57 -0500 Subject: [PATCH 055/131] `release.yml`: replace `needs.start.outputs.mas_version` with `github.event.release.tag_name`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fc637e4cf..b552a37ba 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,6 @@ jobs: runs-on: macos-15 outputs: dry_run: ${{steps.dry_run.outputs.dry_run}} - mas_version: ${{steps.mas_version.outputs.mas_version}} pre_release: ${{steps.pre_release.outputs.pre_release}} steps: - name: 🔈 Log release event @@ -32,13 +31,10 @@ jobs: run: | echo DRY_RUN=false >>"${GITHUB_OUTPUT}" - - id: mas_version - run: | - echo 'MAS_VERSION=${{github.event.release.tag_name}}' >>"${GITHUB_OUTPUT}" - - id: pre_release run: | - echo "PRE_RELEASE=$([[ "${MAS_VERSION}" == *-* ]] && echo true || echo false)" >>"${GITHUB_OUTPUT}" + printf $'PRE_RELEASE=%s\n' "$([[ '${{github.event.release.tag_name}}' == *-* ]] && echo true || echo false)" \ + >>"${GITHUB_OUTPUT}" pkg-installer: runs-on: macos-15 @@ -48,7 +44,7 @@ jobs: with: # Include all history & tags for script/version fetch-depth: 0 - ref: ${{needs.start.outputs.mas_version}} + ref: ${{github.event.release.tag_name}} - name: 👢 Bootstrap run: | @@ -68,8 +64,7 @@ jobs: env: GH_TOKEN: ${{github.token}} run: | - gh release upload '${{needs.start.outputs.mas_version}}' \ - .build/mas.pkg + gh release upload '${{github.event.release.tag_name}}' .build/mas.pkg homebrew-tap: runs-on: macos-15 @@ -80,8 +75,8 @@ jobs: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | brew bump-formula-pr \ - --tag '${{needs.start.outputs.mas_version}}' \ - --revision "$(git rev-list -n 1 '${{needs.start.outputs.mas_version}}')" \ + --tag '${{github.event.release.tag_name}}' \ + --revision "$(git rev-list -n 1 '${{github.event.release.tag_name}}')" \ --strict \ --verbose \ --online \ @@ -98,7 +93,7 @@ jobs: with: # Include all history & tags for script/version fetch-depth: 0 - ref: ${{needs.start.outputs.mas_version}} + ref: ${{github.event.release.tag_name}} - name: 👢 Bootstrap run: | From 2960ef61fabf217fc9576d2486aac141215049f0 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:30:15 -0500 Subject: [PATCH 056/131] Do not indent cases in bash scripts. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 12 ++++++------ script/brew_core_update | 12 ++++++------ script/format | 1 - script/lint | 1 - 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index fa10d29d6..d9c7064fe 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -23,12 +23,12 @@ function usage { frozen= while getopts 'f' opt; do case "${opt}" in - f) - frozen='--no-lock --no-upgrade' - ;; - *) - usage - ;; + f) + frozen='--no-lock --no-upgrade' + ;; + *) + usage + ;; esac done diff --git a/script/brew_core_update b/script/brew_core_update index 6b1e10b54..92a74c77d 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -32,12 +32,12 @@ dry_run= # Detect presence of `-d` dry run option while getopts 'd' o; do case "${o}" in - d) - dry_run=--dry-run - ;; - *) - usage - ;; + d) + dry_run=--dry-run + ;; + *) + usage + ;; esac done shift "$((OPTIND - 1))" diff --git a/script/format b/script/format index 27f04cc19..0085e294c 100755 --- a/script/format +++ b/script/format @@ -40,7 +40,6 @@ shfmt \ --write \ --list \ --indent 2 \ - --case-indent \ contrib/ script/ printf -- $'--> 〽️ Markdown\n' diff --git a/script/lint b/script/lint index 543aa687c..c59a20a90 100755 --- a/script/lint +++ b/script/lint @@ -54,7 +54,6 @@ shfmt \ --diff \ --list \ --indent 2 \ - --case-indent \ contrib/ script/ ((exit_code |= "${?}")) From 77175d29bcba101f1a42e55fc144b27af268b8d6 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:51:45 -0500 Subject: [PATCH 057/131] Improve dry run. `brew_core_update`: disable tracing & cleanup script. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 8 ++------ script/brew_core_update | 38 ++++++++++++++++------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b552a37ba..0a40acf35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: start: runs-on: macos-15 outputs: - dry_run: ${{steps.dry_run.outputs.dry_run}} + dry_run: "" pre_release: ${{steps.pre_release.outputs.pre_release}} steps: - name: 🔈 Log release event @@ -27,10 +27,6 @@ jobs: echo 'release.target_commitish: ${{github.event.release.target_commitish}}' echo $'release.body: \n${{github.event.release.body}}' - - id: dry_run - run: | - echo DRY_RUN=false >>"${GITHUB_OUTPUT}" - - id: pre_release run: | printf $'PRE_RELEASE=%s\n' "$([[ '${{github.event.release.tag_name}}' == *-* ]] && echo true || echo false)" \ @@ -60,7 +56,7 @@ jobs: script/package - name: 🚀 Upload mas.pkg - if: ${{needs.start.outputs.dry_run == 'false'}} + if: ${{!needs.start.outputs.dry_run}} env: GH_TOKEN: ${{github.token}} run: | diff --git a/script/brew_core_update b/script/brew_core_update index 92a74c77d..5c41e1b7a 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -1,4 +1,4 @@ -#!/bin/bash -ex +#!/bin/bash -e # # script/brew_core_update # mas @@ -17,35 +17,31 @@ if ! cd -- "${mas_dir}"; then fi function usage { - echo 'Usage: brew_core_update [-d]' >&2 - echo ' -d option enables dry run mode' >&2 + printf $'Usage: brew_core_update [--dry-run]\n --dry-run flag enables dry run mode\n' >&2 exit 1 } -# Max 1 argument -if [[ "${#}" -gt 1 ]]; then - usage -fi - -dry_run= - -# Detect presence of `-d` dry run option -while getopts 'd' o; do - case "${o}" in - d) +# Parse arguments for --dry-run flag +case "${#}" in +0) + dry_run= + ;; +1) + if [[ "${1}" = --dry-run ]]; then dry_run=--dry-run - ;; - *) + else usage - ;; - esac -done -shift "$((OPTIND - 1))" + fi + ;; +*) + usage + ;; +esac version_tag="v$(script/version)" revision="$(git rev-parse "${version_tag}")" -echo "==> 🧪 Updating mas homebrew-core formula to version tag ${version_tag} @ revision ${revision}" +printf $'==> 🧪%s Updating mas homebrew-core formula to version tag %s @ revision %s\n' "${dry_run:+ DRY RUN}" "${version_tag}" "${revision}" brew bump-formula-pr \ --tag "${version_tag}" \ From 3f3b84eaf4223c086ccbc28656be65834c3322c9 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 01:53:13 -0500 Subject: [PATCH 058/131] Incorporate fixes from 638/release-fixes by @phatblat. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 12 ++++++++++-- script/brew_core_update | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a40acf35..fbbcc2d5a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -66,17 +66,25 @@ jobs: runs-on: macos-15 needs: start steps: + - uses: actions/checkout@v4 + with: + # Include all history & tags for script/version + fetch-depth: 0 + ref: ${{github.event.release.tag_name}} + - name: ⤴️ Bump mas tap formula env: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | + brew tap mas-cli/tap brew bump-formula-pr \ --tag '${{github.event.release.tag_name}}' \ --revision "$(git rev-list -n 1 '${{github.event.release.tag_name}}')" \ + --no-fork \ + --no-browse \ + --online \ --strict \ --verbose \ - --online \ - --no-browse \ ${{needs.start.outputs.dry_run}} \ mas-cli/tap/mas diff --git a/script/brew_core_update b/script/brew_core_update index 5c41e1b7a..734667644 100755 --- a/script/brew_core_update +++ b/script/brew_core_update @@ -46,10 +46,10 @@ printf $'==> 🧪%s Updating mas homebrew-core formula to version tag %s @ revis brew bump-formula-pr \ --tag "${version_tag}" \ --revision "${revision}" \ - --strict \ + --fork-org mas-cli \ + --no-browse \ --online \ + --strict \ --verbose \ - --no-browse \ - --fork-org mas-cli \ ${dry_run} \ mas From 26b892b9f21fb1d09deef22845e02f115bb9667a Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:32:11 -0500 Subject: [PATCH 059/131] Improve URLs. Cleanup comments / documentation / spacing. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .editorconfig | 2 +- .gitattributes | 1 - .github/dependabot.yml | 2 +- .github/workflows/build-test.yml | 2 +- .hound.yml | 2 +- .yamllint.yml | 2 +- CODE_OF_CONDUCT.md | 4 ++-- CONTRIBUTING.md | 15 ++++++++------- README.md | 13 ++++++------- Tests/masTests/.swiftlint.yml | 1 - docs/style.md | 6 +++--- 11 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.editorconfig b/.editorconfig index 43131279a..2de4d4854 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,4 @@ -# http://editorconfig.org +# https://editorconfig.org root = true [*] diff --git a/.gitattributes b/.gitattributes index 0b591edf3..39e2514b6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ # Trailing spaces may be intentional in markdown documents, so these should not # be removed. -# https://gist.github.com/shaunlebron/746476e6e7a4d698b373 **/*.md whitespace=-blank-at-eol diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 254c41818..e2d80fc2c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,4 @@ -# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file --- version: 2 updates: diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index bdaedca9c..5a5e54301 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -26,7 +26,7 @@ jobs: # Prefixes all `run` commands with the following command to force them to run outside Rosetta. # https://github.com/actions/runner/issues/805#issuecomment-942784948 # https://github.com/rolpdog/cffi-mirror/blob/release-1.15/.github/workflows/ci.yaml#L81-L141 - # https://github.com/actions/virtual-environments/issues/2187#issuecomment-790507204 + # https://github.com/actions/runner-images/issues/2187#issuecomment-790507204 shell: arch -arm64 /bin/bash --noprofile --norc -eo pipefail {0} steps: diff --git a/.hound.yml b/.hound.yml index 79acba67b..c6167cf74 100644 --- a/.hound.yml +++ b/.hound.yml @@ -2,7 +2,7 @@ # .hound.yml # mas # -# http://help.houndci.com/configuration/swiftlint +# http://help.houndci.com/en/articles/2138528-swiftlint # --- fail_on_violations: false diff --git a/.yamllint.yml b/.yamllint.yml index d91890d7f..d7927e407 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -13,5 +13,5 @@ rules: truthy: allowed-values: ["true", "false"] check-keys: false - # Disables false positives on GHA workflow `on:` + # Disable false positives on GHA workflow `on:` level: warning diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index e443d1d28..f23a387f4 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -68,9 +68,9 @@ members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at +available at [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see - + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16760d676..5a0cff024 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ We love pull requests from everyone. By participating in this project, you agree ## Getting Started -- Make sure you have a [GitHub account](https://github.com/join). +- Make sure you have a [GitHub account](https://github.com/signup). - [Open an issue](https://github.com/mas-cli/mas/issues/new) to simply ask a question or request a new feature. - Search for similar issues with the [ERROR MESSAGE](https://github.com/mas-cli/mas/issues?utf8=%E2%9C%93&q=is%3Aopen+ERROR+MESSAGE) @@ -25,17 +25,18 @@ you are experiencing. `git checkout -b awesome-feature main` - Please avoid working [directly on the main branch](https://softwareengineering.stackexchange.com/questions/223400/when-should-i-stop-committing-to-master-on-new-projects). - Make commits of logical units. -- Run script/format before committing your changes. Fix anything that isn't automatically fixed by the linters. +- Run `script/format` before committing. +- Run `script/lint` before committing. Fix all lint violations. - Push your topic branch to your fork and [submit a pull request](https://github.com/mas-cli/mas/compare/main...your-username:topic-branch). Some things that will increase the chance that your pull request is accepted: -- Write tests. (Tests target is still [in progress](https://github.com/mas-cli/mas/issues/123)) +- Write tests. - If you need help with tests, feel free to open a PR in the meantime and just ask for some help. - - Add "[WIP]" to the title of your PR to indicate that it's not ready to be merged. +- Add "[WIP]" to the title of your PR to indicate that it's not ready to be merged. - Follow our [style guide](docs/style.md). -- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). - - Including [appropriate emoji](https://gitmoji.carloscuesta.me/) in the first line of commit messages is fun :wink:. +- Write a [good commit message](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). + - Including [appropriate emoji](https://gitmoji.dev) in the first line of commit messages is fun :wink:. ## Becoming a Contributor @@ -50,7 +51,7 @@ to this project, but must remain an owner. By becoming a contributor, you agree ## Branching and Releases -- This project follows [trunk-based development](https://trunkbaseddevelopment.com/), where `main` is our trunk. +- This project follows [trunk-based development](https://trunkbaseddevelopment.com), where `main` is our trunk. - Release commits will be tagged in the format: `v1.2.3`. - Once releases are tagged, high-level release notes are published on the [releases](https://github.com/mas-cli/mas/releases) page. diff --git a/README.md b/README.md index bde16720e..4dfd0373c 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ A command-line interface for the Mac App Store. Designed for scripting and automation. -[![GitHub Release](https://img.shields.io/github/release/mas-cli/mas.svg)](https://github.com/mas-cli/mas/releases) +[![GitHub Release](https://img.shields.io/github/v/release/mas-cli/mas.svg)](https://github.com/mas-cli/mas/releases) [![Software License](https://img.shields.io/badge/license-MIT-lightgrey.svg)]( https://github.com/mas-cli/mas/blob/main/LICENSE ) -[![Swift 5](https://img.shields.io/badge/Language-Swift_5-orange.svg)](https://swift.org) +[![Swift 5](https://img.shields.io/badge/Language-Swift_5-orange.svg)](https://www.swift.org) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) [![Build, Test, & Lint](https://github.com/mas-cli/mas/actions/workflows/build-test.yml/badge.svg?branch=main)]( https://github.com/mas-cli/mas/actions/workflows/build-test.yml?query=branch%3Amain @@ -18,7 +18,7 @@ A command-line interface for the Mac App Store. Designed for scripting and autom ### 🍺 Homebrew -[Homebrew](http://brew.sh) is the preferred way to install: +[Homebrew](https://brew.sh) is the preferred way to install: ```shell brew install mas @@ -63,7 +63,7 @@ Without it, running mas might report errors similar to: To get Swift 5 support on macOS versions older than 10.14.4 (Mojave), you can: - Upgrade to macOS 10.14.4 (Mojave) or newer. -- Install the [Swift 5 Runtime Support for Command Line Tools](https://support.apple.com/kb/DL1998). +- Install the [Swift 5 Runtime Support for Command Line Tools](https://support.apple.com/en-us/106446). - Install Xcode 10.2 or newer to `/Applications/Xcode.app`. ## 🤳🏻 Usage @@ -80,8 +80,7 @@ Alternatively, to find an app's app ID: 1. Find the app in the Mac App Store 2. Select `Share` > `Copy Link` 3. Extract the app ID from the URL. e.g., the Mac App Store URL for Xcode, - [https://apps.apple.com/us/app/xcode/id497799835?mt=12](https://apps.apple.com/us/app/xcode/id497799835?mt=12), - has app ID `497799835` + , has app ID `497799835` ### 🛍 Info from the Mac App Store @@ -343,5 +342,5 @@ mas was created by [@argon](https://github.com/argon). Code is under the [MIT license](LICENSE). [homebrew-bundle]: https://github.com/Homebrew/homebrew-bundle -[`softwareupdate(8)`]: https://www.unix.com/man-page/osx/8/softwareupdate/ +[`softwareupdate(8)`]: https://www.unix.com/man-page/osx/8/softwareupdate [Quick]: https://github.com/Quick/Quick diff --git a/Tests/masTests/.swiftlint.yml b/Tests/masTests/.swiftlint.yml index dc0cbcd0a..bc2a00873 100644 --- a/Tests/masTests/.swiftlint.yml +++ b/Tests/masTests/.swiftlint.yml @@ -4,7 +4,6 @@ # # https://github.com/realm/SwiftLint#configuration # - --- disabled_rules: - force_cast diff --git a/docs/style.md b/docs/style.md index c0487ba64..27051611b 100644 --- a/docs/style.md +++ b/docs/style.md @@ -3,8 +3,8 @@ - Use `script/format` to automatically fix a number of style violations. - Remove unnecessary whitespace from the end of lines. - Use `script/lint` to look for these before committing. - - Note that [two trailing spaces](https://gist.github.com/shaunlebron/746476e6e7a4d698b373) - is intentional in markdown documents to create a line break like `
`, so these should _not_ be removed. + - Note that two trailing spaces is valid markdown to create a line break like `
`, + so those should _not_ be removed. - End each file with a [newline character]( https://unix.stackexchange.com/questions/18743/whats-the-point-in-adding-a-new-line-to-the-end-of-a-file#18789 ). @@ -13,7 +13,7 @@ [Sample](sample.swift) -- Avoid [force unwrapping optionals](https://blog.timac.org/2017/0628-swift-banning-force-unwrapping-optionals/) +- Avoid [force unwrapping optionals](https://blog.timac.org/2017/0628-swift-banning-force-unwrapping-optionals) with `!` in production code - Production code is what gets shipped with the app. Basically, everything under the [`Sources/mas`](https://github.com/mas-cli/mas/tree/main/Sources/mas) folder. From c15c6a2a8a0b9a6ee82c2102328515a3ddd6a18d Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:58:28 -0500 Subject: [PATCH 060/131] `release.yml`: Sanitize version tag input by using environment variable. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fbbcc2d5a..8ad751510 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,9 +28,10 @@ jobs: echo $'release.body: \n${{github.event.release.body}}' - id: pre_release + env: + RELEASE_TAG: ${{github.event.release.tag_name}} run: | - printf $'PRE_RELEASE=%s\n' "$([[ '${{github.event.release.tag_name}}' == *-* ]] && echo true || echo false)" \ - >>"${GITHUB_OUTPUT}" + printf $'PRE_RELEASE=%s\n' "$([[ "${RELEASE_TAG}" == *-* ]] && echo true || echo false)" >>"${GITHUB_OUTPUT}" pkg-installer: runs-on: macos-15 @@ -59,8 +60,9 @@ jobs: if: ${{!needs.start.outputs.dry_run}} env: GH_TOKEN: ${{github.token}} + RELEASE_TAG: ${{github.event.release.tag_name}} run: | - gh release upload '${{github.event.release.tag_name}}' .build/mas.pkg + gh release upload "${RELEASE_TAG}" .build/mas.pkg homebrew-tap: runs-on: macos-15 @@ -75,11 +77,12 @@ jobs: - name: ⤴️ Bump mas tap formula env: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} + RELEASE_TAG: ${{github.event.release.tag_name}} run: | brew tap mas-cli/tap brew bump-formula-pr \ - --tag '${{github.event.release.tag_name}}' \ - --revision "$(git rev-list -n 1 '${{github.event.release.tag_name}}')" \ + --tag "${RELEASE_TAG}" \ + --revision "$(git rev-list -n 1 "${RELEASE_TAG}")" \ --no-fork \ --no-browse \ --online \ From 659bf2e2404cd36797c0b76680819d33f9b9f0bf Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:12:29 -0500 Subject: [PATCH 061/131] `release.yml`: Move `RELEASE_TAG` environment variable to top level. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ad751510..9567e9d1a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,8 @@ defaults: on: release: types: [published] +env: + RELEASE_TAG: ${{github.event.release.tag_name}} jobs: start: runs-on: macos-15 @@ -23,13 +25,11 @@ jobs: run: | echo 'Triggered by a release publication event (wet run)' echo 'release.name: ${{github.event.release.name}}' - echo 'release.tag_name: ${{github.event.release.tag_name}}' + echo "release.tag_name: ${RELEASE_TAG}" echo 'release.target_commitish: ${{github.event.release.target_commitish}}' echo $'release.body: \n${{github.event.release.body}}' - id: pre_release - env: - RELEASE_TAG: ${{github.event.release.tag_name}} run: | printf $'PRE_RELEASE=%s\n' "$([[ "${RELEASE_TAG}" == *-* ]] && echo true || echo false)" >>"${GITHUB_OUTPUT}" @@ -41,7 +41,7 @@ jobs: with: # Include all history & tags for script/version fetch-depth: 0 - ref: ${{github.event.release.tag_name}} + ref: ${{env.RELEASE_TAG}} - name: 👢 Bootstrap run: | @@ -60,7 +60,6 @@ jobs: if: ${{!needs.start.outputs.dry_run}} env: GH_TOKEN: ${{github.token}} - RELEASE_TAG: ${{github.event.release.tag_name}} run: | gh release upload "${RELEASE_TAG}" .build/mas.pkg @@ -72,12 +71,11 @@ jobs: with: # Include all history & tags for script/version fetch-depth: 0 - ref: ${{github.event.release.tag_name}} + ref: ${{env.RELEASE_TAG}} - name: ⤴️ Bump mas tap formula env: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} - RELEASE_TAG: ${{github.event.release.tag_name}} run: | brew tap mas-cli/tap brew bump-formula-pr \ @@ -100,7 +98,7 @@ jobs: with: # Include all history & tags for script/version fetch-depth: 0 - ref: ${{github.event.release.tag_name}} + ref: ${{env.RELEASE_TAG}} - name: 👢 Bootstrap run: | From 686489a3b670afb3d977b595d83e728092b478a1 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:15:21 -0500 Subject: [PATCH 062/131] `release.yml`: Improve step names. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9567e9d1a..94e3dbc7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: dry_run: "" pre_release: ${{steps.pre_release.outputs.pre_release}} steps: - - name: 🔈 Log release event + - name: 🔈 Log real release event # Run only for a real release event if: ${{github.event.release.name != ''}} run: | @@ -37,7 +37,8 @@ jobs: runs-on: macos-15 needs: start steps: - - uses: actions/checkout@v4 + - name: 📺 Checkout mas repo + uses: actions/checkout@v4 with: # Include all history & tags for script/version fetch-depth: 0 @@ -47,12 +48,11 @@ jobs: run: | script/bootstrap -f - # Run a universal build to produce mas binary for package - - name: 🏗️ Build Universal + - name: 🏗️ Build universal executable run: | script/build --universal - - name: 📦 macOS Package + - name: 📦 Package mas.pkg run: | script/package @@ -67,13 +67,14 @@ jobs: runs-on: macos-15 needs: start steps: - - uses: actions/checkout@v4 + - name: 📺 Checkout mas repo + uses: actions/checkout@v4 with: # Include all history & tags for script/version fetch-depth: 0 ref: ${{env.RELEASE_TAG}} - - name: ⤴️ Bump mas tap formula + - name: 🚰 Bump mas-cli/tap/mas formula env: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | @@ -94,7 +95,8 @@ jobs: runs-on: macos-15 needs: [start, homebrew-tap] steps: - - uses: actions/checkout@v4 + - name: 📺 Checkout mas repo + uses: actions/checkout@v4 with: # Include all history & tags for script/version fetch-depth: 0 @@ -104,7 +106,7 @@ jobs: run: | script/bootstrap -f - - name: 🍺 Update homebrew-core mas formula + - name: 🍺 Bump homebrew-core/mas formula env: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | From d80b898b90e1f3867b14f078dbcd299973532fa3 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:19:07 -0500 Subject: [PATCH 063/131] =?UTF-8?q?`release.yml`:=20Change=20`start`=20job?= =?UTF-8?q?=20`=F0=9F=94=88=20Log=20real=20release=20event`=20step=20if=20?= =?UTF-8?q?condition.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 94e3dbc7d..bd5483c1a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: steps: - name: 🔈 Log real release event # Run only for a real release event - if: ${{github.event.release.name != ''}} + if: ${{github.event.release.name}} run: | echo 'Triggered by a release publication event (wet run)' echo 'release.name: ${{github.event.release.name}}' From ec9a95e00f89248a4ffdd92cf0bb2705c15f92e2 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:32:23 -0500 Subject: [PATCH 064/131] `release.yml`: Use environment variables top prevent code injection attacks / accidents. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd5483c1a..865b24f5f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,12 +22,13 @@ jobs: - name: 🔈 Log real release event # Run only for a real release event if: ${{github.event.release.name}} + env: + RELEASE_NAME: ${{github.event.release.name}} + RELEASE_COMMITISH: ${{github.event.release.target_commitish}} + RELEASE_BODY: ${{github.event.release.body}} run: | - echo 'Triggered by a release publication event (wet run)' - echo 'release.name: ${{github.event.release.name}}' - echo "release.tag_name: ${RELEASE_TAG}" - echo 'release.target_commitish: ${{github.event.release.target_commitish}}' - echo $'release.body: \n${{github.event.release.body}}' + printf $'Triggered by release publication event:\nname: %s\ntag_name: %s\ntarget_commitish: %s\nbody:\n%s\n' \ + "${RELEASE_NAME}" "${RELEASE_TAG}" "${RELEASE_COMMITISH}" "${RELEASE_BODY}" - id: pre_release run: | From a7f89f6b7c1c6ffaad04ebdb377818197ba25b48 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:37:38 -0500 Subject: [PATCH 065/131] `release.yml`: Use `DRY_RUN` top-level environment variable instead of an output from `start` job. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 865b24f5f..ec659b84c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,12 +11,12 @@ on: release: types: [published] env: + DRY_RUN: "" RELEASE_TAG: ${{github.event.release.tag_name}} jobs: start: runs-on: macos-15 outputs: - dry_run: "" pre_release: ${{steps.pre_release.outputs.pre_release}} steps: - name: 🔈 Log real release event @@ -58,7 +58,7 @@ jobs: script/package - name: 🚀 Upload mas.pkg - if: ${{!needs.start.outputs.dry_run}} + if: ${{!env.DRY_RUN}} env: GH_TOKEN: ${{github.token}} run: | @@ -88,7 +88,7 @@ jobs: --online \ --strict \ --verbose \ - ${{needs.start.outputs.dry_run}} \ + ${DRY_RUN} \ mas-cli/tap/mas homebrew-core: @@ -111,4 +111,4 @@ jobs: env: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | - script/brew_core_update ${{needs.start.outputs.dry_run}} + script/brew_core_update ${DRY_RUN} From 823d4f0c5a317e0f122cafa9a8a86585219b17f2 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 20:40:49 -0500 Subject: [PATCH 066/131] `release.yml`: Use `!contains(env.RELEASE_TAG, '-')` instead of a `pre_release` output from `start` job. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec659b84c..6f28b5411 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,8 +16,6 @@ env: jobs: start: runs-on: macos-15 - outputs: - pre_release: ${{steps.pre_release.outputs.pre_release}} steps: - name: 🔈 Log real release event # Run only for a real release event @@ -30,10 +28,6 @@ jobs: printf $'Triggered by release publication event:\nname: %s\ntag_name: %s\ntarget_commitish: %s\nbody:\n%s\n' \ "${RELEASE_NAME}" "${RELEASE_TAG}" "${RELEASE_COMMITISH}" "${RELEASE_BODY}" - - id: pre_release - run: | - printf $'PRE_RELEASE=%s\n' "$([[ "${RELEASE_TAG}" == *-* ]] && echo true || echo false)" >>"${GITHUB_OUTPUT}" - pkg-installer: runs-on: macos-15 needs: start @@ -92,9 +86,10 @@ jobs: mas-cli/tap/mas homebrew-core: - if: ${{needs.start.outputs.pre_release == 'false'}} + # Bump homebrew-core/mas formula only if not a prerelease; all prerelease versions contain a '-' + if: ${{!contains(env.RELEASE_TAG, '-')}} runs-on: macos-15 - needs: [start, homebrew-tap] + needs: homebrew-tap steps: - name: 📺 Checkout mas repo uses: actions/checkout@v4 From e24f52472a26f527839dc8b9758d746d86a56c57 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:23:39 -0500 Subject: [PATCH 067/131] =?UTF-8?q?`release.yml`:=20Remove=20unnecessary?= =?UTF-8?q?=20`=F0=9F=91=A2=20Bootstrap`=20step=20from=20`homebrew-core`?= =?UTF-8?q?=20job.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6f28b5411..396f5fbdc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -98,10 +98,6 @@ jobs: fetch-depth: 0 ref: ${{env.RELEASE_TAG}} - - name: 👢 Bootstrap - run: | - script/bootstrap -f - - name: 🍺 Bump homebrew-core/mas formula env: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} From 514b93ebc6dd7ec6b528366425bd55b0ee1b88b6 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:27:24 -0500 Subject: [PATCH 068/131] `release.yml`: Change `homebrew-tap.needs` from `start` to `pkg-installer` to ensure that custom tap isn't bumped if the package installer wasn't uploaded to the GitHub release. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 396f5fbdc..d677ecb8f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,7 +60,7 @@ jobs: homebrew-tap: runs-on: macos-15 - needs: start + needs: pkg-installer steps: - name: 📺 Checkout mas repo uses: actions/checkout@v4 From 902ab83db68c3daac331e176ae284b9ea6e3fea6 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:38:37 -0500 Subject: [PATCH 069/131] `release.yml`: Combine all separate jobs into one single job to simplify & speedup workflow. Move all environment variables to the top level. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 49 +++++++---------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d677ecb8f..34f4ced4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,26 +12,23 @@ on: types: [published] env: DRY_RUN: "" + GH_TOKEN: ${{github.token}} + HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} + RELEASE_BODY: ${{github.event.release.body}} + RELEASE_COMMITISH: ${{github.event.release.target_commitish}} + RELEASE_NAME: ${{github.event.release.name}} RELEASE_TAG: ${{github.event.release.tag_name}} jobs: - start: + release: runs-on: macos-15 steps: - name: 🔈 Log real release event # Run only for a real release event - if: ${{github.event.release.name}} - env: - RELEASE_NAME: ${{github.event.release.name}} - RELEASE_COMMITISH: ${{github.event.release.target_commitish}} - RELEASE_BODY: ${{github.event.release.body}} + if: ${{env.RELEASE_NAME}} run: | printf $'Triggered by release publication event:\nname: %s\ntag_name: %s\ntarget_commitish: %s\nbody:\n%s\n' \ "${RELEASE_NAME}" "${RELEASE_TAG}" "${RELEASE_COMMITISH}" "${RELEASE_BODY}" - pkg-installer: - runs-on: macos-15 - needs: start - steps: - name: 📺 Checkout mas repo uses: actions/checkout@v4 with: @@ -53,25 +50,10 @@ jobs: - name: 🚀 Upload mas.pkg if: ${{!env.DRY_RUN}} - env: - GH_TOKEN: ${{github.token}} run: | gh release upload "${RELEASE_TAG}" .build/mas.pkg - homebrew-tap: - runs-on: macos-15 - needs: pkg-installer - steps: - - name: 📺 Checkout mas repo - uses: actions/checkout@v4 - with: - # Include all history & tags for script/version - fetch-depth: 0 - ref: ${{env.RELEASE_TAG}} - - name: 🚰 Bump mas-cli/tap/mas formula - env: - HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | brew tap mas-cli/tap brew bump-formula-pr \ @@ -85,21 +67,8 @@ jobs: ${DRY_RUN} \ mas-cli/tap/mas - homebrew-core: - # Bump homebrew-core/mas formula only if not a prerelease; all prerelease versions contain a '-' - if: ${{!contains(env.RELEASE_TAG, '-')}} - runs-on: macos-15 - needs: homebrew-tap - steps: - - name: 📺 Checkout mas repo - uses: actions/checkout@v4 - with: - # Include all history & tags for script/version - fetch-depth: 0 - ref: ${{env.RELEASE_TAG}} - - name: 🍺 Bump homebrew-core/mas formula - env: - HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} + # Bump homebrew-core/mas formula only if not a prerelease; all prerelease versions contain a '-' + if: ${{!contains(env.RELEASE_TAG, '-')}} run: | script/brew_core_update ${DRY_RUN} From 9968bcd148963f7e02113bb57d668d294b716da5 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 19 Nov 2024 02:52:10 -0500 Subject: [PATCH 070/131] Replace `echo` with `printf` in bash scripts. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 3 +-- script/build | 3 ++- script/build_artifacts | 2 +- script/package | 4 ++-- script/package_install | 2 +- script/uninstall | 2 +- script/update_headers | 3 +-- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index d9c7064fe..e0c55b665 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -14,8 +14,7 @@ if ! cd -- "${mas_dir}"; then fi function usage { - echo 'Usage: bootstrap [-f]' >&2 - echo ' -f option enables frozen mode' >&2 + printf $'Usage: bootstrap [-f]\n -f option enables frozen mode\n' >&2 exit 1 } diff --git a/script/build b/script/build index bae69ba40..53b9e596d 100755 --- a/script/build +++ b/script/build @@ -32,7 +32,8 @@ fi script/generate_version_info_for_swift -echo "==> 🏗️ Building mas $(script/version)" +printf $'==> 🏗️ Building mas %s\n' "$(script/version)" + swift build \ --configuration release \ "${arch[@]+"${arch[@]}"}" \ diff --git a/script/build_artifacts b/script/build_artifacts index d81148b37..42ca333e8 100755 --- a/script/build_artifacts +++ b/script/build_artifacts @@ -13,7 +13,7 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -echo "==> 👑 Building mas $(script/version) artifacts" +printf $'==> 👑 Building mas %s artifacts\n' "$(script/version)" script/clean script/build --universal diff --git a/script/package b/script/package index 58773376e..56c67eb53 100755 --- a/script/package +++ b/script/package @@ -22,7 +22,7 @@ script/install "${dstroot}/usr/local" --universal version="$(script/version)" -echo "==> 📦 Assembling installer package for mas ${version}" +printf $'==> 📦 Assembling installer package for mas %s\n' "${version}" # Assemble macOS installer component package (aka 'product archive'). pkgbuild \ @@ -39,5 +39,5 @@ productbuild \ --package-path "${build_dir}" \ "${distribution_package}" -echo '==> 🔢 File Hash' +printf $'==> 🔢 File Hash\n' shasum -a 256 "${distribution_package}" diff --git a/script/package_install b/script/package_install index 524f1b814..96c84219a 100755 --- a/script/package_install +++ b/script/package_install @@ -15,7 +15,7 @@ fi identifier=com.mphys.mas-cli -echo '==> 📲 Installing mas' +printf $'==> 📲 Installing mas\n' sudo installer \ -pkg .build/mas.pkg \ diff --git a/script/uninstall b/script/uninstall index 6c7536ece..a2abdfd86 100755 --- a/script/uninstall +++ b/script/uninstall @@ -16,6 +16,6 @@ fi # Override default prefix path with optional 1st arg prefix="${1:-"$(brew --prefix)"}" -echo "==> 🔥 Uninstalling mas from ${prefix}" +printf $'==> 🔥 Uninstalling mas from %s\n' "${prefix}" trash -F "${prefix}/bin/mas" || true diff --git a/script/update_headers b/script/update_headers index d0f2d018a..beb3a3c68 100755 --- a/script/update_headers +++ b/script/update_headers @@ -14,8 +14,7 @@ if ! cd -- "${mas_dir}"; then fi if ! command -v class-dump >/dev/null; then - echo 'class-dump is not installed.' >&2 - echo 'Download from http://stevenygard.com/projects/class-dump/' >&2 + printf $'class-dump is not installed.\nDownload from http://stevenygard.com/projects/class-dump/\n' >&2 exit 1 fi From 47c07d13763f99285860478e85bfa53e3f0e3746 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 19 Nov 2024 02:35:13 -0500 Subject: [PATCH 071/131] Delete `script/brew_core_update` & move its `homebrew-core/mas` bump into `release.yml`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run `git rev-parse …` instead of `git rev-list -n 1 …` for mas-cli/tap/mas. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 13 +++++++-- script/brew_core_update | 55 ----------------------------------- 2 files changed, 11 insertions(+), 57 deletions(-) delete mode 100755 script/brew_core_update diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34f4ced4d..1b84c43d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -58,7 +58,7 @@ jobs: brew tap mas-cli/tap brew bump-formula-pr \ --tag "${RELEASE_TAG}" \ - --revision "$(git rev-list -n 1 "${RELEASE_TAG}")" \ + --revision "$(git rev-parse "${RELEASE_TAG}")" \ --no-fork \ --no-browse \ --online \ @@ -71,4 +71,13 @@ jobs: # Bump homebrew-core/mas formula only if not a prerelease; all prerelease versions contain a '-' if: ${{!contains(env.RELEASE_TAG, '-')}} run: | - script/brew_core_update ${DRY_RUN} + brew bump-formula-pr \ + --tag "${RELEASE_TAG}" \ + --revision "$(git rev-parse "${RELEASE_TAG}")" \ + --fork-org mas-cli \ + --no-browse \ + --online \ + --strict \ + --verbose \ + ${DRY_RUN} \ + mas diff --git a/script/brew_core_update b/script/brew_core_update deleted file mode 100755 index 734667644..000000000 --- a/script/brew_core_update +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -e -# -# script/brew_core_update -# mas -# -# Updates mas Homebrew core formula: -# https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb -# -# brew bump-formula-pr --help -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -function usage { - printf $'Usage: brew_core_update [--dry-run]\n --dry-run flag enables dry run mode\n' >&2 - exit 1 -} - -# Parse arguments for --dry-run flag -case "${#}" in -0) - dry_run= - ;; -1) - if [[ "${1}" = --dry-run ]]; then - dry_run=--dry-run - else - usage - fi - ;; -*) - usage - ;; -esac - -version_tag="v$(script/version)" -revision="$(git rev-parse "${version_tag}")" - -printf $'==> 🧪%s Updating mas homebrew-core formula to version tag %s @ revision %s\n' "${dry_run:+ DRY RUN}" "${version_tag}" "${revision}" - -brew bump-formula-pr \ - --tag "${version_tag}" \ - --revision "${revision}" \ - --fork-org mas-cli \ - --no-browse \ - --online \ - --strict \ - --verbose \ - ${dry_run} \ - mas From 09c1abfe959efa49412311e34d907b2115572fcd Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 19 Nov 2024 03:33:00 -0500 Subject: [PATCH 072/131] Delete `Makefile` & seemingly unused bash scripts. Remove `trash` dependency. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .editorconfig | 3 - Brewfile | 1 - Brewfile.lock.json | 69 --------------- Makefile | 158 ---------------------------------- script/brew_build_interactive | 18 ---- script/brew_release_validate | 21 ----- script/build_artifacts | 20 ----- script/package_install | 26 ------ script/uninstall | 21 ----- 9 files changed, 337 deletions(-) delete mode 100644 Makefile delete mode 100755 script/brew_build_interactive delete mode 100755 script/brew_release_validate delete mode 100755 script/build_artifacts delete mode 100755 script/package_install delete mode 100755 script/uninstall diff --git a/.editorconfig b/.editorconfig index 2de4d4854..653f5cbd0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -22,9 +22,6 @@ indent_style = tab [*.yml] indent_size = 2 -[Makefile] -indent_style = tab - [script/*] indent_size = 2 max_line_length = 80 diff --git a/Brewfile b/Brewfile index 693f5cd22..c449f179c 100644 --- a/Brewfile +++ b/Brewfile @@ -5,7 +5,6 @@ brew "shellcheck" brew "shfmt" brew "swift-format" brew "swiftformat" -brew "trash" brew "yamllint" if OS.mac? && MacOS.version >= :ventura diff --git a/Brewfile.lock.json b/Brewfile.lock.json index 05b809322..1836c9f35 100644 --- a/Brewfile.lock.json +++ b/Brewfile.lock.json @@ -206,75 +206,6 @@ } } }, - "trash": { - "version": "0.9.2", - "bottle": { - "rebuild": 1, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:f3b7a766bcc683b339c145ab7d8b484f2bbd65aac6903fd952dec7f4521efe5f", - "sha256": "f3b7a766bcc683b339c145ab7d8b484f2bbd65aac6903fd952dec7f4521efe5f" - }, - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:90cffd3d151720b768c48a8874f7b8dfaaf6f7a9e9000ffe23cfa3f9e4aa6b76", - "sha256": "90cffd3d151720b768c48a8874f7b8dfaaf6f7a9e9000ffe23cfa3f9e4aa6b76" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:60186a8823abc9dd734475e3f787edd7c2d6a2254fff25b7289de2db15447099", - "sha256": "60186a8823abc9dd734475e3f787edd7c2d6a2254fff25b7289de2db15447099" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:541af91d1cb128aa743460a529a3dcab5bac63b61ccde0a60d73aee23ab7d5c0", - "sha256": "541af91d1cb128aa743460a529a3dcab5bac63b61ccde0a60d73aee23ab7d5c0" - }, - "arm64_big_sur": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:11c0c85ec692ea6d4a125070f0a6ca576aff991608a6c9632b984cbf983e2481", - "sha256": "11c0c85ec692ea6d4a125070f0a6ca576aff991608a6c9632b984cbf983e2481" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:c26e06202022f708790f22f4477b65e3337d611c42e9a814ada1526bda03d923", - "sha256": "c26e06202022f708790f22f4477b65e3337d611c42e9a814ada1526bda03d923" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:539093ca74c72ed8be974fd9042b14f55cde0ef2c1fadbedc7343099a394593e", - "sha256": "539093ca74c72ed8be974fd9042b14f55cde0ef2c1fadbedc7343099a394593e" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:09b8ac7ade28ca59bd578b90680ece838a507b90b35e44d06a16f4d8ab9ae6e6", - "sha256": "09b8ac7ade28ca59bd578b90680ece838a507b90b35e44d06a16f4d8ab9ae6e6" - }, - "big_sur": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:403ba52ce97d38535e1d127ca227afd4ea2d0e0c8b414118dbc5376c9ed8f094", - "sha256": "403ba52ce97d38535e1d127ca227afd4ea2d0e0c8b414118dbc5376c9ed8f094" - }, - "catalina": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:b452d67cdeeb52db0aaadd258bc3e214a5ea5ed37da698b45017b01457115ea6", - "sha256": "b452d67cdeeb52db0aaadd258bc3e214a5ea5ed37da698b45017b01457115ea6" - }, - "mojave": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:d8ad5460b24a51a4a12b31ebf1a2887e9e86e029d061f6994c3c1caea7bf0551", - "sha256": "d8ad5460b24a51a4a12b31ebf1a2887e9e86e029d061f6994c3c1caea7bf0551" - }, - "high_sierra": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/trash/blobs/sha256:0ef5ea924ba8d01398686657a839ad270796f3f10eee86d6522980d32038df9a", - "sha256": "0ef5ea924ba8d01398686657a839ad270796f3f10eee86d6522980d32038df9a" - } - } - } - }, "yamllint": { "version": "1.35.1", "bottle": { diff --git a/Makefile b/Makefile deleted file mode 100644 index 9e088518a..000000000 --- a/Makefile +++ /dev/null @@ -1,158 +0,0 @@ -# -# Makefile -# mas -# - -################################################################################ -# -# Variables -# - -CMD_NAME = mas -SHELL = /bin/sh -PREFIX ?= $(shell brew --prefix) - -SWIFT_VERSION = 5.7.1 - -# set EXECUTABLE_DIRECTORY according to your specific environment -# run swift build and see where the output executable is created - -# OS specific differences -ifeq ($(shell uname), Darwin) -PLATFORM = $(shell uname -m)-apple-macosx -EXECUTABLE_DIRECTORY = ./.build/${PLATFORM}/debug -endif - -################################################################################ -# -# Help -# - -.DEFAULT_GOAL := help - -.PHONY: help -help: MAKEFILE_FMT = " \033[36m%-25s\033[0m%s\n" -help: ## (default) Displays this message - @echo "mas Makefile" - @echo "" - @echo "Targets:" - @grep -E '^[a-zA-Z0-9_-]*:.*?##' ${MAKEFILE_LIST} | awk 'BEGIN {FS = ":.*?##"}; {printf ${MAKEFILE_FMT}, $$1, $$2}' -: # Hacky way to display a newline ## - -################################################################################ -# -# ℹ️ Info Targets -# - -.PHONY: version -version: ## Prints versions of tools used by this Makefile. - xcodebuild -version - swiftenv version - swift --version - swift package tools-version - -.PHONY: init -init: ## Installs tools. - - swiftenv install ${SWIFT_VERSION} - swiftenv local ${SWIFT_VERSION} - -################################################################################ -# -# 👢 Bootstrap -# - -.PHONY: bootstrap -bootstrap: ## Installs tools. - script/bootstrap -f - -.PHONY: bootstrap-update -bootstrap-update: ## Upgrades and installs tools. - script/bootstrap - -################################################################################ -# -# 👩🏻‍💻 Development Targets -# - -.PHONY: clean -clean: ## Cleans built products. - script/clean - -.PHONY: lint -lint: ## Lints source code. - script/lint - -.PHONY: format -format: ## Formats source code. - script/format - -.PHONY: build -build: ## Builds the project. - script/build - -.PHONY: test -test: build ## Runs tests. - script/test - -# make run ARGS="asdf" -.PHONY: run -run: build - ${EXECUTABLE_DIRECTORY}/${CMD_NAME} ${ARGS} - -.PHONY: update-headers -update-headers: ## Updates private macOS headers. - script/update_headers - -################################################################################ -# -# 🕊️ Swift Package Targets -# - -.PHONY: describe -describe: ## Describes the Swift package. - swift package describe - -.PHONY: resolve -resolve: ## Resolves SwiftPM dependencies. - swift package resolve - -.PHONY: dependencies -dependencies: resolve ## Lists SwiftPM dependencies. - swift package show-dependencies - -.PHONY: update -update: resolve ## Updates SwiftPM dependencies. - swift package update - -################################################################################ -# -# 🚀 Release Targets -# - -.PHONY: build-universal -build-universal: ## Builds a "fat" universal binary. - script/build --universal - -.PHONY: install -install: build ## Installs the binary. - script/install ${PREFIX} - -.PHONY: install-universal -install-universal: build-universal ## Installs a universal binary. - script/install --universal ${PREFIX} - -.PHONY: uninstall -uninstall: ## Uninstalls the binary. - script/uninstall - -.PHONY: package -package: build ## Packages the project. - script/package - -.PHONY: package-install -package-install: package ## Installs the package. - script/package_install - -.PHONY: brew_release_validate -brew_release_validate: ## Validates Homebrew mas formula. - script/brew_release_validate diff --git a/script/brew_build_interactive b/script/brew_build_interactive deleted file mode 100755 index d93a039ba..000000000 --- a/script/brew_build_interactive +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -e -# -# script/brew_build_interactive -# mas -# -# https://docs.brew.sh/Formula-Cookbook#check-the-build-system -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -HOMEBREW_NO_INSTALL_FROM_API=1 \ - brew reinstall \ - --interactive mas diff --git a/script/brew_release_validate b/script/brew_release_validate deleted file mode 100755 index abb51e101..000000000 --- a/script/brew_release_validate +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# script/brew_release_validate -# mas -# -# Validates the mas formula -# https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md#to-contribute-a-fix-to-the-foo-formula -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -brew uninstall --force mas -brew install --build-from-source mas -brew test mas -brew audit --strict mas -brew style mas diff --git a/script/build_artifacts b/script/build_artifacts deleted file mode 100755 index 42ca333e8..000000000 --- a/script/build_artifacts +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -e -# -# script/build_artifacts -# mas -# -# Runs all related scripts for generating all artifacts. -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -printf $'==> 👑 Building mas %s artifacts\n' "$(script/version)" - -script/clean -script/build --universal -script/package diff --git a/script/package_install b/script/package_install deleted file mode 100755 index 96c84219a..000000000 --- a/script/package_install +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -e -# -# script/package_install -# mas -# -# Installs the mas distribution package. Requires sudo access. -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -identifier=com.mphys.mas-cli - -printf $'==> 📲 Installing mas\n' - -sudo installer \ - -pkg .build/mas.pkg \ - -target / - -pkgutil --pkg-info "${identifier}" - -pkgutil --files "${identifier}" diff --git a/script/uninstall b/script/uninstall deleted file mode 100755 index a2abdfd86..000000000 --- a/script/uninstall +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -e -# -# script/uninstall -# mas -# -# Removes mas from a bin folder under a prefix folder, defaulting to /usr/local. -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -# Override default prefix path with optional 1st arg -prefix="${1:-"$(brew --prefix)"}" - -printf $'==> 🔥 Uninstalling mas from %s\n' "${prefix}" - -trash -F "${prefix}/bin/mas" || true From 1ef95d0791d48cd85fdc4998dff891e5bd2c3f72 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 19 Nov 2024 03:35:25 -0500 Subject: [PATCH 073/131] Delete `script/install`. Requires corresponding commits to `homebrew-core/mas` & `mas-cli/tap/mas` formulae. Rename `dstroot` variable as `distributions_root` in `script/package`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/install | 39 --------------------------------------- script/package | 10 ++++------ 2 files changed, 4 insertions(+), 45 deletions(-) delete mode 100755 script/install diff --git a/script/install b/script/install deleted file mode 100755 index 32b74ba64..000000000 --- a/script/install +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -e -# -# script/install -# mas -# -# Install mas into a bin folder under a prefix folder, defaulting to /usr/local. -# -# NOTE: This script is run by the mas Homebrew formula, so, aside from Swift, it -# may only depend on system dependencies. -# -# https://github.com/Homebrew/homebrew-core/blob/master/Formula/m/mas.rb -# - -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi - -arch="$(uname -m)" -release=".build/${arch}-apple-macosx/release" -prefix=/usr/local - -while [[ -n "${1}" ]]; do - if [[ "${1}" == '--universal' ]]; then - arch=universal - release=.build/apple/Products/Release - else - prefix="${1}" - fi - - shift -done - -printf $'==> 📲 Installing mas %s for %s to %s\n' \ - "$(script/version)" "${arch}" "${prefix}" - -ditto -v "${release}/mas" "${prefix}/bin/mas" diff --git a/script/package b/script/package index 56c67eb53..76cf3d697 100755 --- a/script/package +++ b/script/package @@ -15,13 +15,11 @@ fi build_dir=.build distribution_package="${build_dir}/mas.pkg" - -# Destination for install root -dstroot="${build_dir}/distributions" -script/install "${dstroot}/usr/local" --universal - +distributions_root="${build_dir}/distributions" version="$(script/version)" +ditto -v "${build_dir}/apple/Products/Release/mas" "${distributions_root}/usr/local/bin/mas" + printf $'==> 📦 Assembling installer package for mas %s\n' "${version}" # Assemble macOS installer component package (aka 'product archive'). @@ -29,7 +27,7 @@ pkgbuild \ --identifier com.mphys.mas-cli \ --install-location '/' \ --version "${version}" \ - --root "${dstroot}" \ + --root "${distributions_root}" \ "${build_dir}/mas_components.pkg" # Build distribution package (aka 'product archive'). Not sure why, but this is how Carthage does it. From 4ae40a9acd262927d2a25d274abc8668ed70af17 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 19 Nov 2024 06:54:07 -0500 Subject: [PATCH 074/131] Ensure bash scripts don't use unset variables. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/clean | 2 +- script/package | 2 +- script/update_headers | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/script/clean b/script/clean index d08285bdb..faa3d68a0 100755 --- a/script/clean +++ b/script/clean @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -eu # # script/clean # mas diff --git a/script/package b/script/package index 76cf3d697..d5183dd0d 100755 --- a/script/package +++ b/script/package @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -eu # # script/package # mas diff --git a/script/update_headers b/script/update_headers index beb3a3c68..c3b4ccc63 100755 --- a/script/update_headers +++ b/script/update_headers @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -eu # # script/update_headers # mas From b6613bb1ba8b2015ff106e3cbd1c6ead83e65f8e Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 19 Nov 2024 07:10:37 -0500 Subject: [PATCH 075/131] Update `actions/checkout@v4` settings: Should only release revisions that have version tags on them, so should only need a single commit. `ref:` should default to the reference for the event, which should be `github.event.release.tag_name`, so shouldn't need to explicitly set it. If any of these changes cause problems, will back them out. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b84c43d5..ac663a253 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,10 +31,6 @@ jobs: - name: 📺 Checkout mas repo uses: actions/checkout@v4 - with: - # Include all history & tags for script/version - fetch-depth: 0 - ref: ${{env.RELEASE_TAG}} - name: 👢 Bootstrap run: | From 58fd1e190594e6e98f48111c47cdeb7933690bf3 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 19 Nov 2024 07:15:10 -0500 Subject: [PATCH 076/131] Improve script modularity: `script/package` calls `script/build --universal` instead of requiring the latter to be called before the former. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 6 +----- script/package | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ac663a253..afaaa0f37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,11 +36,7 @@ jobs: run: | script/bootstrap -f - - name: 🏗️ Build universal executable - run: | - script/build --universal - - - name: 📦 Package mas.pkg + - name: 📦 Build universal executable & package it in mas.pkg run: | script/package diff --git a/script/package b/script/package index d5183dd0d..fc299231f 100755 --- a/script/package +++ b/script/package @@ -18,6 +18,8 @@ distribution_package="${build_dir}/mas.pkg" distributions_root="${build_dir}/distributions" version="$(script/version)" +script/build --universal + ditto -v "${build_dir}/apple/Products/Release/mas" "${distributions_root}/usr/local/bin/mas" printf $'==> 📦 Assembling installer package for mas %s\n' "${version}" From fed396c072422941cf46d9bdf62937099aebc905 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Wed, 20 Nov 2024 03:17:26 -0500 Subject: [PATCH 077/131] No longer git ignore `Sources/MasKit/Package.swift` since the `MasKit` target has been merged into `mas` target. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2b6a070d7..820092c4b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ Carthage/ DerivedData Pods/ Sources/mas/Package.swift -Sources/MasKit/Package.swift Temporary Items bin/ build/ From befb45868f6902eaf3f7f2b5550bd5370e480992 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Wed, 20 Nov 2024 22:58:47 -0500 Subject: [PATCH 078/131] Cleanup Swift files. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Dangerfile.swift | 13 +++-- Sources/mas/AppStore/Downloader.swift | 4 +- Sources/mas/Commands/Upgrade.swift | 3 +- docs/sample.swift | 82 ++++++++++++++------------- 4 files changed, 56 insertions(+), 46 deletions(-) diff --git a/Dangerfile.swift b/Dangerfile.swift index c5e6345b2..52f5b4d8e 100644 --- a/Dangerfile.swift +++ b/Dangerfile.swift @@ -1,19 +1,24 @@ import Danger + let danger = Danger() -// Thanks other people! if let github = danger.github { + // Thank non-member submitters let submitter = github.pullRequest.user.login - if submitter != "phatblat" && submitter != "chris-araman" { + switch submitter { + case "chris-araman", + "phatblat": + break + default: danger.message(":tada: Thanks for your contribution, \(submitter)!") } - // Mainly to encourage writing up some reasoning about the PR, rather than just leaving a title + // Encourage writing up some reasoning about the PR if github.pullRequest.body?.count ?? 0 < 5 { danger.fail(":memo: Please provide a summary in the Pull Request description.") } - // Make it more obvious that a PR is a work in progress and shouldn't be merged yet + // Warn that PR marked [WIP] should be a Draft if github.pullRequest.title.contains("[WIP]") { danger.warn(":construction: Title includes `[WIP]`. Please convert the pull request to a Draft.") } diff --git a/Sources/mas/AppStore/Downloader.swift b/Sources/mas/AppStore/Downloader.swift index 5ec5d6178..b1e7216b4 100644 --- a/Sources/mas/AppStore/Downloader.swift +++ b/Sources/mas/AppStore/Downloader.swift @@ -65,8 +65,8 @@ func downloadApps(withAppIDs appIDs: [AppID], purchasing: Bool = false) -> Promi } } .done { - if let error = firstError { - throw error + if let firstError { + throw firstError } } } diff --git a/Sources/mas/Commands/Upgrade.swift b/Sources/mas/Commands/Upgrade.swift index 3f1d3f414..fb30be4c8 100644 --- a/Sources/mas/Commands/Upgrade.swift +++ b/Sources/mas/Commands/Upgrade.swift @@ -14,8 +14,7 @@ extension MAS { /// Command which upgrades apps with new versions available in the Mac App Store. struct Upgrade: ParsableCommand { static let configuration = CommandConfiguration( - abstract: - "Upgrade outdated app(s) installed from the Mac App Store" + abstract: "Upgrade outdated app(s) installed from the Mac App Store" ) @Argument(help: ArgumentHelp("App ID/app name", valueName: "app-id-or-name")) diff --git a/docs/sample.swift b/docs/sample.swift index 17fc5d450..4e1acb7d2 100644 --- a/docs/sample.swift +++ b/docs/sample.swift @@ -2,93 +2,99 @@ // MARK: Types and naming -// Types begin with a capital letter +/// Types begin with a capital letter. struct User { let name: String - // if the first letter of an acronym is lowercase, the entire thing should - // be lowercase + /// if the first letter of an acronym is lowercase, the entire thing should + /// be lowercase. let json: Any - // if the first letter of an acronym is uppercase, the entire thing should - // be uppercase - static func decode(from json: JSON) -> User { - return User(json: json) + /// if the first letter of an acronym is uppercase, the entire thing should + /// be uppercase. + static func decode(from json: JSON) -> Self { + Self(json: json) } } -// Use () for void arguments and Void for void return types -let f: () -> Void = {} +/// Use () for void arguments and Void for void return types. +let closure: () -> Void = { + // Do nothing +} -// When using classes, default to marking them as final -final class MyViewController: UIViewController { - // Prefer strong IBOutlet references - @IBOutlet var button: UIButton! +/// When using classes, default to marking them as final. +final class MyClass { + // Empty class } -// Use typealias when closures are referenced in multiple places +/// Use typealias when closures are referenced in multiple places. typealias CoolClosure = (Int) -> Bool -// Use aliased parameter names when function parameters are ambiguous +/// Use aliased parameter names when function parameters are ambiguous. func yTown(some: Int, withCallback callback: CoolClosure) -> Bool { - return callback(some) + callback(some) } -// It's OK to use $ variable references if the closure is very short and -// readability is maintained +/// It's OK to use $ variable references if the closure is very short and +/// readability is maintained. let cool = yTown(5) { $0 == 6 } -// Use full variable names when closures are more complex +/// Use full variable names when closures are more complex. let cool = yTown(5) { foo in - if foo > 5, foo < 0 { - return true - } else { - return false - } + max(foo, 0) + // … } // Strongify weak references in async closures APIClient.getAwesomeness { [weak self] result in - guard let `self` = self else { return } + guard let self else { + return + } self.stopLoadingSpinner() self.show(result) } -// If the API you are using has implicit unwrapping you should still use if-let -func someUnauditedAPI(thing: String!) { - if let string = thing { - print(string) +/// Use if-let to check for not `nil` (even if using an implicitly unwrapped variable from an API). +func someUnauditedAPI(thing: String?) { + if let thing { + print(thing) } } -// When the type is known you can let the compiler infer +/// When the type is known you can let the compiler infer. let response: Response = .success(NSData()) func doSomeWork() -> Response { - let data = ... + let data = Data("", .utf8) return .success(data) } switch response { -case let .success(data): +case .success(let data): print("The response returned successfully \(data)") - -case let .failure(error): +case .failure(let error): print("An error occurred: \(error)") } // MARK: Organization -// Group methods into specific extensions for each level of access control +/// Group methods into specific extensions for each level of access control. private extension MyClass { - func doSomethingPrivate() {} + func doSomethingPrivate() { + // Do something + } } // MARK: Breaking up long lines // One expression to evaluate and short or no return -guard let singleTest = somethingFailable() else { return } -guard statementThatShouldBeTrue else { return } +guard let singleTest = somethingFailable() else { + return +} + +guard statementThatShouldBeTrue else { + return +} // If a guard clause requires multiple lines, chop down, then start `else` new line // In this case, always chop down else clause. From 800633eea5443931c77f8f26ca7722f9d18d1e4a Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Wed, 20 Nov 2024 23:11:53 -0500 Subject: [PATCH 079/131] The `swift-format` formula will only install on macOS 13+. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Brewfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Brewfile b/Brewfile index c449f179c..e58427213 100644 --- a/Brewfile +++ b/Brewfile @@ -3,11 +3,11 @@ brew "markdownlint-cli" brew "prettier" brew "shellcheck" brew "shfmt" -brew "swift-format" brew "swiftformat" brew "yamllint" if OS.mac? && MacOS.version >= :ventura + brew "swift-format" brew "swiftlint" tap "peripheryapp/periphery" cask "periphery" From 39ce6b9edaec855b381b693170009d4defbfb5e5 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 21 Nov 2024 01:53:02 -0500 Subject: [PATCH 080/131] Upgrade swiftformat to 0.55.2, prettier to 3.4.1, & markdownlint-cli to 0.43.0. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Brewfile.lock.json | 62 +++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Brewfile.lock.json b/Brewfile.lock.json index 1836c9f35..d3a9a9424 100644 --- a/Brewfile.lock.json +++ b/Brewfile.lock.json @@ -2,40 +2,40 @@ "entries": { "brew": { "markdownlint-cli": { - "version": "0.42.0", + "version": "0.43.0", "bottle": { "rebuild": 0, "root_url": "https://ghcr.io/v2/homebrew/core", "files": { "arm64_sequoia": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:a3e5181a75b8fb131ac22c9c63635573d403a3d720ef0c72bd58cecfb3c2fe3e", - "sha256": "a3e5181a75b8fb131ac22c9c63635573d403a3d720ef0c72bd58cecfb3c2fe3e" + "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704", + "sha256": "5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704" }, "arm64_sonoma": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:a3e5181a75b8fb131ac22c9c63635573d403a3d720ef0c72bd58cecfb3c2fe3e", - "sha256": "a3e5181a75b8fb131ac22c9c63635573d403a3d720ef0c72bd58cecfb3c2fe3e" + "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704", + "sha256": "5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704" }, "arm64_ventura": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:a3e5181a75b8fb131ac22c9c63635573d403a3d720ef0c72bd58cecfb3c2fe3e", - "sha256": "a3e5181a75b8fb131ac22c9c63635573d403a3d720ef0c72bd58cecfb3c2fe3e" + "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704", + "sha256": "5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704" }, "sonoma": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:758ba29dba62e69b33801d519cbf6186a84320adf3e8e08bda862c9b057c22e5", - "sha256": "758ba29dba62e69b33801d519cbf6186a84320adf3e8e08bda862c9b057c22e5" + "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:3c474cd8d82383adbdb5f98012721beaf18a515754dc9fd4e7affe421a5af6d5", + "sha256": "3c474cd8d82383adbdb5f98012721beaf18a515754dc9fd4e7affe421a5af6d5" }, "ventura": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:758ba29dba62e69b33801d519cbf6186a84320adf3e8e08bda862c9b057c22e5", - "sha256": "758ba29dba62e69b33801d519cbf6186a84320adf3e8e08bda862c9b057c22e5" + "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:3c474cd8d82383adbdb5f98012721beaf18a515754dc9fd4e7affe421a5af6d5", + "sha256": "3c474cd8d82383adbdb5f98012721beaf18a515754dc9fd4e7affe421a5af6d5" }, "x86_64_linux": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:a3e5181a75b8fb131ac22c9c63635573d403a3d720ef0c72bd58cecfb3c2fe3e", - "sha256": "a3e5181a75b8fb131ac22c9c63635573d403a3d720ef0c72bd58cecfb3c2fe3e" + "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704", + "sha256": "5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704" } } } @@ -168,40 +168,40 @@ } }, "swiftformat": { - "version": "0.54.6_1", + "version": "0.55.2", "bottle": { "rebuild": 0, "root_url": "https://ghcr.io/v2/homebrew/core", "files": { "arm64_sequoia": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:03eb08eb7de0e697e574b5d5c94104a88c9548ee880b942f1916536fe7ff897a", - "sha256": "03eb08eb7de0e697e574b5d5c94104a88c9548ee880b942f1916536fe7ff897a" + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:a1574c8ec95b85dbcc192977e3b961895661249c006ec8256fad2c144b120a54", + "sha256": "a1574c8ec95b85dbcc192977e3b961895661249c006ec8256fad2c144b120a54" }, "arm64_sonoma": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:0ff9c3c154fea61303bd060da1aecebb025a3a33460b24910cf55e6ae366574e", - "sha256": "0ff9c3c154fea61303bd060da1aecebb025a3a33460b24910cf55e6ae366574e" + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:e9a143ddf86e2d36e426ff874e30c497790ca0cfc775cbf858fdf89e2fc7ddeb", + "sha256": "e9a143ddf86e2d36e426ff874e30c497790ca0cfc775cbf858fdf89e2fc7ddeb" }, "arm64_ventura": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:52200577da57cebd27e7d4b6a9ed84f6d3475b7f91e28ec4f5947fc2992cd943", - "sha256": "52200577da57cebd27e7d4b6a9ed84f6d3475b7f91e28ec4f5947fc2992cd943" + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:3ddbf04449504f60ee538f078e15e11bc94dafcb892ff790ca313d7630e1601d", + "sha256": "3ddbf04449504f60ee538f078e15e11bc94dafcb892ff790ca313d7630e1601d" }, "sonoma": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:9f79e28a0a5c7172be8bfcf23fca47de08f8bc03a3ddcdfbf52704445b9d8b18", - "sha256": "9f79e28a0a5c7172be8bfcf23fca47de08f8bc03a3ddcdfbf52704445b9d8b18" + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:670b1bd51cd26556933eec3bad67b02dd928ccc3ab2833eb30226fdc0db2e431", + "sha256": "670b1bd51cd26556933eec3bad67b02dd928ccc3ab2833eb30226fdc0db2e431" }, "ventura": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:416528899d45dc25edc2f14c857239a2c922b4be548345423857f140c6b90f0f", - "sha256": "416528899d45dc25edc2f14c857239a2c922b4be548345423857f140c6b90f0f" + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:4a84ae76fe2611d6f5b3ee8dbba3e826beba9bdb009f85a6e8d4f77f1d2358ae", + "sha256": "4a84ae76fe2611d6f5b3ee8dbba3e826beba9bdb009f85a6e8d4f77f1d2358ae" }, "x86_64_linux": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:86c47e1a74da98ff5646c8d510ea5e6de45e9dc97bc59f151bd2a8848b5bc9f8", - "sha256": "86c47e1a74da98ff5646c8d510ea5e6de45e9dc97bc59f151bd2a8848b5bc9f8" + "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:2d7e27757d5e139a04270be0c0f5e08838dc665f4dd8cc6a3c06e9acfdd4eb50", + "sha256": "2d7e27757d5e139a04270be0c0f5e08838dc665f4dd8cc6a3c06e9acfdd4eb50" } } } @@ -285,15 +285,15 @@ } }, "prettier": { - "version": "3.3.3", + "version": "3.4.1", "bottle": { - "rebuild": 2, + "rebuild": 0, "root_url": "https://ghcr.io/v2/homebrew/core", "files": { "all": { "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/prettier/blobs/sha256:34c3eb047777201bc1fd28e71876301232bdecf8ee36d35787e621a412244be3", - "sha256": "34c3eb047777201bc1fd28e71876301232bdecf8ee36d35787e621a412244be3" + "url": "https://ghcr.io/v2/homebrew/core/prettier/blobs/sha256:aad8e8d0d49f60f68c69f5c62ff22b1e7818ea585245d05c9e8deff129891a40", + "sha256": "aad8e8d0d49f60f68c69f5c62ff22b1e7818ea585245d05c9e8deff129891a40" } } } @@ -303,7 +303,7 @@ "system": { "macos": { "monterey": { - "HOMEBREW_VERSION": "4.4.5-42-g640d52c", + "HOMEBREW_VERSION": "4.4.8-4-g6fb9d2d", "HOMEBREW_PREFIX": "/usr/local", "Homebrew/homebrew-core": "api", "CLT": "14.2.0.0.1.1668646533", From 292771a1a62951b7a111680d514d321ec5c46ff0 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 21 Nov 2024 02:11:44 -0500 Subject: [PATCH 081/131] Output full `git describe --tags` to indicate number of commits since tag & current revision for local (i.e. non-release builds), since releases should all be for a version tagged revision. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/version b/script/version index 14581650f..781f855a3 100755 --- a/script/version +++ b/script/version @@ -13,5 +13,5 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -version_tag="$(git describe --abbrev=0 --tags 2>/dev/null)" +version_tag="$(git describe --tags 2>/dev/null)" printf $'%s\n' "${version_tag#v}" From 403a3f838df9720fd883d18368a159f636d6abdb Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:12:11 -0500 Subject: [PATCH 082/131] Remove unnecessary single quotes from bash scripts. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 2 +- script/build | 2 +- script/package | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index e0c55b665..68b8a0f1f 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -20,7 +20,7 @@ function usage { # Detect presence of `-f` frozen option frozen= -while getopts 'f' opt; do +while getopts f opt; do case "${opt}" in f) frozen='--no-lock --no-upgrade' diff --git a/script/build b/script/build index 53b9e596d..cb6832af5 100755 --- a/script/build +++ b/script/build @@ -14,7 +14,7 @@ if ! cd -- "${mas_dir}"; then fi # Build for the host architecture by default. -if [[ "${#}" -ge 1 && "${1}" == '--universal' ]]; then +if [[ "${#}" -ge 1 && "${1}" == --universal ]]; then arch=( --arch arm64 --arch x86_64 diff --git a/script/package b/script/package index fc299231f..3a52ab299 100755 --- a/script/package +++ b/script/package @@ -24,15 +24,15 @@ ditto -v "${build_dir}/apple/Products/Release/mas" "${distributions_root}/usr/lo printf $'==> 📦 Assembling installer package for mas %s\n' "${version}" -# Assemble macOS installer component package (aka 'product archive'). +# Assemble macOS installer component package (aka product archive). pkgbuild \ --identifier com.mphys.mas-cli \ - --install-location '/' \ + --install-location / \ --version "${version}" \ --root "${distributions_root}" \ "${build_dir}/mas_components.pkg" -# Build distribution package (aka 'product archive'). Not sure why, but this is how Carthage does it. +# 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 Package/Distribution.plist \ From 0870111ca71c132561b017e3354a67c0748923b4 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:39:42 -0500 Subject: [PATCH 083/131] Remove unnecessary `swiftlint` output filtering from `script/lint`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/lint | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/script/lint b/script/lint index c59a20a90..33a4de5fe 100755 --- a/script/lint +++ b/script/lint @@ -40,8 +40,7 @@ for source in Package.swift Sources Tests; do (grep -vxE '(?:\^D\x08{2})?Running SwiftFormat\.{3}\r|\(lint mode - no files will be changed\.\)\r|Reading (?:config|swift-version) file at .*|\x1b\[32mSwiftFormat completed in \d+\.\d+s\.\x1b\[0m\r|0/\d+ files require formatting\.\r' || true) ((exit_code |= "${?}")) printf -- $'--> 🦅 %s swiftlint\n' "${source}" - swiftlint --strict --quiet "${source}" 2> \ - >((grep -vxF $'warning: Configuration option \'allow_multiline_func\' in \'opening_brace\' rule is deprecated. Use the option \'ignore_multiline_function_signatures\' instead.' || true) >&2) + swiftlint --strict --quiet "${source}" ((exit_code |= "${?}")) done From a0f59fcc70d90a02295fa787009fb5fc6555e235 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:05:55 -0500 Subject: [PATCH 084/131] Use `markdownlint` on all `*.md` files. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 2 +- script/lint | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/format b/script/format index 0085e294c..ec946b7aa 100755 --- a/script/format +++ b/script/format @@ -43,7 +43,7 @@ shfmt \ contrib/ script/ printf -- $'--> 〽️ Markdown\n' -markdownlint --config .markdownlint.json --fix .github . +markdownlint --config .markdownlint.json --fix . docs printf -- $'--> 🖊 YAML\n' # shellcheck disable=SC2046 diff --git a/script/lint b/script/lint index 33a4de5fe..6ddf53053 100755 --- a/script/lint +++ b/script/lint @@ -57,7 +57,7 @@ shfmt \ ((exit_code |= "${?}")) printf -- $'--> 〽️ Markdown\n' -markdownlint --config .markdownlint.json .github . +markdownlint --config .markdownlint.json . docs ((exit_code |= "${?}")) printf -- $'--> 📝 YAML\n' From 1fe3ca434b2a91e9bbb75efda7eaf33253bd4d0a Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:19:14 -0500 Subject: [PATCH 085/131] Remove incorrect comment from `script/format`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/script/format b/script/format index ec946b7aa..c07e94caf 100755 --- a/script/format +++ b/script/format @@ -3,8 +3,6 @@ # script/format # mas # -# Linting checks for development and CI. -# # Automatically formats and fixes style violations using various tools. # # Please keep in sync with script/lint. @@ -17,7 +15,7 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -printf $'==> 🚨 Formatting mas\n' +printf $'==> 🚨 Formatting mas %s\n' "$(script/version)" for linter in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do if [[ ! -x "$(command -v "${linter}")" ]]; then From c064c91b91c3ba5a94fa8c7ab83ebe08e9a7d721 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:20:27 -0500 Subject: [PATCH 086/131] Rename `linter` as `formatter` in `script/format`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/format b/script/format index c07e94caf..b40336b33 100755 --- a/script/format +++ b/script/format @@ -17,9 +17,9 @@ fi printf $'==> 🚨 Formatting mas %s\n' "$(script/version)" -for linter in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do - if [[ ! -x "$(command -v "${linter}")" ]]; then - printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}" >&2 +for formatter in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do + if [[ ! -x "$(command -v "${formatter}")" ]]; then + printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${formatter}" "${formatter}" >&2 exit 1 fi done From 9ab9277a39559c0b7ffb055235dd4fff0c7b2350 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:21:40 -0500 Subject: [PATCH 087/131] Change Swift formatter emoji to fix output spacing issues in `script/format`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/script/format b/script/format index b40336b33..4b66811d9 100755 --- a/script/format +++ b/script/format @@ -25,11 +25,11 @@ for formatter in markdownlint prettier shfmt swift-format swiftformat swiftlint done for source in Package.swift Sources Tests; do - printf -- $'--> 🕊 %s swift-format\n' "${source}" + printf -- $'--> 🦅 %s swift-format\n' "${source}" swift-format format --in-place --recursive "${source}" - printf -- $'--> 🕊 %s swiftformat\n' "${source}" + printf -- $'--> 🦅 %s swiftformat\n' "${source}" swiftformat "${source}" - printf -- $'--> 🕊 %s swiftlint\n' "${source}" + printf -- $'--> 🦅 %s swiftlint\n' "${source}" swiftlint --fix --strict "${source}" done @@ -43,6 +43,6 @@ shfmt \ printf -- $'--> 〽️ Markdown\n' markdownlint --config .markdownlint.json --fix . docs -printf -- $'--> 🖊 YAML\n' +printf -- $'--> 📝 YAML\n' # shellcheck disable=SC2046 prettier --write $(yamllint --list-files .) From 16c5a26ca4a03a4b3b7ab4941b4e796cc60224f2 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:23:25 -0500 Subject: [PATCH 088/131] Make `swiftformat` `--strict` in `script/format`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/format b/script/format index 4b66811d9..139d384d5 100755 --- a/script/format +++ b/script/format @@ -28,7 +28,7 @@ for source in Package.swift Sources Tests; do printf -- $'--> 🦅 %s swift-format\n' "${source}" swift-format format --in-place --recursive "${source}" printf -- $'--> 🦅 %s swiftformat\n' "${source}" - swiftformat "${source}" + swiftformat --strict "${source}" printf -- $'--> 🦅 %s swiftlint\n' "${source}" swiftlint --fix --strict "${source}" done From 6913bf6d5d78e41a3f8a99ecce3d5b9ec43ec43f Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:24:15 -0500 Subject: [PATCH 089/131] Make `swiftlint` `--quiet` in `script/format`. Remove useless `--strict` from `swiftlint` in `script/format`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/format b/script/format index 139d384d5..e476edd87 100755 --- a/script/format +++ b/script/format @@ -30,7 +30,7 @@ for source in Package.swift Sources Tests; do printf -- $'--> 🦅 %s swiftformat\n' "${source}" swiftformat --strict "${source}" printf -- $'--> 🦅 %s swiftlint\n' "${source}" - swiftlint --fix --strict "${source}" + swiftlint --fix --quiet "${source}" done printf -- $'--> 📜 Bash shfmt\n' From 2061d886544572eb03be3a28a885cb8e0b95f1b4 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:43:11 -0500 Subject: [PATCH 090/131] Filter out boilerplate `swiftformat` output from `script/format`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script/format b/script/format index e476edd87..39d36e807 100755 --- a/script/format +++ b/script/format @@ -8,6 +8,8 @@ # Please keep in sync with script/lint. # +set -o pipefail + mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" if ! cd -- "${mas_dir}"; then @@ -28,7 +30,8 @@ for source in Package.swift Sources Tests; do printf -- $'--> 🦅 %s swift-format\n' "${source}" swift-format format --in-place --recursive "${source}" printf -- $'--> 🦅 %s swiftformat\n' "${source}" - swiftformat --strict "${source}" + script -q /dev/null swiftformat --strict "${source}" | + (grep -vxE '(?:\^D\x08{2})?Running SwiftFormat\.{3}\r|Reading (?:config|swift-version) file at .*|\x1b\[32mSwiftFormat completed in \d+\.\d+s\.\x1b\[0m\r|0/\d+ files formatted\.\r' || true) printf -- $'--> 🦅 %s swiftlint\n' "${source}" swiftlint --fix --quiet "${source}" done From 1cf85be5a271d86604e0e490ecd25b13173167af Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:52:16 -0500 Subject: [PATCH 091/131] Filter out boilerplate `prettier` output from `script/format`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/format b/script/format index 39d36e807..b453adf71 100755 --- a/script/format +++ b/script/format @@ -48,4 +48,5 @@ markdownlint --config .markdownlint.json --fix . docs printf -- $'--> 📝 YAML\n' # shellcheck disable=SC2046 -prettier --write $(yamllint --list-files .) +script -q /dev/null prettier --write $(yamllint --list-files .) | + (grep -vxE '.+ \d+ms \(unchanged\)\r' || true) From 50f43333ddcb399b6762d69aea9e02ac6a06a878 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:49:41 -0500 Subject: [PATCH 092/131] Filter out boilerplate output from `script/test`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/test | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script/test b/script/test index 0af4334d0..d856d8384 100755 --- a/script/test +++ b/script/test @@ -6,6 +6,8 @@ # Runs mas tests. # +set -o pipefail + mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" if ! cd -- "${mas_dir}"; then @@ -17,4 +19,5 @@ script/generate_version_info_for_swift printf $'==> ✅ Testing mas %s\n' "$(script/version)" -swift test +script -q /dev/null swift test | + (grep -vxE $'Test Suite \'.+\' (?:started|passed) at \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3}\\.?\\r|Test Case \'-\\[.+\\]\' (?:started|passed \\(\\d+\\.\\d+ seconds\\))\\.\\r|\\t Executed \\d+ tests?, with 0 failures \\(0 unexpected\\) in \\d+\\.\\d+ \\(\\d+\\.\\d+\\) seconds\\r' || true) From 2f6873be6f2e179ceaaee4841b89898714bc680f Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Wed, 27 Nov 2024 04:07:56 -0500 Subject: [PATCH 093/131] brew bundle no longer generates `Brewfile.lock.json`. Allow `script/bootstrap` to accept any arguments for `brew bundle install`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/build-test.yml | 2 +- .github/workflows/release.yml | 2 +- Brewfile.lock.json | 315 ------------------------------- script/bootstrap | 22 +-- 4 files changed, 5 insertions(+), 336 deletions(-) delete mode 100644 Brewfile.lock.json diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 5a5e54301..384f68757 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -36,7 +36,7 @@ jobs: fetch-depth: 0 - name: Bootstrap - run: script/bootstrap -f + run: script/bootstrap - name: Build run: script/build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index afaaa0f37..ab0a1681f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,7 @@ jobs: - name: 👢 Bootstrap run: | - script/bootstrap -f + script/bootstrap - name: 📦 Build universal executable & package it in mas.pkg run: | diff --git a/Brewfile.lock.json b/Brewfile.lock.json deleted file mode 100644 index d3a9a9424..000000000 --- a/Brewfile.lock.json +++ /dev/null @@ -1,315 +0,0 @@ -{ - "entries": { - "brew": { - "markdownlint-cli": { - "version": "0.43.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704", - "sha256": "5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704" - }, - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704", - "sha256": "5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704", - "sha256": "5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:3c474cd8d82383adbdb5f98012721beaf18a515754dc9fd4e7affe421a5af6d5", - "sha256": "3c474cd8d82383adbdb5f98012721beaf18a515754dc9fd4e7affe421a5af6d5" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:3c474cd8d82383adbdb5f98012721beaf18a515754dc9fd4e7affe421a5af6d5", - "sha256": "3c474cd8d82383adbdb5f98012721beaf18a515754dc9fd4e7affe421a5af6d5" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704", - "sha256": "5b821b6668e1fb447f4be2a67ea43544913b7e17bcd2fd8d7374cd7422239704" - } - } - } - }, - "shellcheck": { - "version": "0.10.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:5045be1e530288251353848343322f5a423617d061830b7ea7465fe550787364", - "sha256": "5045be1e530288251353848343322f5a423617d061830b7ea7465fe550787364" - }, - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:ef742b6992cfcdcd7289718ac64b27174e421d29ce3ad9b81e1856349059b117", - "sha256": "ef742b6992cfcdcd7289718ac64b27174e421d29ce3ad9b81e1856349059b117" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:6e60ee03edb09ac5bc852b8eb813849fa654400e21ffb4c746989678172f5a26", - "sha256": "6e60ee03edb09ac5bc852b8eb813849fa654400e21ffb4c746989678172f5a26" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:d5e8407806dbf757e71930ce2cb9b0d23bae286f0c058d9ff246d851dd7aa871", - "sha256": "d5e8407806dbf757e71930ce2cb9b0d23bae286f0c058d9ff246d851dd7aa871" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:b53cf1e5464406ee49743fc2db84850b6d34d3a2098cf729e629b23f9d6dd6e0", - "sha256": "b53cf1e5464406ee49743fc2db84850b6d34d3a2098cf729e629b23f9d6dd6e0" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:15ba88c48a5ae3b08e085791e3c5e514d9d78ce88414c96bd21ed33f29fb4aca", - "sha256": "15ba88c48a5ae3b08e085791e3c5e514d9d78ce88414c96bd21ed33f29fb4aca" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:b3d14cb62e325d0f7221cd24a7fb4533936feae4ed4dce00e8983ec6e55123f8", - "sha256": "b3d14cb62e325d0f7221cd24a7fb4533936feae4ed4dce00e8983ec6e55123f8" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:6d0867f144686a5caa025cb15ecac49286654b78e7b89979a54eedc9a0cc9b6b", - "sha256": "6d0867f144686a5caa025cb15ecac49286654b78e7b89979a54eedc9a0cc9b6b" - } - } - } - }, - "shfmt": { - "version": "3.10.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:88d60bca61406671618ecf94f2d81104882f9dd8db838a70d0c2cd6c0fa46863", - "sha256": "88d60bca61406671618ecf94f2d81104882f9dd8db838a70d0c2cd6c0fa46863" - }, - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:88d60bca61406671618ecf94f2d81104882f9dd8db838a70d0c2cd6c0fa46863", - "sha256": "88d60bca61406671618ecf94f2d81104882f9dd8db838a70d0c2cd6c0fa46863" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:88d60bca61406671618ecf94f2d81104882f9dd8db838a70d0c2cd6c0fa46863", - "sha256": "88d60bca61406671618ecf94f2d81104882f9dd8db838a70d0c2cd6c0fa46863" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:788b7ecff02bbff7fa1563a4937999972799361b4a0c49b1ed8545983d6ff989", - "sha256": "788b7ecff02bbff7fa1563a4937999972799361b4a0c49b1ed8545983d6ff989" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:788b7ecff02bbff7fa1563a4937999972799361b4a0c49b1ed8545983d6ff989", - "sha256": "788b7ecff02bbff7fa1563a4937999972799361b4a0c49b1ed8545983d6ff989" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:0b15af30edec238edf607c38a95bd45249cdd6f48f30ab33bdd0a9c2ae2da956", - "sha256": "0b15af30edec238edf607c38a95bd45249cdd6f48f30ab33bdd0a9c2ae2da956" - } - } - } - }, - "swift-format": { - "version": "510.1.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swift-format/blobs/sha256:4bee0106201ba2a3036576610e61832b97fb65292c194f52fc15d62e1bdb2243", - "sha256": "4bee0106201ba2a3036576610e61832b97fb65292c194f52fc15d62e1bdb2243" - }, - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swift-format/blobs/sha256:ac50e5269ecc0bffb70a6c5077f97954e2e51c9158a3bfa36b86d89f9d6c5e43", - "sha256": "ac50e5269ecc0bffb70a6c5077f97954e2e51c9158a3bfa36b86d89f9d6c5e43" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swift-format/blobs/sha256:7fb047e8f80a72e5d8d7ae50c496d0cf59dd3ab654ce6048e4b7fa7b85afe69a", - "sha256": "7fb047e8f80a72e5d8d7ae50c496d0cf59dd3ab654ce6048e4b7fa7b85afe69a" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swift-format/blobs/sha256:a99a19c9fc177a57b2577e3c1b30feb70f13388fc9c4e4ea7968f783058e09a0", - "sha256": "a99a19c9fc177a57b2577e3c1b30feb70f13388fc9c4e4ea7968f783058e09a0" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swift-format/blobs/sha256:a652f68cc4bed9c3186b66c8ee68e79b7387d37943aaff0a0c2d4197367b73fe", - "sha256": "a652f68cc4bed9c3186b66c8ee68e79b7387d37943aaff0a0c2d4197367b73fe" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swift-format/blobs/sha256:b1949fcb7f1b943fa5b0216bc6f18e12dc369c0538b093786332f851f22b0b03", - "sha256": "b1949fcb7f1b943fa5b0216bc6f18e12dc369c0538b093786332f851f22b0b03" - } - } - } - }, - "swiftformat": { - "version": "0.55.2", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:a1574c8ec95b85dbcc192977e3b961895661249c006ec8256fad2c144b120a54", - "sha256": "a1574c8ec95b85dbcc192977e3b961895661249c006ec8256fad2c144b120a54" - }, - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:e9a143ddf86e2d36e426ff874e30c497790ca0cfc775cbf858fdf89e2fc7ddeb", - "sha256": "e9a143ddf86e2d36e426ff874e30c497790ca0cfc775cbf858fdf89e2fc7ddeb" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:3ddbf04449504f60ee538f078e15e11bc94dafcb892ff790ca313d7630e1601d", - "sha256": "3ddbf04449504f60ee538f078e15e11bc94dafcb892ff790ca313d7630e1601d" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:670b1bd51cd26556933eec3bad67b02dd928ccc3ab2833eb30226fdc0db2e431", - "sha256": "670b1bd51cd26556933eec3bad67b02dd928ccc3ab2833eb30226fdc0db2e431" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:4a84ae76fe2611d6f5b3ee8dbba3e826beba9bdb009f85a6e8d4f77f1d2358ae", - "sha256": "4a84ae76fe2611d6f5b3ee8dbba3e826beba9bdb009f85a6e8d4f77f1d2358ae" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:2d7e27757d5e139a04270be0c0f5e08838dc665f4dd8cc6a3c06e9acfdd4eb50", - "sha256": "2d7e27757d5e139a04270be0c0f5e08838dc665f4dd8cc6a3c06e9acfdd4eb50" - } - } - } - }, - "yamllint": { - "version": "1.35.1", - "bottle": { - "rebuild": 2, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/yamllint/blobs/sha256:cb74d6cc51501733531acd25b26fd474557d19374b98eb7de16271ff2c257860", - "sha256": "cb74d6cc51501733531acd25b26fd474557d19374b98eb7de16271ff2c257860" - }, - "arm64_sonoma": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/yamllint/blobs/sha256:e36b43d6b87028fe2005878cb15c78edec6ddb898e9a86ff7b901fe093cf9c0e", - "sha256": "e36b43d6b87028fe2005878cb15c78edec6ddb898e9a86ff7b901fe093cf9c0e" - }, - "arm64_ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/yamllint/blobs/sha256:3591f98aaaebba5e9360926f5ca756dbd85c6a46de0554042376ac83548c7fb3", - "sha256": "3591f98aaaebba5e9360926f5ca756dbd85c6a46de0554042376ac83548c7fb3" - }, - "sonoma": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/yamllint/blobs/sha256:3889369233f5f342b73cc70625748a52d72117603b92f352af00a9ebd27cb1c4", - "sha256": "3889369233f5f342b73cc70625748a52d72117603b92f352af00a9ebd27cb1c4" - }, - "ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/yamllint/blobs/sha256:209883378df0edf4a0691fd2dbf6f2e8da7776bd9c0de0fc70fa04dd0fc51c8d", - "sha256": "209883378df0edf4a0691fd2dbf6f2e8da7776bd9c0de0fc70fa04dd0fc51c8d" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/yamllint/blobs/sha256:993514320174f1147d538719552131a73d34cf66dc9f82c38f6ed28b16cea287", - "sha256": "993514320174f1147d538719552131a73d34cf66dc9f82c38f6ed28b16cea287" - } - } - } - }, - "act": { - "version": "0.2.69", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sequoia": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:b506a62f7a79cb1274f1b4e2ac063e99e8b21c48303f037a8d072fa7e72d51f1", - "sha256": "b506a62f7a79cb1274f1b4e2ac063e99e8b21c48303f037a8d072fa7e72d51f1" - }, - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:fc7f50bc0659b145e63576379ec94f799d4a18b05442126828cb78a4579e44d0", - "sha256": "fc7f50bc0659b145e63576379ec94f799d4a18b05442126828cb78a4579e44d0" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:b55f6f6d877ca04e0e8416d0659655f4b5949d43f054799760d36c985331fc9c", - "sha256": "b55f6f6d877ca04e0e8416d0659655f4b5949d43f054799760d36c985331fc9c" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:04027bfea83f4a73d50c788cc5cdecf8a06866fc7e208a89d9c0b1271e6b0f58", - "sha256": "04027bfea83f4a73d50c788cc5cdecf8a06866fc7e208a89d9c0b1271e6b0f58" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:ca92a0306d5f17988f137e0711b1fffc1a4aa7038f2bbe96b50ec52ed788f846", - "sha256": "ca92a0306d5f17988f137e0711b1fffc1a4aa7038f2bbe96b50ec52ed788f846" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/act/blobs/sha256:30819c65f4c708e7cf5443017a5c16e27ffdccef8f2e1177b01886cdde982a4c", - "sha256": "30819c65f4c708e7cf5443017a5c16e27ffdccef8f2e1177b01886cdde982a4c" - } - } - } - }, - "prettier": { - "version": "3.4.1", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "all": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/prettier/blobs/sha256:aad8e8d0d49f60f68c69f5c62ff22b1e7818ea585245d05c9e8deff129891a40", - "sha256": "aad8e8d0d49f60f68c69f5c62ff22b1e7818ea585245d05c9e8deff129891a40" - } - } - } - } - } - }, - "system": { - "macos": { - "monterey": { - "HOMEBREW_VERSION": "4.4.8-4-g6fb9d2d", - "HOMEBREW_PREFIX": "/usr/local", - "Homebrew/homebrew-core": "api", - "CLT": "14.2.0.0.1.1668646533", - "Xcode": "14.2", - "macOS": "12.7.6" - } - } - } -} diff --git a/script/bootstrap b/script/bootstrap index 68b8a0f1f..165e8d226 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -5,6 +5,8 @@ # # Installs development dependencies and builds project dependencies. # +# Usage: bootstrap [...] +# mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" @@ -13,25 +15,7 @@ if ! cd -- "${mas_dir}"; then exit 1 fi -function usage { - printf $'Usage: bootstrap [-f]\n -f option enables frozen mode\n' >&2 - exit 1 -} - -# Detect presence of `-f` frozen option -frozen= -while getopts f opt; do - case "${opt}" in - f) - frozen='--no-lock --no-upgrade' - ;; - *) - usage - ;; - esac -done - printf $'==> 👢 Bootstrapping mas %s\n' "$(script/version)" # shellcheck disable=SC2086 -brew bundle install ${frozen} --verbose +brew bundle install --verbose "${@:+"${@}"}" From b4452adcc053affdcfff5ea8e283962777798db9 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Sun, 1 Dec 2024 10:54:49 -0700 Subject: [PATCH 094/131] =?UTF-8?q?=F0=9F=94=A5=20Remove=20DRY=5FRUN=20var?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab0a1681f..77f5f9b41 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,6 @@ on: release: types: [published] env: - DRY_RUN: "" GH_TOKEN: ${{github.token}} HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} RELEASE_BODY: ${{github.event.release.body}} @@ -41,7 +40,6 @@ jobs: script/package - name: 🚀 Upload mas.pkg - if: ${{!env.DRY_RUN}} run: | gh release upload "${RELEASE_TAG}" .build/mas.pkg @@ -56,7 +54,6 @@ jobs: --online \ --strict \ --verbose \ - ${DRY_RUN} \ mas-cli/tap/mas - name: 🍺 Bump homebrew-core/mas formula @@ -71,5 +68,4 @@ jobs: --online \ --strict \ --verbose \ - ${DRY_RUN} \ mas From 5d9abd352a981b7f08a0a6c62a47f50c296fb1b6 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 2 Dec 2024 03:42:24 -0500 Subject: [PATCH 095/131] Remove shfmt because it cannot work with zsh. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Brewfile | 1 - script/format | 9 +-------- script/lint | 10 +--------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/Brewfile b/Brewfile index e58427213..780f05016 100644 --- a/Brewfile +++ b/Brewfile @@ -2,7 +2,6 @@ brew "act" brew "markdownlint-cli" brew "prettier" brew "shellcheck" -brew "shfmt" brew "swiftformat" brew "yamllint" diff --git a/script/format b/script/format index b453adf71..373b9f9d6 100755 --- a/script/format +++ b/script/format @@ -19,7 +19,7 @@ fi printf $'==> 🚨 Formatting mas %s\n' "$(script/version)" -for formatter in markdownlint prettier shfmt swift-format swiftformat swiftlint yamllint; do +for formatter in markdownlint prettier swift-format swiftformat swiftlint yamllint; do if [[ ! -x "$(command -v "${formatter}")" ]]; then printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${formatter}" "${formatter}" >&2 exit 1 @@ -36,13 +36,6 @@ for source in Package.swift Sources Tests; do swiftlint --fix --quiet "${source}" done -printf -- $'--> 📜 Bash shfmt\n' -shfmt \ - --write \ - --list \ - --indent 2 \ - contrib/ script/ - printf -- $'--> 〽️ Markdown\n' markdownlint --config .markdownlint.json --fix . docs diff --git a/script/lint b/script/lint index 6ddf53053..2d4ac4406 100755 --- a/script/lint +++ b/script/lint @@ -23,7 +23,7 @@ script/generate_version_info_for_swift printf $'==> 🚨 Linting mas %s\n' "$(script/version)" -for linter in git markdownlint periphery shellcheck shfmt swift-format swiftformat swiftlint yamllint; do +for linter in git markdownlint periphery shellcheck swift-format swiftformat swiftlint yamllint; do if [[ ! -x "$(command -v "${linter}")" ]]; then printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}" >&2 exit 1 @@ -48,14 +48,6 @@ printf -- $'--> 🐚 Bash shellcheck\n' shellcheck --shell=bash script/* ((exit_code |= "${?}")) -printf -- $'--> 📜 Bash shfmt\n' -shfmt \ - --diff \ - --list \ - --indent 2 \ - contrib/ script/ -((exit_code |= "${?}")) - printf -- $'--> 〽️ Markdown\n' markdownlint --config .markdownlint.json . docs ((exit_code |= "${?}")) From 5a29bb7b3119bbad0859426bdf9a5837bca47601 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 2 Dec 2024 03:21:19 -0500 Subject: [PATCH 096/131] Switch scripts from bash to zsh. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/build-test.yml | 2 +- .github/workflows/release.yml | 2 +- script/bootstrap | 7 +++---- script/build | 8 ++++---- script/clean | 4 ++-- script/format | 7 +++---- script/generate_version_info_for_swift | 4 ++-- script/lint | 24 ++++++++++++------------ script/package | 4 ++-- script/test | 4 ++-- script/update_headers | 4 ++-- script/version | 7 +++---- 12 files changed, 37 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 384f68757..dd4580a03 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -27,7 +27,7 @@ jobs: # https://github.com/actions/runner/issues/805#issuecomment-942784948 # https://github.com/rolpdog/cffi-mirror/blob/release-1.15/.github/workflows/ci.yaml#L81-L141 # https://github.com/actions/runner-images/issues/2187#issuecomment-790507204 - shell: arch -arm64 /bin/bash --noprofile --norc -eo pipefail {0} + shell: arch -arm64 /bin/zsh -ef --pipefail {0} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77f5f9b41..b7118fe8c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ name: release defaults: run: # Force all run commands to not use Rosetta 2 - shell: arch -arm64 /bin/bash --noprofile --norc -eo pipefail {0} + shell: arch -arm64 /bin/zsh -ef --pipefail {0} on: release: types: [published] diff --git a/script/bootstrap b/script/bootstrap index 165e8d226..e0f5ae9f8 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/bootstrap # mas @@ -8,7 +8,7 @@ # Usage: bootstrap [...] # -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 @@ -17,5 +17,4 @@ fi printf $'==> 👢 Bootstrapping mas %s\n' "$(script/version)" -# shellcheck disable=SC2086 -brew bundle install --verbose "${@:+"${@}"}" +brew bundle install --verbose "${@}" diff --git a/script/build b/script/build index cb6832af5..789f94710 100755 --- a/script/build +++ b/script/build @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/build # mas @@ -6,7 +6,7 @@ # Builds the Swift Package. # -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 @@ -36,6 +36,6 @@ printf $'==> 🏗️ Building mas %s\n' "$(script/version)" swift build \ --configuration release \ - "${arch[@]+"${arch[@]}"}" \ + "${arch[@]}" \ --disable-sandbox \ - "${cache[@]+"${cache[@]}"}" + "${cache[@]}" diff --git a/script/clean b/script/clean index faa3d68a0..01f651d38 100755 --- a/script/clean +++ b/script/clean @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/clean # mas @@ -6,7 +6,7 @@ # Deletes the build directory. # -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 diff --git a/script/format b/script/format index 373b9f9d6..593098776 100755 --- a/script/format +++ b/script/format @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/format # mas @@ -10,7 +10,7 @@ set -o pipefail -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 @@ -40,6 +40,5 @@ printf -- $'--> 〽️ Markdown\n' markdownlint --config .markdownlint.json --fix . docs printf -- $'--> 📝 YAML\n' -# shellcheck disable=SC2046 -script -q /dev/null prettier --write $(yamllint --list-files .) | +script -q /dev/null prettier --write "${(f)"$(yamllint --list-files .)"}" | (grep -vxE '.+ \d+ms \(unchanged\)\r' || true) diff --git a/script/generate_version_info_for_swift b/script/generate_version_info_for_swift index b276c25cb..4967d46dc 100755 --- a/script/generate_version_info_for_swift +++ b/script/generate_version_info_for_swift @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/generate_version_info_for_swift # mas @@ -6,7 +6,7 @@ # Generates a file to provide the mas version to Swift code. # -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 diff --git a/script/lint b/script/lint index 2d4ac4406..68ba81a1b 100755 --- a/script/lint +++ b/script/lint @@ -1,4 +1,4 @@ -#!/bin/bash -u +#!/bin/zsh -fu # # script/lint # mas @@ -12,7 +12,7 @@ set -o pipefail -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 @@ -34,35 +34,35 @@ exit_code=0 for source in Package.swift Sources Tests; do printf -- $'--> 🦅 %s swift-format\n' "${source}" swift-format lint --strict --recursive "${source}" - ((exit_code |= "${?}")) + ((exit_code |= ${?})) printf -- $'--> 🦅 %s swiftformat\n' "${source}" script -q /dev/null swiftformat --lint --strict "${source}" | (grep -vxE '(?:\^D\x08{2})?Running SwiftFormat\.{3}\r|\(lint mode - no files will be changed\.\)\r|Reading (?:config|swift-version) file at .*|\x1b\[32mSwiftFormat completed in \d+\.\d+s\.\x1b\[0m\r|0/\d+ files require formatting\.\r' || true) - ((exit_code |= "${?}")) + ((exit_code |= ${?})) printf -- $'--> 🦅 %s swiftlint\n' "${source}" swiftlint --strict --quiet "${source}" - ((exit_code |= "${?}")) + ((exit_code |= ${?})) done -printf -- $'--> 🐚 Bash shellcheck\n' -shellcheck --shell=bash script/* -((exit_code |= "${?}")) +printf -- $'--> 🐚 ShellCheck\n' +shellcheck -s bash -o all -e SC2296,SC2301,SC2312 -a -P SCRIPTDIR script/**/*(.) +((exit_code |= ${?})) printf -- $'--> 〽️ Markdown\n' markdownlint --config .markdownlint.json . docs -((exit_code |= "${?}")) +((exit_code |= ${?})) printf -- $'--> 📝 YAML\n' yamllint . -((exit_code |= "${?}")) +((exit_code |= ${?})) printf -- $'--> 🌳 Git\n' PAGER='cat' git diff --check -((exit_code |= "${?}")) +((exit_code |= ${?})) printf -- $'--> 🌀 Periphery\n' script -q /dev/null periphery scan --strict --quiet --disable-update-check | (grep -vxE '(?:\x1b\[0;1;32m|\^D\x08{2})\* (?:\x1b\[0;0m\x1b\[0;1m)?No unused code detected\.(?:\x1b\[0;0m)?\r' || true) -((exit_code |= "${?}")) +((exit_code |= ${?})) exit "${exit_code}" diff --git a/script/package b/script/package index 3a52ab299..5a85f50ba 100755 --- a/script/package +++ b/script/package @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/package # mas @@ -6,7 +6,7 @@ # Builds macOS installer component and distribution packages. # -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 diff --git a/script/test b/script/test index d856d8384..8424a8e55 100755 --- a/script/test +++ b/script/test @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/test # mas @@ -8,7 +8,7 @@ set -o pipefail -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 diff --git a/script/update_headers b/script/update_headers index c3b4ccc63..20cddc110 100755 --- a/script/update_headers +++ b/script/update_headers @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/update_headers # mas @@ -6,7 +6,7 @@ # Runs class-dump to generate headers for Apple private frameworks. # -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 diff --git a/script/version b/script/version index 781f855a3..884ac18c8 100755 --- a/script/version +++ b/script/version @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/bin/zsh -efu # # script/version # mas @@ -6,12 +6,11 @@ # Displays the mas version. # -mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")" +mas_dir="${0:a:h:h}" if ! cd -- "${mas_dir}"; then printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 exit 1 fi -version_tag="$(git describe --tags 2>/dev/null)" -printf $'%s\n' "${version_tag#v}" +printf $'%s\n' "${"$(git describe --tags 2>/dev/null)"#v}" From f4f5f18ec743a2b2439271824c095ed181ffd6b0 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:03:13 -0500 Subject: [PATCH 097/131] Add & use `script/_setup_script` to configure all zsh scripts. Update shebangs. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/build-test.yml | 2 +- .github/workflows/release.yml | 2 +- script/_setup_script | 42 ++++++++++++++++++++++++++ script/bootstrap | 9 ++---- script/build | 9 ++---- script/clean | 9 ++---- script/format | 11 ++----- script/generate_version_info_for_swift | 9 ++---- script/lint | 13 ++------ script/package | 9 ++---- script/test | 11 ++----- script/update_headers | 9 ++---- script/version | 9 ++---- 13 files changed, 65 insertions(+), 79 deletions(-) create mode 100755 script/_setup_script diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index dd4580a03..27440f8e2 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -27,7 +27,7 @@ jobs: # https://github.com/actions/runner/issues/805#issuecomment-942784948 # https://github.com/rolpdog/cffi-mirror/blob/release-1.15/.github/workflows/ci.yaml#L81-L141 # https://github.com/actions/runner-images/issues/2187#issuecomment-790507204 - shell: arch -arm64 /bin/zsh -ef --pipefail {0} + shell: arch -arm64 /bin/zsh {0} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7118fe8c..f044a1077 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ name: release defaults: run: # Force all run commands to not use Rosetta 2 - shell: arch -arm64 /bin/zsh -ef --pipefail {0} + shell: arch -arm64 /bin/zsh {0} on: release: types: [published] diff --git a/script/_setup_script b/script/_setup_script new file mode 100755 index 000000000..40b73f14c --- /dev/null +++ b/script/_setup_script @@ -0,0 +1,42 @@ +#!/bin/zsh -Ndefgku +# +# script/_setup_script +# mas +# +# Boilerplate setup for scripts. +# + +\unalias -as +setopt\ + autopushd\ + combiningchars\ + extendedglob\ + extendedhistory\ + no_globalrcs\ + histexpiredupsfirst\ + histignorespace\ + histverify\ + incappendhistorytime\ + interactivecomments\ + pipefail\ + no_rcs\ + no_unset +export HISTCHARS='!^#' +export IFS=$' \t\n\0' +export NULLCMD=cat +export PAGER=cat +export READNULLCMD=cat +export TMPDIR="${"${TMPDIR:-/tmp/}"/%(#b)([^\/])/"${match[1]}"/}" +export TMPPREFIX="${TMPPREFIX:-"${TMPDIR}"zsh}" +unset CDPATH +unset ENV +unset KEYBOARD_HACK +unset TMPSUFFIX +unset WORDCHARS + +mas_dir="${0:a:h:h}" + +if ! cd -- "${mas_dir}"; then + printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 + exit 1 +fi diff --git a/script/bootstrap b/script/bootstrap index e0f5ae9f8..2e54162dd 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/bootstrap # mas @@ -8,12 +8,7 @@ # Usage: bootstrap [...] # -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" printf $'==> 👢 Bootstrapping mas %s\n' "$(script/version)" diff --git a/script/build b/script/build index 789f94710..2d548b548 100755 --- a/script/build +++ b/script/build @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/build # mas @@ -6,12 +6,7 @@ # Builds the Swift Package. # -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" # Build for the host architecture by default. if [[ "${#}" -ge 1 && "${1}" == --universal ]]; then diff --git a/script/clean b/script/clean index 01f651d38..22345739a 100755 --- a/script/clean +++ b/script/clean @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/clean # mas @@ -6,12 +6,7 @@ # Deletes the build directory. # -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" swift package clean swift package reset diff --git a/script/format b/script/format index 593098776..766774ad3 100755 --- a/script/format +++ b/script/format @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/format # mas @@ -8,14 +8,7 @@ # Please keep in sync with script/lint. # -set -o pipefail - -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" printf $'==> 🚨 Formatting mas %s\n' "$(script/version)" diff --git a/script/generate_version_info_for_swift b/script/generate_version_info_for_swift index 4967d46dc..c29e2741b 100755 --- a/script/generate_version_info_for_swift +++ b/script/generate_version_info_for_swift @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/generate_version_info_for_swift # mas @@ -6,12 +6,7 @@ # Generates a file to provide the mas version to Swift code. # -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" # Write version to Swift singleton cat <Sources/mas/Package.swift diff --git a/script/lint b/script/lint index 68ba81a1b..22625fb81 100755 --- a/script/lint +++ b/script/lint @@ -1,4 +1,4 @@ -#!/bin/zsh -fu +#!/bin/zsh -Ndfgku # # script/lint # mas @@ -10,14 +10,7 @@ # Please keep in sync with script/format. # -set -o pipefail - -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" script/generate_version_info_for_swift @@ -57,7 +50,7 @@ yamllint . ((exit_code |= ${?})) printf -- $'--> 🌳 Git\n' -PAGER='cat' git diff --check +git diff --check ((exit_code |= ${?})) printf -- $'--> 🌀 Periphery\n' diff --git a/script/package b/script/package index 5a85f50ba..e8d151ece 100755 --- a/script/package +++ b/script/package @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/package # mas @@ -6,12 +6,7 @@ # Builds macOS installer component and distribution packages. # -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" build_dir=.build distribution_package="${build_dir}/mas.pkg" diff --git a/script/test b/script/test index 8424a8e55..3c9f009ab 100755 --- a/script/test +++ b/script/test @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/test # mas @@ -6,14 +6,7 @@ # Runs mas tests. # -set -o pipefail - -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" script/generate_version_info_for_swift diff --git a/script/update_headers b/script/update_headers index 20cddc110..96bbc023a 100755 --- a/script/update_headers +++ b/script/update_headers @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/update_headers # mas @@ -6,12 +6,7 @@ # Runs class-dump to generate headers for Apple private frameworks. # -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" if ! command -v class-dump >/dev/null; then printf $'class-dump is not installed.\nDownload from http://stevenygard.com/projects/class-dump/\n' >&2 diff --git a/script/version b/script/version index 884ac18c8..f5369b270 100755 --- a/script/version +++ b/script/version @@ -1,4 +1,4 @@ -#!/bin/zsh -efu +#!/bin/zsh -Ndefgku # # script/version # mas @@ -6,11 +6,6 @@ # Displays the mas version. # -mas_dir="${0:a:h:h}" - -if ! cd -- "${mas_dir}"; then - printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2 - exit 1 -fi +. "${0:a:h}/_setup_script" printf $'%s\n' "${"$(git describe --tags 2>/dev/null)"#v}" From 0dadaf6bda379909d8fcdb5745f2c1f8f01f4951 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 3 Dec 2024 06:16:22 -0500 Subject: [PATCH 098/131] `script/clean`: `rm -f Sources/mas/Package.swift`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/clean | 1 + 1 file changed, 1 insertion(+) diff --git a/script/clean b/script/clean index 22345739a..b5af491c3 100755 --- a/script/clean +++ b/script/clean @@ -10,3 +10,4 @@ swift package clean swift package reset +rm -f Sources/mas/Package.swift From c950af31de2bc9c92f0beac55662af1dc3d1f023 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:03:26 -0500 Subject: [PATCH 099/131] GitHub Workflows: reorder workflow parts, improve step emojis, update comments & improve spacing. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/build-test.yml | 14 ++------------ .github/workflows/release.yml | 10 +++++----- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 27440f8e2..04b4056b3 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -3,36 +3,26 @@ # --- name: Build, Test, and Lint - on: pull_request: branches: [main] push: branches: [main] - concurrency: group: ${{github.workflow}}-${{github.ref}} cancel-in-progress: true - jobs: build-test: name: Build, Test, and Lint - - # https://github.com/actions/runner-images#available-images runs-on: macos-15 - defaults: run: - # Prefixes all `run` commands with the following command to force them to run outside Rosetta. - # https://github.com/actions/runner/issues/805#issuecomment-942784948 - # https://github.com/rolpdog/cffi-mirror/blob/release-1.15/.github/workflows/ci.yaml#L81-L141 - # https://github.com/actions/runner-images/issues/2187#issuecomment-790507204 + # Force all run commands to not use Rosetta 2 shell: arch -arm64 /bin/zsh {0} - steps: - uses: actions/checkout@v4 with: - # A fetch-depth of 0 includes all history and tags for script/version + # Include all history & tags for script/version fetch-depth: 0 - name: Bootstrap diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f044a1077..0e8612336 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,13 +3,13 @@ # --- name: release +on: + release: + types: [published] defaults: run: # Force all run commands to not use Rosetta 2 shell: arch -arm64 /bin/zsh {0} -on: - release: - types: [published] env: GH_TOKEN: ${{github.token}} HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} @@ -28,7 +28,7 @@ jobs: printf $'Triggered by release publication event:\nname: %s\ntag_name: %s\ntarget_commitish: %s\nbody:\n%s\n' \ "${RELEASE_NAME}" "${RELEASE_TAG}" "${RELEASE_COMMITISH}" "${RELEASE_BODY}" - - name: 📺 Checkout mas repo + - name: 🛒 Checkout mas repo uses: actions/checkout@v4 - name: 👢 Bootstrap @@ -39,7 +39,7 @@ jobs: run: | script/package - - name: 🚀 Upload mas.pkg + - name: 📤 Upload mas.pkg run: | gh release upload "${RELEASE_TAG}" .build/mas.pkg From b484dcf12aabb848fc189643d8ee17d48ade2943 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 3 Dec 2024 09:56:51 -0500 Subject: [PATCH 100/131] Improve `class-dump` installation instructions. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/update_headers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/update_headers b/script/update_headers index 96bbc023a..b669feea7 100755 --- a/script/update_headers +++ b/script/update_headers @@ -9,7 +9,7 @@ . "${0:a:h}/_setup_script" if ! command -v class-dump >/dev/null; then - printf $'class-dump is not installed.\nDownload from http://stevenygard.com/projects/class-dump/\n' >&2 + printf $'class-dump is not installed.\n\nDownload, build & install mas fork of class-dump from https://github.com/mas-cli/class-dump\n' >&2 exit 1 fi From 181bf05c8a7e6911e462ebcc2e2220b5192267a5 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 3 Dec 2024 10:05:41 -0500 Subject: [PATCH 101/131] `script/bootstrap`: install Homebrew if not already installed. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/bootstrap | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/bootstrap b/script/bootstrap index 2e54162dd..d21785941 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -12,4 +12,8 @@ printf $'==> 👢 Bootstrapping mas %s\n' "$(script/version)" +if ! command -v brew >/dev/null; then + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + brew bundle install --verbose "${@}" From 3848da7732602f48c178d0fd3d287d33d9dc81f5 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:03:52 -0500 Subject: [PATCH 102/131] Improve `script/build`: - Remove `--universal` argument. - Do not disable sandbox. - Do not disable manifest cache. - Pass script arguments to `swift build`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/build | 23 +---------------------- script/package | 2 +- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/script/build b/script/build index 2d548b548..a856c8704 100755 --- a/script/build +++ b/script/build @@ -8,29 +8,8 @@ . "${0:a:h}/_setup_script" -# Build for the host architecture by default. -if [[ "${#}" -ge 1 && "${1}" == --universal ]]; then - arch=( - --arch arm64 - --arch x86_64 - ) -else - arch=() -fi - -# Disable the manifest cache. -if [[ "$(swift build --help)" =~ manifest-cache ]]; then - cache=(--manifest-cache none) -else - cache=() -fi - script/generate_version_info_for_swift printf $'==> 🏗️ Building mas %s\n' "$(script/version)" -swift build \ - --configuration release \ - "${arch[@]}" \ - --disable-sandbox \ - "${cache[@]}" +swift build --configuration release "${@}" diff --git a/script/package b/script/package index e8d151ece..0a3fc57bc 100755 --- a/script/package +++ b/script/package @@ -13,7 +13,7 @@ distribution_package="${build_dir}/mas.pkg" distributions_root="${build_dir}/distributions" version="$(script/version)" -script/build --universal +script/build --arch arm64 --arch x86_64 ditto -v "${build_dir}/apple/Products/Release/mas" "${distributions_root}/usr/local/bin/mas" From 98eb15982e64b7686db50b9b2601f4398524d6c0 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 10 Dec 2024 07:30:28 -0500 Subject: [PATCH 103/131] Move printf earlier in scripts. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/build | 4 ++-- script/lint | 4 ++-- script/package | 4 ++-- script/test | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/script/build b/script/build index a856c8704..809de60a8 100755 --- a/script/build +++ b/script/build @@ -8,8 +8,8 @@ . "${0:a:h}/_setup_script" -script/generate_version_info_for_swift - printf $'==> 🏗️ Building mas %s\n' "$(script/version)" +script/generate_version_info_for_swift + swift build --configuration release "${@}" diff --git a/script/lint b/script/lint index 22625fb81..2cd587606 100755 --- a/script/lint +++ b/script/lint @@ -12,10 +12,10 @@ . "${0:a:h}/_setup_script" -script/generate_version_info_for_swift - printf $'==> 🚨 Linting mas %s\n' "$(script/version)" +script/generate_version_info_for_swift + for linter in git markdownlint periphery shellcheck swift-format swiftformat swiftlint yamllint; do if [[ ! -x "$(command -v "${linter}")" ]]; then printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}" >&2 diff --git a/script/package b/script/package index 0a3fc57bc..aac675844 100755 --- a/script/package +++ b/script/package @@ -15,10 +15,10 @@ version="$(script/version)" script/build --arch arm64 --arch x86_64 -ditto -v "${build_dir}/apple/Products/Release/mas" "${distributions_root}/usr/local/bin/mas" - printf $'==> 📦 Assembling installer package for mas %s\n' "${version}" +ditto -v "${build_dir}/apple/Products/Release/mas" "${distributions_root}/usr/local/bin/mas" + # Assemble macOS installer component package (aka product archive). pkgbuild \ --identifier com.mphys.mas-cli \ diff --git a/script/test b/script/test index 3c9f009ab..5f3a5e1aa 100755 --- a/script/test +++ b/script/test @@ -8,9 +8,9 @@ . "${0:a:h}/_setup_script" -script/generate_version_info_for_swift - printf $'==> ✅ Testing mas %s\n' "$(script/version)" +script/generate_version_info_for_swift + script -q /dev/null swift test | (grep -vxE $'Test Suite \'.+\' (?:started|passed) at \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d{3}\\.?\\r|Test Case \'-\\[.+\\]\' (?:started|passed \\(\\d+\\.\\d+ seconds\\))\\.\\r|\\t Executed \\d+ tests?, with 0 failures \\(0 unexpected\\) in \\d+\\.\\d+ \\(\\d+\\.\\d+\\) seconds\\r' || true) From 6b3ed950f5a5ff0f5591d10ef1970bde053847be Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 10 Dec 2024 07:33:14 -0500 Subject: [PATCH 104/131] Remove act dependency & `.actrc`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .actrc | 8 -------- Brewfile | 1 - 2 files changed, 9 deletions(-) delete mode 100644 .actrc diff --git a/.actrc b/.actrc deleted file mode 100644 index cd64307fd..000000000 --- a/.actrc +++ /dev/null @@ -1,8 +0,0 @@ ---action-offline-mode ---eventpath .github/event.json ---container-architecture linux/amd64 ---log-prefix-job-id ---platform macos-15=-self-hosted ---pull=false ---reuse ---secret-file .secrets diff --git a/Brewfile b/Brewfile index 780f05016..a664c4421 100644 --- a/Brewfile +++ b/Brewfile @@ -1,4 +1,3 @@ -brew "act" brew "markdownlint-cli" brew "prettier" brew "shellcheck" From a37847866ca95daf59005c507fc565d309545046 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 10 Dec 2024 08:24:23 -0500 Subject: [PATCH 105/131] Remove debug output & associated env vars from `.github/workflows/release.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e8612336..14567c041 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,21 +13,11 @@ defaults: env: GH_TOKEN: ${{github.token}} HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} - RELEASE_BODY: ${{github.event.release.body}} - RELEASE_COMMITISH: ${{github.event.release.target_commitish}} - RELEASE_NAME: ${{github.event.release.name}} RELEASE_TAG: ${{github.event.release.tag_name}} jobs: release: runs-on: macos-15 steps: - - name: 🔈 Log real release event - # Run only for a real release event - if: ${{env.RELEASE_NAME}} - run: | - printf $'Triggered by release publication event:\nname: %s\ntag_name: %s\ntarget_commitish: %s\nbody:\n%s\n' \ - "${RELEASE_NAME}" "${RELEASE_TAG}" "${RELEASE_COMMITISH}" "${RELEASE_BODY}" - - name: 🛒 Checkout mas repo uses: actions/checkout@v4 From f322e00acbe1594c601f5b84a4f0244d47d422c0 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Tue, 10 Dec 2024 17:30:09 -0500 Subject: [PATCH 106/131] Simplify zsh scripts. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- script/format | 2 +- script/lint | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/format b/script/format index 766774ad3..db5fb8d36 100755 --- a/script/format +++ b/script/format @@ -13,7 +13,7 @@ printf $'==> 🚨 Formatting mas %s\n' "$(script/version)" for formatter in markdownlint prettier swift-format swiftformat swiftlint yamllint; do - if [[ ! -x "$(command -v "${formatter}")" ]]; then + if ! command -v "${formatter}" >/dev/null; then printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${formatter}" "${formatter}" >&2 exit 1 fi diff --git a/script/lint b/script/lint index 2cd587606..aafc21abe 100755 --- a/script/lint +++ b/script/lint @@ -17,7 +17,7 @@ printf $'==> 🚨 Linting mas %s\n' "$(script/version)" script/generate_version_info_for_swift for linter in git markdownlint periphery shellcheck swift-format swiftformat swiftlint yamllint; do - if [[ ! -x "$(command -v "${linter}")" ]]; then + if ! command -v "${linter}" >/dev/null; then printf $'error: %s is not installed. Run \'script/bootstrap\' or \'brew install %s\'.\n' "${linter}" "${linter}" >&2 exit 1 fi From 66826868ce771c1ef51c9b295a86fce04b76e98f Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 16 Dec 2024 08:59:54 -0500 Subject: [PATCH 107/131] `release.yml`: rename `RELEASE_TAG` as `TAG_NAME`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 14567c041..e884a4785 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ defaults: env: GH_TOKEN: ${{github.token}} HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} - RELEASE_TAG: ${{github.event.release.tag_name}} + TAG_NAME: ${{github.event.release.tag_name}} jobs: release: runs-on: macos-15 @@ -31,14 +31,14 @@ jobs: - name: 📤 Upload mas.pkg run: | - gh release upload "${RELEASE_TAG}" .build/mas.pkg + gh release upload "${TAG_NAME}" .build/mas.pkg - name: 🚰 Bump mas-cli/tap/mas formula run: | brew tap mas-cli/tap brew bump-formula-pr \ - --tag "${RELEASE_TAG}" \ - --revision "$(git rev-parse "${RELEASE_TAG}")" \ + --tag "${TAG_NAME}" \ + --revision "$(git rev-parse "${TAG_NAME}")" \ --no-fork \ --no-browse \ --online \ @@ -48,11 +48,11 @@ jobs: - name: 🍺 Bump homebrew-core/mas formula # Bump homebrew-core/mas formula only if not a prerelease; all prerelease versions contain a '-' - if: ${{!contains(env.RELEASE_TAG, '-')}} + if: ${{!contains(env.TAG_NAME, '-')}} run: | brew bump-formula-pr \ - --tag "${RELEASE_TAG}" \ - --revision "$(git rev-parse "${RELEASE_TAG}")" \ + --tag "${TAG_NAME}" \ + --revision "$(git rev-parse "${TAG_NAME}")" \ --fork-org mas-cli \ --no-browse \ --online \ From 7751dda90e89cdd38cf1224067f4eb4012326be3 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:01:03 -0500 Subject: [PATCH 108/131] `release.yml`: remove `*_TOKEN` env vars to check if they're necessary. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e884a4785..6e24ac486 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,8 +11,6 @@ defaults: # Force all run commands to not use Rosetta 2 shell: arch -arm64 /bin/zsh {0} env: - GH_TOKEN: ${{github.token}} - HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} TAG_NAME: ${{github.event.release.tag_name}} jobs: release: From 15053e6d2b129b6c0f2444e51d57f2e9cf6c95a8 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:02:15 -0500 Subject: [PATCH 109/131] `release.yml`: add & use `PRERELEASE` workflow-level env var. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e24ac486..338d8791a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,7 @@ defaults: # Force all run commands to not use Rosetta 2 shell: arch -arm64 /bin/zsh {0} env: + PRERELEASE: ${{contains(github.event.release.tag_name, '-') && '--prerelease' || ''}} TAG_NAME: ${{github.event.release.tag_name}} jobs: release: @@ -45,8 +46,7 @@ jobs: mas-cli/tap/mas - name: 🍺 Bump homebrew-core/mas formula - # Bump homebrew-core/mas formula only if not a prerelease; all prerelease versions contain a '-' - if: ${{!contains(env.TAG_NAME, '-')}} + if: ${{!env.PRERELEASE}} run: | brew bump-formula-pr \ --tag "${TAG_NAME}" \ From aa150fbd300f3e6dcf75e332b2c61c4f9a8e7369 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Mon, 16 Dec 2024 09:03:38 -0500 Subject: [PATCH 110/131] `release.yml`: run job iff repo is `mas-cli/mas`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 338d8791a..96c1c1279 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,7 @@ env: TAG_NAME: ${{github.event.release.tag_name}} jobs: release: + if: github.repository == 'mas-cli/mas' runs-on: macos-15 steps: - name: 🛒 Checkout mas repo From 00a7c0270c4c2354806c99d0b5a4c9648066b231 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:44:13 -0500 Subject: [PATCH 111/131] `release.yml`: run iff a tag is pushed to the `mas-cli/mas` repo. Delete any tags that lack a valid signature. Delete any version tags that are not on the main branch. Create a draft GitHub Release iff the package installer builds properly. Do not bump the `homebrew-core` `mas` formula. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 46 +++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96c1c1279..bf9934242 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,13 +4,14 @@ --- name: release on: - release: - types: [published] + push: + tags: ["**"] defaults: run: # Force all run commands to not use Rosetta 2 shell: arch -arm64 /bin/zsh {0} env: + DEFAULT_BRANCH_NAME: ${{github.event.repository.default_branch}} PRERELEASE: ${{contains(github.event.release.tag_name, '-') && '--prerelease' || ''}} TAG_NAME: ${{github.event.release.tag_name}} jobs: @@ -21,6 +22,30 @@ jobs: - name: 🛒 Checkout mas repo uses: actions/checkout@v4 + - name: 🖋 Delete tag lacking valid signature + run: | + if ! git tag -v "${TAG_NAME}" &>|/dev/null; then + printf $'Error: Deleting tag %s because it does not have a valid signature\n' "${TAG_NAME}" >&2 + git push -d origin "${TAG_NAME}" + exit 1 + fi + + - name: 🏷 Exit if not a version tag + run: | + if [[ ! "${TAG_NAME}" =~ '^v[[:digit:]]+(\.[[:digit:]]+)*(-(alpha|beta|rc)\.[[:digit:]]+)?$' ]]; then + printf $'Exiting because %s is not a version tag\n' "${TAG_NAME}" + exit 2 + fi + + - name: 🌳 Delete version tag not on main + run: | + if ! git merge-base --is-ancestor "${TAG_NAME}" "${DEFAULT_BRANCH_NAME}"; then + printf $'Error: Deleting version tag %s because it is not on the %s branch\n' "${TAG_NAME}" \ + "${DEFAULT_BRANCH_NAME}" >&2 + git push -d origin "${TAG_NAME}" + exit 3 + fi + - name: 👢 Bootstrap run: | script/bootstrap @@ -29,6 +54,10 @@ jobs: run: | script/package + - name: 📝 Create draft release + run: | + gh release create -d --generate-notes ${PRERELEASE} "${TAG_NAME}" + - name: 📤 Upload mas.pkg run: | gh release upload "${TAG_NAME}" .build/mas.pkg @@ -45,16 +74,3 @@ jobs: --strict \ --verbose \ mas-cli/tap/mas - - - name: 🍺 Bump homebrew-core/mas formula - if: ${{!env.PRERELEASE}} - run: | - brew bump-formula-pr \ - --tag "${TAG_NAME}" \ - --revision "$(git rev-parse "${TAG_NAME}")" \ - --fork-org mas-cli \ - --no-browse \ - --online \ - --strict \ - --verbose \ - mas From d5f9dba6b2ef74f6b11a685572a735b2f1ceec72 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:42:03 -0500 Subject: [PATCH 112/131] Make `Package/Distribution.plist` as close to .pkg contents as possible. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Package/Distribution.plist | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Package/Distribution.plist b/Package/Distribution.plist index 571cb27eb..95f4c93c8 100644 --- a/Package/Distribution.plist +++ b/Package/Distribution.plist @@ -1,7 +1,10 @@ - + - mas_components.pkg - + + + + #mas_components.pkg + From 8994505feca735bb7d266342e17fa173074d3343 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:53:19 -0500 Subject: [PATCH 113/131] Improve `script/package`: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename `mas.pkg` as `mas-${version}.pkg`. Use `/usr/local/bin` for `--install-location` instead of having executable stored in `.pkg` under `mas_components.pkg/Payload/usr/local/bin`. Do not output SHA-256 of `.pkg`. Move `script/build …` earlier. Rename variables & temporary folders to follow Apple's terminology. Update comments. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release.yml | 6 +++--- script/package | 23 ++++++++--------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf9934242..c6d12a239 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,7 +50,7 @@ jobs: run: | script/bootstrap - - name: 📦 Build universal executable & package it in mas.pkg + - name: 📦 Build universal executable & package it in an installer run: | script/package @@ -58,9 +58,9 @@ jobs: run: | gh release create -d --generate-notes ${PRERELEASE} "${TAG_NAME}" - - name: 📤 Upload mas.pkg + - name: 📤 Upload installer run: | - gh release upload "${TAG_NAME}" .build/mas.pkg + gh release upload "${TAG_NAME}" ".build/mas-${TAG_NAME#v}.pkg" - name: 🚰 Bump mas-cli/tap/mas formula run: | diff --git a/script/package b/script/package index aac675844..93a34252a 100755 --- a/script/package +++ b/script/package @@ -3,36 +3,29 @@ # script/package # mas # -# Builds macOS installer component and distribution packages. +# Builds .pkg installer. # . "${0:a:h}/_setup_script" +script/build --arch arm64 --arch x86_64 + build_dir=.build -distribution_package="${build_dir}/mas.pkg" -distributions_root="${build_dir}/distributions" +destination_root="${build_dir}/destination" version="$(script/version)" -script/build --arch arm64 --arch x86_64 - printf $'==> 📦 Assembling installer package for mas %s\n' "${version}" -ditto -v "${build_dir}/apple/Products/Release/mas" "${distributions_root}/usr/local/bin/mas" +ditto -v "${build_dir}/apple/Products/Release/mas" "${destination_root}/mas" -# Assemble macOS installer component package (aka product archive). pkgbuild \ --identifier com.mphys.mas-cli \ - --install-location / \ + --install-location /usr/local/bin \ --version "${version}" \ - --root "${distributions_root}" \ + --root "${destination_root}" \ "${build_dir}/mas_components.pkg" -# 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 Package/Distribution.plist \ --package-path "${build_dir}" \ - "${distribution_package}" - -printf $'==> 🔢 File Hash\n' -shasum -a 256 "${distribution_package}" + "${build_dir}/mas-${version}.pkg" From 9cab3e4498c2984f6971d4df139de61037ec2442 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Wed, 18 Dec 2024 20:47:19 -0500 Subject: [PATCH 114/131] Replace `Package/Distribution.plist` with a heredoc in `script/package`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- Package/Distribution.plist | 23 ----------------------- script/lint | 2 +- script/package | 28 +++++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 25 deletions(-) delete mode 100644 Package/Distribution.plist diff --git a/Package/Distribution.plist b/Package/Distribution.plist deleted file mode 100644 index 95f4c93c8..000000000 --- a/Package/Distribution.plist +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - #mas_components.pkg - - - - - - - - - - - - - - - - - diff --git a/script/lint b/script/lint index aafc21abe..9632678e3 100755 --- a/script/lint +++ b/script/lint @@ -38,7 +38,7 @@ for source in Package.swift Sources Tests; do done printf -- $'--> 🐚 ShellCheck\n' -shellcheck -s bash -o all -e SC2296,SC2301,SC2312 -a -P SCRIPTDIR script/**/*(.) +shellcheck -s bash -o all -e SC1088,SC2296,SC2301,SC2312 -a -P SCRIPTDIR script/**/*(.) ((exit_code |= ${?})) printf -- $'--> 〽️ Markdown\n' diff --git a/script/package b/script/package index 93a34252a..1c1bba9a0 100755 --- a/script/package +++ b/script/package @@ -25,7 +25,33 @@ pkgbuild \ --root "${destination_root}" \ "${build_dir}/mas_components.pkg" +# shellcheck disable=SC1036 productbuild \ - --distribution Package/Distribution.plist \ + --distribution =(cat <<'END' + + + + + + #mas_components.pkg + + + + + + + + + + + + + + + + + +END +) \ --package-path "${build_dir}" \ "${build_dir}/mas-${version}.pkg" From e4795b3dba7440d050b09d747ee172e755b5a6d7 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 00:15:50 -0500 Subject: [PATCH 115/131] Improve `README.md`: No longer include `script/bootstrap` in build instructions since it is only necessary for linting & formatting. Minor text improvements. Improve URLs. Replace `and` with `&`. Improve example console output. Wrap long line. Improve spacing. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- README.md | 55 ++++++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 4dfd0373c..ee463c8f7 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,10 @@ # mas -A command-line interface for the Mac App Store. Designed for scripting and automation. +A command-line interface for the Mac App Store. Designed for scripting & automation. [![GitHub Release](https://img.shields.io/github/v/release/mas-cli/mas.svg)](https://github.com/mas-cli/mas/releases) -[![Software License](https://img.shields.io/badge/license-MIT-lightgrey.svg)]( - https://github.com/mas-cli/mas/blob/main/LICENSE -) +[![Software License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](LICENSE) [![Swift 5](https://img.shields.io/badge/Language-Swift_5-orange.svg)](https://www.swift.org) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) [![Build, Test, & Lint](https://github.com/mas-cli/mas/actions/workflows/build-test.yml/badge.svg?branch=main)]( @@ -52,12 +50,13 @@ brew install mas-cli/tap/mas #### 🐙 GitHub Releases -Alternatively, binaries and sources are available from the [GitHub Releases](https://github.com/mas-cli/mas/releases). +Alternatively, binaries & sources are available from the [GitHub Releases](https://github.com/mas-cli/mas/releases). #### 🕊 Swift 5 Runtime Support -mas requires Swift 5 runtime support. macOS 10.14.4 (Mojave) and newer include it, but earlier releases do not. +mas requires Swift 5 runtime support. macOS 10.14.4 (Mojave) & newer include it, but earlier releases do not. Without it, running mas might report errors similar to: + > dyld: Symbol not found: _$s11SubSequenceSlTl To get Swift 5 support on macOS versions older than 10.14.4 (Mojave), you can: @@ -71,16 +70,16 @@ To get Swift 5 support on macOS versions older than 10.14.4 (Mojave), you can: ### 🪪 App IDs Each application in the Mac App Store has an integer app identifier (app ID). -mas commands accept app IDs as arguments and output App IDs to uniquely identify apps. +mas commands accept app IDs as arguments & output App IDs to uniquely identify apps. -`mas search` and `mas list` can be used to find the app IDs of relevant apps. +`mas search` & `mas list` can be used to find the app IDs of relevant apps. Alternatively, to find an app's app ID: 1. Find the app in the Mac App Store 2. Select `Share` > `Copy Link` -3. Extract the app ID from the URL. e.g., the Mac App Store URL for Xcode, - , has app ID `497799835` +3. Extract the app ID from the URL. e.g., the Mac App Store URL for Xcode + () has app ID `497799835` ### 🛍 Info from the Mac App Store @@ -106,7 +105,7 @@ $ mas search Xcode ```console $ mas info 497799835 -Xcode 16.0 [0.0] +Xcode 16.0 [Free] By: Apple Inc. Released: 2024-09-16 Minimum OS: 14.5 @@ -188,7 +187,9 @@ $ mas lucky Xcode All the commands in this section require you to be logged into an Apple ID in the Mac App Store. > mas only installs/upgrades applications from the Mac App Store. -Use [`softwareupdate(8)`] to install system updates (e.g., Xcode Command Line Tools, Safari, etc.) +> +> Use [`softwareupdate(8)`](https://www.unix.com/man-page/osx/8/softwareupdate) to install system updates (e.g., Xcode +> Command Line Tools, Safari, etc.) #### `mas upgrade` @@ -269,23 +270,16 @@ Over time, Apple has silently changed these frameworks, breaking some functional https://github.com/mas-cli/mas/issues/417 ) -### 👀 Version Consistency - -mas might be using suboptimal app version sources to compare local app versions with Mac App Store app versions. -That current sources are frequently consistent with the Mac App Store, but are infrequently inconsistent. -This might cause symptoms like [#384](https://github.com/mas-cli/mas/issues/384) and -[#387](https://github.com/mas-cli/mas/issues/387). mas will be updated soon to fix any such problems, if possible. - ### ⏳ Eventual Consistency The Mac App Store operates on eventual consistency, so the versions seen by various parts of mas or the Mac App Store -might be inconsistent for some period of time. This might cause symptoms like -[#384](https://github.com/mas-cli/mas/issues/384) and [#387](https://github.com/mas-cli/mas/issues/387). +might be inconsistent for short periods of time. This might cause symptoms like +[#384](https://github.com/mas-cli/mas/issues/384) & [#387](https://github.com/mas-cli/mas/issues/387). -### 📱 iOS and iPadOS Apps +### 📱 iOS & iPadOS Apps -Macs with Apple Silicon can install and run iOS and iPadOS apps from the Mac App Store. mas is not yet aware of these -apps, and is not yet able to install or upgrade them. [#321](https://github.com/mas-cli/mas/issues/321) +Apple Silicon Macs can install & run iOS & iPadOS apps from the Mac App Store. mas does not yet support such apps. +[#321](https://github.com/mas-cli/mas/issues/321) ### 📺 Using `tmux` @@ -319,18 +313,14 @@ All feedback is much appreciated! ✨ You can build from Xcode by opening the root mas directory, or from the Terminal: ```shell -script/bootstrap script/build ``` -Build output can be found in the `.build/` directory within the project. +Build output can be found in the `.build` directory within the project. ## ✅ Tests -The tests in this project are a recent work-in-progress. -Since Xcode does not officially support tests for command-line tool targets, -all logic is part of the mas target with tests in masTests. -Tests are written using [Quick]. +Tests are written using [Quick](https://github.com/Quick/Quick) & [Nimble](https://github.com/Quick/Nimble). ```shell script/test @@ -338,9 +328,8 @@ script/test ## 📄 License -mas was created by [@argon](https://github.com/argon). Code is under the [MIT license](LICENSE). +mas was created by [@argon](https://github.com/argon). + [homebrew-bundle]: https://github.com/Homebrew/homebrew-bundle -[`softwareupdate(8)`]: https://www.unix.com/man-page/osx/8/softwareupdate -[Quick]: https://github.com/Quick/Quick From 009583266701a188ecf575029df86fa2c2886604 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:24:10 -0500 Subject: [PATCH 116/131] Rename `release` workflow as `pushed-tag`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/{release.yml => tag-pushed.yml} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{release.yml => tag-pushed.yml} (97%) diff --git a/.github/workflows/release.yml b/.github/workflows/tag-pushed.yml similarity index 97% rename from .github/workflows/release.yml rename to .github/workflows/tag-pushed.yml index c6d12a239..0d352c845 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/tag-pushed.yml @@ -1,8 +1,8 @@ # -# .github/workflows/release.yml +# .github/workflows/tag-pushed.yml # --- -name: release +name: tag-pushed on: push: tags: ["**"] @@ -15,7 +15,7 @@ env: PRERELEASE: ${{contains(github.event.release.tag_name, '-') && '--prerelease' || ''}} TAG_NAME: ${{github.event.release.tag_name}} jobs: - release: + tag-pushed: if: github.repository == 'mas-cli/mas' runs-on: macos-15 steps: From c43b1ba313c39d4bbbd81cd853407717cfb25a18 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:25:13 -0500 Subject: [PATCH 117/131] Don't call `script/bootstrap` from `tag-pushed.yml` as it isn't necessary for building. Improve `script/bootstrap` documentation. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 4 ---- script/bootstrap | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index 0d352c845..785c32e62 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -46,10 +46,6 @@ jobs: exit 3 fi - - name: 👢 Bootstrap - run: | - script/bootstrap - - name: 📦 Build universal executable & package it in an installer run: | script/package diff --git a/script/bootstrap b/script/bootstrap index d21785941..63c4eba02 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -3,7 +3,7 @@ # script/bootstrap # mas # -# Installs development dependencies and builds project dependencies. +# Installs dependencies for script/format & script/lint. # # Usage: bootstrap [...] # From 4fb49d92ed0a80fc1483b2c871bc3008d6d132c8 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:28:14 -0500 Subject: [PATCH 118/131] Replace `TAG_NAME` with `GITHUB_REF_NAME` in `tag-pushed.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index 785c32e62..50d1b0bef 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -13,7 +13,6 @@ defaults: env: DEFAULT_BRANCH_NAME: ${{github.event.repository.default_branch}} PRERELEASE: ${{contains(github.event.release.tag_name, '-') && '--prerelease' || ''}} - TAG_NAME: ${{github.event.release.tag_name}} jobs: tag-pushed: if: github.repository == 'mas-cli/mas' @@ -24,25 +23,25 @@ jobs: - name: 🖋 Delete tag lacking valid signature run: | - if ! git tag -v "${TAG_NAME}" &>|/dev/null; then - printf $'Error: Deleting tag %s because it does not have a valid signature\n' "${TAG_NAME}" >&2 - git push -d origin "${TAG_NAME}" + if ! git tag -v "${GITHUB_REF_NAME}" &>|/dev/null; then + printf $'Error: Deleting tag %s because it does not have a valid signature\n' "${GITHUB_REF_NAME}" >&2 + git push -d origin "${GITHUB_REF_NAME}" exit 1 fi - name: 🏷 Exit if not a version tag run: | - if [[ ! "${TAG_NAME}" =~ '^v[[:digit:]]+(\.[[:digit:]]+)*(-(alpha|beta|rc)\.[[:digit:]]+)?$' ]]; then - printf $'Exiting because %s is not a version tag\n' "${TAG_NAME}" + if [[ ! "${GITHUB_REF_NAME}" =~ '^v[[:digit:]]+(\.[[:digit:]]+)*(-(alpha|beta|rc)\.[[:digit:]]+)?$' ]]; then + printf $'Exiting because %s is not a version tag\n' "${GITHUB_REF_NAME}" exit 2 fi - name: 🌳 Delete version tag not on main run: | - if ! git merge-base --is-ancestor "${TAG_NAME}" "${DEFAULT_BRANCH_NAME}"; then - printf $'Error: Deleting version tag %s because it is not on the %s branch\n' "${TAG_NAME}" \ + if ! git merge-base --is-ancestor "${GITHUB_REF_NAME}" "${DEFAULT_BRANCH_NAME}"; then + printf $'Error: Deleting version tag %s because it is not on the %s branch\n' "${GITHUB_REF_NAME}" \ "${DEFAULT_BRANCH_NAME}" >&2 - git push -d origin "${TAG_NAME}" + git push -d origin "${GITHUB_REF_NAME}" exit 3 fi @@ -52,18 +51,18 @@ jobs: - name: 📝 Create draft release run: | - gh release create -d --generate-notes ${PRERELEASE} "${TAG_NAME}" + gh release create -d --generate-notes ${PRERELEASE} "${GITHUB_REF_NAME}" - name: 📤 Upload installer run: | - gh release upload "${TAG_NAME}" ".build/mas-${TAG_NAME#v}.pkg" + gh release upload "${GITHUB_REF_NAME}" ".build/mas-${GITHUB_REF_NAME#v}.pkg" - name: 🚰 Bump mas-cli/tap/mas formula run: | brew tap mas-cli/tap brew bump-formula-pr \ - --tag "${TAG_NAME}" \ - --revision "$(git rev-parse "${TAG_NAME}")" \ + --tag "${GITHUB_REF_NAME}" \ + --revision "$(git rev-parse "${GITHUB_REF_NAME}")" \ --no-fork \ --no-browse \ --online \ From 42ab8a579e690cc453712e3298a27cefa7047fb8 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:31:36 -0500 Subject: [PATCH 119/131] Inline single `PRERELEASE` use in `tag-pushed.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index 50d1b0bef..5b1529195 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -12,7 +12,6 @@ defaults: shell: arch -arm64 /bin/zsh {0} env: DEFAULT_BRANCH_NAME: ${{github.event.repository.default_branch}} - PRERELEASE: ${{contains(github.event.release.tag_name, '-') && '--prerelease' || ''}} jobs: tag-pushed: if: github.repository == 'mas-cli/mas' @@ -51,7 +50,7 @@ jobs: - name: 📝 Create draft release run: | - gh release create -d --generate-notes ${PRERELEASE} "${GITHUB_REF_NAME}" + gh release create -d --generate-notes ${"${GITHUB_REF_NAME//[^-]/}":+-p} "${GITHUB_REF_NAME}" - name: 📤 Upload installer run: | From 4f96d96d2df13d7a1505cf34ce7f8c053f0a3cf0 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:32:31 -0500 Subject: [PATCH 120/131] =?UTF-8?q?Move=20`DEFAULT=5FBRANCH=5FNAME`=20envi?= =?UTF-8?q?ronment=20variable=20from=20top=20level=20to=20`=F0=9F=9A=B0=20?= =?UTF-8?q?Bump=20mas-cli/tap/mas=20formula`=20step.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index 5b1529195..aeffe3686 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -10,8 +10,6 @@ defaults: run: # Force all run commands to not use Rosetta 2 shell: arch -arm64 /bin/zsh {0} -env: - DEFAULT_BRANCH_NAME: ${{github.event.repository.default_branch}} jobs: tag-pushed: if: github.repository == 'mas-cli/mas' @@ -36,6 +34,8 @@ jobs: fi - name: 🌳 Delete version tag not on main + env: + DEFAULT_BRANCH_NAME: ${{github.event.repository.default_branch}} run: | if ! git merge-base --is-ancestor "${GITHUB_REF_NAME}" "${DEFAULT_BRANCH_NAME}"; then printf $'Error: Deleting version tag %s because it is not on the %s branch\n' "${GITHUB_REF_NAME}" \ From 96243f29f89a4366aef39f99575ab3f1283d55cb Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:33:20 -0500 Subject: [PATCH 121/131] Replace `$(git rev-parse "${GITHUB_REF_NAME}")` with `${GITHUB_SHA}` in `tag-pushed.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index aeffe3686..a9d1f96c7 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -61,7 +61,7 @@ jobs: brew tap mas-cli/tap brew bump-formula-pr \ --tag "${GITHUB_REF_NAME}" \ - --revision "$(git rev-parse "${GITHUB_REF_NAME}")" \ + --revision "${GITHUB_SHA}" \ --no-fork \ --no-browse \ --online \ From f9ec6bb84f2bfdac01f3a872b493f355313d7233 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:47:28 -0500 Subject: [PATCH 122/131] Add `GH_TOKEN` environment variable to `tag-pushed` job in `tag-pushed.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index a9d1f96c7..3086e4db1 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -14,6 +14,8 @@ jobs: tag-pushed: if: github.repository == 'mas-cli/mas' runs-on: macos-15 + env: + GH_TOKEN: ${{github.token}} steps: - name: 🛒 Checkout mas repo uses: actions/checkout@v4 From 61e473e93c161759e096783d435c693973915198 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:04:14 -0500 Subject: [PATCH 123/131] =?UTF-8?q?Add=20`HOMEBREW=5FGITHUB=5FAPI=5FTOKEN`?= =?UTF-8?q?=20environment=20variable=20to=20`=F0=9F=9A=B0=20Bump=20mas-cli?= =?UTF-8?q?/tap/mas=20formula`=20step=20in=20`tag-pushed`=20job=20in=20`ta?= =?UTF-8?q?g-pushed.yml`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index 3086e4db1..0ba7cfdcb 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -59,6 +59,8 @@ jobs: gh release upload "${GITHUB_REF_NAME}" ".build/mas-${GITHUB_REF_NAME#v}.pkg" - name: 🚰 Bump mas-cli/tap/mas formula + env: + HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | brew tap mas-cli/tap brew bump-formula-pr \ From 567a3307358b95413b8e3076bbfc23c4fb555c31 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 20 Dec 2024 04:10:00 -0500 Subject: [PATCH 124/131] Fix tag verification steps in `tag-pushed.yml`. Avoid warning from checkout step. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index 0ba7cfdcb..e2f907862 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -18,11 +18,20 @@ jobs: GH_TOKEN: ${{github.token}} steps: - name: 🛒 Checkout mas repo + env: + GIT_CONFIG_COUNT: 1 + GIT_CONFIG_KEY_0: init.defaultBranch + GIT_CONFIG_VALUE_0: ${{github.event.repository.default_branch}} uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: 🖋 Delete tag lacking valid signature run: | - if ! git tag -v "${GITHUB_REF_NAME}" &>|/dev/null; then + git fetch --tags --force + if [[ \ + "$(git cat-file tag "${GITHUB_REF_NAME}")" != *'-----BEGIN SSH SIGNATURE-----'*'-----END SSH SIGNATURE-----' \ + ]]; then printf $'Error: Deleting tag %s because it does not have a valid signature\n' "${GITHUB_REF_NAME}" >&2 git push -d origin "${GITHUB_REF_NAME}" exit 1 @@ -39,6 +48,7 @@ jobs: env: DEFAULT_BRANCH_NAME: ${{github.event.repository.default_branch}} run: | + git fetch --force origin "${DEFAULT_BRANCH_NAME}:${DEFAULT_BRANCH_NAME}" if ! git merge-base --is-ancestor "${GITHUB_REF_NAME}" "${DEFAULT_BRANCH_NAME}"; then printf $'Error: Deleting version tag %s because it is not on the %s branch\n' "${GITHUB_REF_NAME}" \ "${DEFAULT_BRANCH_NAME}" >&2 From bbdf8f17dc1a6bce7afe3ee65b6c8de26d818328 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:20:33 -0500 Subject: [PATCH 125/131] Use tag name & tag message in release title. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index e2f907862..aa3852b6c 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -62,7 +62,12 @@ jobs: - name: 📝 Create draft release run: | - gh release create -d --generate-notes ${"${GITHUB_REF_NAME//[^-]/}":+-p} "${GITHUB_REF_NAME}" + gh release create\ + -d\ + -t "${GITHUB_REF_NAME}: ${$(git tag -l "${GITHUB_REF_NAME}" --format='%(contents)')%%$'\n'*}"\ + --generate-notes\ + ${"${GITHUB_REF_NAME//[^-]/}":+ -p}\ + "${GITHUB_REF_NAME}" - name: 📤 Upload installer run: | From ac5856e7d55e45ed9b7b2523bc37c332a537bbda Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:22:06 -0500 Subject: [PATCH 126/131] Spacing in `tag-pushed.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index aa3852b6c..e5237b98e 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -29,9 +29,9 @@ jobs: - name: 🖋 Delete tag lacking valid signature run: | git fetch --tags --force - if [[ \ - "$(git cat-file tag "${GITHUB_REF_NAME}")" != *'-----BEGIN SSH SIGNATURE-----'*'-----END SSH SIGNATURE-----' \ - ]]; then + if [[\ + "$(git cat-file tag "${GITHUB_REF_NAME}")" != *'-----BEGIN SSH SIGNATURE-----'*'-----END SSH SIGNATURE-----'\ + ]]; then printf $'Error: Deleting tag %s because it does not have a valid signature\n' "${GITHUB_REF_NAME}" >&2 git push -d origin "${GITHUB_REF_NAME}" exit 1 @@ -50,8 +50,8 @@ jobs: run: | git fetch --force origin "${DEFAULT_BRANCH_NAME}:${DEFAULT_BRANCH_NAME}" if ! git merge-base --is-ancestor "${GITHUB_REF_NAME}" "${DEFAULT_BRANCH_NAME}"; then - printf $'Error: Deleting version tag %s because it is not on the %s branch\n' "${GITHUB_REF_NAME}" \ - "${DEFAULT_BRANCH_NAME}" >&2 + printf $'Error: Deleting version tag %s because it is not on the %s branch\n' "${GITHUB_REF_NAME}"\ + "${DEFAULT_BRANCH_NAME}" >&2 git push -d origin "${GITHUB_REF_NAME}" exit 3 fi @@ -78,12 +78,12 @@ jobs: HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} run: | brew tap mas-cli/tap - brew bump-formula-pr \ - --tag "${GITHUB_REF_NAME}" \ - --revision "${GITHUB_SHA}" \ - --no-fork \ - --no-browse \ - --online \ - --strict \ - --verbose \ - mas-cli/tap/mas + brew bump-formula-pr\ + --tag "${GITHUB_REF_NAME}"\ + --revision "${GITHUB_SHA}"\ + --no-fork\ + --no-browse\ + --online\ + --strict\ + --verbose\ + mas-cli/tap/mas From b069658bc3c60d7513a1c5c66ad7cb19bea9add5 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 21 Dec 2024 11:03:11 -0500 Subject: [PATCH 127/131] Cleanup `actions/checkout@v4` step in `danger.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/danger.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 5c5c60f2f..0eecad573 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -10,7 +10,9 @@ jobs: danger: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 + - name: Danger uses: docker://ghcr.io/danger/danger-swift:3.20.2 with: From fa018e7b3dc96fa8d2cc94b5a871f03740bd1cef Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 21 Dec 2024 11:35:42 -0500 Subject: [PATCH 128/131] Include zsh options in GitHub workflows. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/build-test.yml | 2 +- .github/workflows/tag-pushed.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 04b4056b3..6bfc533de 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -18,7 +18,7 @@ jobs: defaults: run: # Force all run commands to not use Rosetta 2 - shell: arch -arm64 /bin/zsh {0} + shell: arch -arm64 /bin/zsh -Negku {0} steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index e5237b98e..1b4ffabde 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -9,7 +9,7 @@ on: defaults: run: # Force all run commands to not use Rosetta 2 - shell: arch -arm64 /bin/zsh {0} + shell: arch -arm64 /bin/zsh -Negku {0} jobs: tag-pushed: if: github.repository == 'mas-cli/mas' From 2b92c5db3ded30e84c6ce9ad3aa4cfa87495e7ac Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 21 Dec 2024 12:16:55 -0500 Subject: [PATCH 129/131] Improve git fetching in `tag-pushed.yml`. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index 1b4ffabde..1cf087f19 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -23,12 +23,10 @@ jobs: GIT_CONFIG_KEY_0: init.defaultBranch GIT_CONFIG_VALUE_0: ${{github.event.repository.default_branch}} uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: 🖋 Delete tag lacking valid signature run: | - git fetch --tags --force + git fetch --force origin "${GITHUB_REF}:${GITHUB_REF}" if [[\ "$(git cat-file tag "${GITHUB_REF_NAME}")" != *'-----BEGIN SSH SIGNATURE-----'*'-----END SSH SIGNATURE-----'\ ]]; then From a3a00fc9be75f6b269fa5b6f6a69184860c01a32 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sat, 21 Dec 2024 23:27:20 -0500 Subject: [PATCH 130/131] Fix workflows. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/release-published.yml | 39 ++++++++++++++++++++ .github/workflows/tag-pushed.yml | 49 ++++++++++++++----------- 2 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/release-published.yml diff --git a/.github/workflows/release-published.yml b/.github/workflows/release-published.yml new file mode 100644 index 000000000..807f0bb7c --- /dev/null +++ b/.github/workflows/release-published.yml @@ -0,0 +1,39 @@ +# +# .github/workflows/release-published.yml +# +--- +name: release-published +on: + release: + types: [published] +defaults: + run: + # Force all run commands to not use Rosetta 2 + shell: arch -arm64 /bin/zsh -Negku {0} +jobs: + release-published: + if: ${{!github.event.repository.fork}} + runs-on: macos-15 + steps: + - name: 🚰 Apply pr-pull label to custom tap formula bump PR + env: + GH_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}} + run: | + gh release -R "${GITHUB_REPOSITORY}" download "${GITHUB_REF_NAME}" -p bump.url + gh pr edit "$(&1)" + exit_code="${?}" + setopt errexit + printf $'%s' "${bump_output}" + printf $'%s' "${${(f)bump_output}[-1]}" > .build/bump.url + exit "${exit_code}" + + - name: 📝 Create draft release + env: + GH_TOKEN: ${{github.token}} + run: | + gh release create\ + "${GITHUB_REF_NAME}"\ + ".build/mas-${GITHUB_REF_NAME#v}.pkg"\ + .build/bump.url\ + -d\ + -t "${GITHUB_REF_NAME}: ${$(git tag -l "${GITHUB_REF_NAME}" --format='%(contents)')%%$'\n'*}"\ + --generate-notes\ + ${"${GITHUB_REF_NAME//[^-]/}":+ -p} From 82e28104c67808553ab83569db620beceb28b615 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 22 Dec 2024 16:49:06 -0500 Subject: [PATCH 131/131] Removed unnecessary quoting. Partial #638 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .github/workflows/tag-pushed.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tag-pushed.yml b/.github/workflows/tag-pushed.yml index 4b88df0e7..d67640ace 100644 --- a/.github/workflows/tag-pushed.yml +++ b/.github/workflows/tag-pushed.yml @@ -76,8 +76,8 @@ jobs: 2>&1)" exit_code="${?}" setopt errexit - printf $'%s' "${bump_output}" - printf $'%s' "${${(f)bump_output}[-1]}" > .build/bump.url + printf %s "${bump_output}" + printf %s "${${(f)bump_output}[-1]}" > .build/bump.url exit "${exit_code}" - name: 📝 Create draft release