Merge pull request #510 from mas-cli/gha/release-workflow

This commit is contained in:
Ben Chatelain 2024-03-31 13:41:09 -06:00 committed by GitHub
commit 08c6c9874a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 1008 additions and 437 deletions

8
.actrc Normal file
View file

@ -0,0 +1,8 @@
--action-offline-mode
--eventpath .github/event.json
--container-architecture linux/amd64
--log-prefix-job-id
--platform macos-14=-self-hosted
--pull=false
--reuse
--secret-file .secrets

View file

@ -27,6 +27,7 @@ indent_style = tab
# JSON files contain newlines inconsistently
[*.json]
indent_size = 2
insert_final_newline = ignore
# Makefiles always use tabs for indentation

View file

@ -1,4 +1,5 @@
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
---
version: 2
updates:
- package-ecosystem: "github-actions"

12
.github/event.json vendored Normal file
View file

@ -0,0 +1,12 @@
{
"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)"
}
}

11
.github/release.yml vendored
View file

@ -1,12 +1,13 @@
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
---
changelog:
categories:
- title: '🚀 Features'
- title: "🚀 Features"
labels:
- '🆕 feature request'
- title: '🐛 Bug Fixes'
- "🆕 feature request"
- title: "🐛 Bug Fixes"
labels:
- '🐛 bug'
- "🐛 bug"
- title: Changes
labels:
- '*'
- "*"

View file

@ -1,53 +0,0 @@
#
# .github/workflows/build-test.yml
#
# https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
name: Build, Test, and Lint
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-test:
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/virtual-environments/issues/2187#issuecomment-790507204
shell: arch -arm64 bash --noprofile --norc -eo pipefail {0}
name: Build, Test, and Lint
# https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
# https://github.com/mas-cli/mas/actions/runners
runs-on: macos-14
steps:
# https://github.com/actions/checkout#usage
- 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
- name: Build
run: script/build
- name: Test
run: script/test
- name: Lint
run: script/lint

View file

@ -1,17 +1,21 @@
name: Danger
#
# .github/workflows/danger.yml
#
# https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
---
name: danger
on:
pull_request:
branches: [ main ]
branches: [main]
jobs:
danger:
name: Danger
runs-on: ubuntu-latest
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.12.3
with:
args: --failOnErrors --no-publish-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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
with:
args: --failOnErrors --no-publish-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

35
.github/workflows/pr-checks.yml vendored Normal file
View file

@ -0,0 +1,35 @@
#
# .github/workflows/pr-checks.yml
#
# https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
---
name: pr-checks
on:
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-test:
runs-on: macos-14
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/virtual-environments/issues/2187#issuecomment-790507204
shell: arch -arm64 bash --noprofile --norc -eo pipefail {0}
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: Build
run: script/build
- name: Test
run: script/test

113
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,113 @@
#
# .github/workflows/release.yml
#
---
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}
on:
release:
types: [published]
jobs:
start:
runs-on: macos-14
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.
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 "DRY_RUN=false" >>$GITHUB_ENV
echo "MAS_VERSION=${{ github.event.release.tag_name }}" >>${GITHUB_ENV}
echo "RELEASE_COMMIT=${{ github.event.release.target_commitish }}" >>${GITHUB_ENV}
- name: 🔈 Log environment variables
run: |
echo "DRY_RUN: ${DRY_RUN}"
echo "MAS_VERSION: ${MAS_VERSION}"
echo "RELEASE_COMMIT: ${RELEASE_COMMIT}"
pkg-installer:
runs-on: macos-14
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
# Important to trigger a universal build first as package just works with
# the `mas` binary in finds in the build dir.
- name: 🏗️ Build Universal
run: |
script/build --universal
- name: 📦 macOS Package
run: |
script/package
- name: 🚀 Upload mas.pkg
if: ${{ env.DRY_RUN == 'false' }}
run: |
gh release upload ${MAS_VERSION} \
.build/mas.pkg
homebrew-core:
runs-on: macos-14
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: 🍺 Update Homebrew mas formula
run: |
DRY_RUN=${{ env.DRY_RUN }} \
script/brew_core_update ${{ env.MAS_VERSION }}
homebrew-tap:
runs-on: macos-14
needs: [start, homebrew-core]
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: 🚰 Update mas tap formula
run: |
DRY_RUN=${{ env.DRY_RUN }} \
script/brew_tap_update ${{ env.MAS_VERSION }}
- name: 🍼 Homebrew Bottles for mas tap
run: |
script/bottle
- name: 🚀 Upload Bottles
if: ${{ env.DRY_RUN == 'false' }}
run: |
gh release upload ${MAS_VERSION} \
.build/bottles/mas-*.bottle.tar.gz

3
.gitignore vendored
View file

@ -26,6 +26,7 @@
.envrc
.fseventsd
.rubygems/
.secrets
.swiftpm/
Carthage/
DerivedData
@ -33,7 +34,7 @@ Pods/
Temporary Items
bin/
build/
gha/
default.profraw
releases/
xcuserdata
Sources/MasKit/Package.swift

View file

@ -1,20 +0,0 @@
#
# .hound.yml
# mas
#
# http://help.houndci.com/configuration/swiftlint
#
---
fail_on_violations: false
erblint:
enabled: false
rubocop:
enabled: false
shellcheck:
enabled: true
swiftlint:
enabled: false

11
.mise.toml Normal file
View file

@ -0,0 +1,11 @@
#
# .mise.toml
# https://mise.jdx.dev/configuration.html
#
[tools]
act = "0.2.60"
"npm:prettier" = "3.2.5"
[settings]
experimental = true

View file

@ -1,2 +1,3 @@
---
retain_public: true
strict: true

View file

@ -4,12 +4,10 @@
#
# https://github.com/realm/SwiftLint#configuration
#
---
disabled_rules:
- trailing_comma
- trailing_comma
excluded:
- docs
- docs
opening_brace:
allow_multiline_func: true

View file

@ -1,49 +0,0 @@
#
# .travis.yml
# mas-cli
#
# https://travis-ci.com/mas-cli/mas
# https://docs.travis-ci.com/user/reference/osx/
# https://docs.travis-ci.com/user/languages/objective-c/
#
# https://docs.travis-ci.com/user/build-config-validation
version: ~> 1.0
# https://docs.travis-ci.com/user/reference/osx/#macos-version
os: osx
osx_image: xcode11.5 # macOS 10.15.4
env:
global:
- LANG=en_US.UTF-8
- LC_ALL=en_US.UTF-8
- LANGUAGE=en_US.UTF-8
# Bundler 2
# https://docs.travis-ci.com/user/languages/ruby/#bundler-20
before_install:
- gem install bundler
install:
- script/bootstrap
script:
- script/build
- script/test
- bundle exec danger
before_deploy:
- script/package
deploy:
provider: releases
api_key:
secure: SEAdxkLeRJ/z7cO4Y//8sxrYbNlzz3W4ip717gcMsuxp6LzsQtS7QW+/N3iSNuowgIKqTad0ZdiYHczwa+mTI/rjPDP1mxC4Bx+pQpZN+bizY9MNVcDDTSD6yCvI1vZl+dLQwUKKzW/lTKDk4yunOmxLV4xtDE7EDfyf1Zkypx0mQ6SoG2cFHZVDrDrU4c05oPtD/3dTvq2lVf5suBhjrRNLSOpIU4fPgc3PbPCL1MtIZRQpGfVPGWZLRMOHLXNIKFkP1qaa6Z2+R1iZjtqZ5isECikRNSPeBYm7OWx/EoGqRbC64YVIjTKi17rjEHDf46RxskPKa4Df6i2X4HCzhZBKcVB/Zu4HpjaR8gMcTCT0QnfHpDDgyAMVBPW84uyhfJ93GJaK7vk5NebY6IWg4d/mrisZ5XA4o6EXZSOSTbrZEZDn+2Knp9IIad169YYymo6ESr4zFwfxXG516ozYi8ROuWP0ZR+wxgBkm3b2mvryABgye45k/yqX/8Pd7RD/wB03RTOKkog4gQkyhrR9VSpuSVXfAm89Qg4Y+nzdDNoSR8i9xKN/c+rXFMnmuTItwiIqE30Nb58dISt2BEpFzDRh00ae1kOZ3coC0WsqW7hmdk46QvhhEOIYGVYOlUDU/8BownV37alfAiiQV0tjEwX7YMV+6qwraKmdnjOWISk=
file:
- mas-cli.zip
- mas.xcarchive.zip
skip_cleanup: true
on:
repo: mas-cli/mas
tags: true

17
.yamllint.yml Normal file
View file

@ -0,0 +1,17 @@
# https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration
---
extends: default
locale: en_US.UTF-8
ignore-from-file: .gitignore
rules:
line-length:
max: 120
level: warning
# https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.truthy
truthy:
allowed-values: ["true", "false"]
check-keys: false
# Disables fallse positives on GHA workflow `on:`
level: warning

View file

@ -1,4 +1,6 @@
brew "markdownlint-cli"
brew "mise"
brew "sd"
brew "shellcheck"
brew "shfmt"
brew "swiftformat"

View file

@ -2,132 +2,265 @@
"entries": {
"brew": {
"markdownlint-cli": {
"version": "0.32.2",
"version": "0.39.0",
"bottle": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"all": {
"arm64_sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:7be52e16473a658becde9b817f86c868bcb9e41e79856d9dce542218b9515860",
"sha256": "7be52e16473a658becde9b817f86c868bcb9e41e79856d9dce542218b9515860"
"url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:7bc1310bfbeff34386c2b309988569bc6494b333edf9bf26d027fbecc1342c2f",
"sha256": "7bc1310bfbeff34386c2b309988569bc6494b333edf9bf26d027fbecc1342c2f"
},
"arm64_ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:7bc1310bfbeff34386c2b309988569bc6494b333edf9bf26d027fbecc1342c2f",
"sha256": "7bc1310bfbeff34386c2b309988569bc6494b333edf9bf26d027fbecc1342c2f"
},
"arm64_monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:7bc1310bfbeff34386c2b309988569bc6494b333edf9bf26d027fbecc1342c2f",
"sha256": "7bc1310bfbeff34386c2b309988569bc6494b333edf9bf26d027fbecc1342c2f"
},
"sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:0af1b50fb5bef4a0c47e1bd233e39262586885b48bc4c5a60592c5f42c2edf9f",
"sha256": "0af1b50fb5bef4a0c47e1bd233e39262586885b48bc4c5a60592c5f42c2edf9f"
},
"ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:0af1b50fb5bef4a0c47e1bd233e39262586885b48bc4c5a60592c5f42c2edf9f",
"sha256": "0af1b50fb5bef4a0c47e1bd233e39262586885b48bc4c5a60592c5f42c2edf9f"
},
"monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:0af1b50fb5bef4a0c47e1bd233e39262586885b48bc4c5a60592c5f42c2edf9f",
"sha256": "0af1b50fb5bef4a0c47e1bd233e39262586885b48bc4c5a60592c5f42c2edf9f"
},
"x86_64_linux": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/markdownlint-cli/blobs/sha256:7bc1310bfbeff34386c2b309988569bc6494b333edf9bf26d027fbecc1342c2f",
"sha256": "7bc1310bfbeff34386c2b309988569bc6494b333edf9bf26d027fbecc1342c2f"
}
}
}
},
"mise": {
"version": "2024.3.11",
"bottle": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"arm64_sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:2ccc2946ac8d9af9fdde8ce0ef8d9271010eee24f8824086134533480b95b69f",
"sha256": "2ccc2946ac8d9af9fdde8ce0ef8d9271010eee24f8824086134533480b95b69f"
},
"arm64_ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:8e87fe7f49fa24545c99bcefc1fd1a22edfa6426b8c59e349bd445ced8544dd2",
"sha256": "8e87fe7f49fa24545c99bcefc1fd1a22edfa6426b8c59e349bd445ced8544dd2"
},
"arm64_monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:2c0deb90ea8214e22f4f10fa53ef8d90b66c769f4784807ce99614c6c3a97b43",
"sha256": "2c0deb90ea8214e22f4f10fa53ef8d90b66c769f4784807ce99614c6c3a97b43"
},
"sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:458438873c3a621d77849261f7ef57173670bdf0a64e018592e1682685be28ce",
"sha256": "458438873c3a621d77849261f7ef57173670bdf0a64e018592e1682685be28ce"
},
"ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:55196d84f5fc7d1b56dd03943dd8744a23e064b78928ebc4de85d8659a71c9ca",
"sha256": "55196d84f5fc7d1b56dd03943dd8744a23e064b78928ebc4de85d8659a71c9ca"
},
"monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:31c0c0ca68d7b2d3d12492c97a7e36547c88cddc8c6e195a3a4fb7b443a74f31",
"sha256": "31c0c0ca68d7b2d3d12492c97a7e36547c88cddc8c6e195a3a4fb7b443a74f31"
},
"x86_64_linux": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/mise/blobs/sha256:97e003f7841847029e38986685ec809b9a6eab9b66409e6baad4e568860a23aa",
"sha256": "97e003f7841847029e38986685ec809b9a6eab9b66409e6baad4e568860a23aa"
}
}
}
},
"sd": {
"version": "1.0.0",
"bottle": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"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.8.0",
"version": "0.10.0",
"bottle": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"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:625466bcd245a36da12ee088877d582c7e9fec1622418d1165a7d7d8f204ecc3",
"sha256": "625466bcd245a36da12ee088877d582c7e9fec1622418d1165a7d7d8f204ecc3"
"url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:d5e8407806dbf757e71930ce2cb9b0d23bae286f0c058d9ff246d851dd7aa871",
"sha256": "d5e8407806dbf757e71930ce2cb9b0d23bae286f0c058d9ff246d851dd7aa871"
},
"arm64_big_sur": {
"sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:883ba5ee45554568cd1ce106dc6c090ec0745f576a4a6708332de951b03c7423",
"sha256": "883ba5ee45554568cd1ce106dc6c090ec0745f576a4a6708332de951b03c7423"
"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:cfd8c8e8d8927dfd4b83593f539690a6083b075b0a1ff8a66578e8bb810d3db9",
"sha256": "cfd8c8e8d8927dfd4b83593f539690a6083b075b0a1ff8a66578e8bb810d3db9"
},
"big_sur": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:d88edc1ae7db555ec5da01d4a1272da8260eb62073d2cdfa5fa3dce37d51fbe6",
"sha256": "d88edc1ae7db555ec5da01d4a1272da8260eb62073d2cdfa5fa3dce37d51fbe6"
},
"catalina": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:24a67cd4f2b66a02cb77a1c705d7dcf25b4410209435a0b1136398da1fa6f766",
"sha256": "24a67cd4f2b66a02cb77a1c705d7dcf25b4410209435a0b1136398da1fa6f766"
"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:961b2f3d75cf86dd5bc767cf689eee8f8e88bb30d716cf208b4bb89d61e5a553",
"sha256": "961b2f3d75cf86dd5bc767cf689eee8f8e88bb30d716cf208b4bb89d61e5a553"
"url": "https://ghcr.io/v2/homebrew/core/shellcheck/blobs/sha256:6d0867f144686a5caa025cb15ecac49286654b78e7b89979a54eedc9a0cc9b6b",
"sha256": "6d0867f144686a5caa025cb15ecac49286654b78e7b89979a54eedc9a0cc9b6b"
}
}
}
},
"shfmt": {
"version": "3.5.1",
"version": "3.8.0",
"bottle": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"arm64_sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:78a5017f23e2d4b9fd9312ce1e4e06c09cfb838d47e78cfb02ddb4190acb6b34",
"sha256": "78a5017f23e2d4b9fd9312ce1e4e06c09cfb838d47e78cfb02ddb4190acb6b34"
},
"arm64_ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:78a5017f23e2d4b9fd9312ce1e4e06c09cfb838d47e78cfb02ddb4190acb6b34",
"sha256": "78a5017f23e2d4b9fd9312ce1e4e06c09cfb838d47e78cfb02ddb4190acb6b34"
},
"arm64_monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:633116b598a60ad576a79753208e13388f6a2460139c8aca44e5a25befdb017c",
"sha256": "633116b598a60ad576a79753208e13388f6a2460139c8aca44e5a25befdb017c"
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:78a5017f23e2d4b9fd9312ce1e4e06c09cfb838d47e78cfb02ddb4190acb6b34",
"sha256": "78a5017f23e2d4b9fd9312ce1e4e06c09cfb838d47e78cfb02ddb4190acb6b34"
},
"arm64_big_sur": {
"sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:1b0653c0a44f7db5e78c5c6d67de534a52c4f588fb65e3acbb8211d06b871bd9",
"sha256": "1b0653c0a44f7db5e78c5c6d67de534a52c4f588fb65e3acbb8211d06b871bd9"
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:0d7952151f13e850fa40b03d6ba3f39daa8ec9401735aa91d6cd8e950f880d62",
"sha256": "0d7952151f13e850fa40b03d6ba3f39daa8ec9401735aa91d6cd8e950f880d62"
},
"ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:0d7952151f13e850fa40b03d6ba3f39daa8ec9401735aa91d6cd8e950f880d62",
"sha256": "0d7952151f13e850fa40b03d6ba3f39daa8ec9401735aa91d6cd8e950f880d62"
},
"monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:e7168603f81cf1357c2460c5c476fa66bf5421183d4dedeafe9cf38550fe8855",
"sha256": "e7168603f81cf1357c2460c5c476fa66bf5421183d4dedeafe9cf38550fe8855"
},
"big_sur": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:0e0683566d83cceecd4d02596e3c899a640918ff067b6e15e10f8aee424f1759",
"sha256": "0e0683566d83cceecd4d02596e3c899a640918ff067b6e15e10f8aee424f1759"
},
"catalina": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:4fabb118ba0da244f2b0ffe280b28e343712fac23e738ddf1db29fad68526d73",
"sha256": "4fabb118ba0da244f2b0ffe280b28e343712fac23e738ddf1db29fad68526d73"
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:0d7952151f13e850fa40b03d6ba3f39daa8ec9401735aa91d6cd8e950f880d62",
"sha256": "0d7952151f13e850fa40b03d6ba3f39daa8ec9401735aa91d6cd8e950f880d62"
},
"x86_64_linux": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:faa60f70812132e10f94477676499a1e2bacb0d06fbe437e8480a997695c2203",
"sha256": "faa60f70812132e10f94477676499a1e2bacb0d06fbe437e8480a997695c2203"
"url": "https://ghcr.io/v2/homebrew/core/shfmt/blobs/sha256:772a5dfe3e281fc51f6200313fb62b454314bf4978a8fe70ba2026a4fe5af5c4",
"sha256": "772a5dfe3e281fc51f6200313fb62b454314bf4978a8fe70ba2026a4fe5af5c4"
}
}
}
},
"swiftformat": {
"version": "0.49.18",
"version": "0.53.5",
"bottle": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"arm64_sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:04e089d4b1ae1217dd6c8133b3c661add56d7c4f4f24ee67becd3cf8f54e6e80",
"sha256": "04e089d4b1ae1217dd6c8133b3c661add56d7c4f4f24ee67becd3cf8f54e6e80"
},
"arm64_ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:19a6ce102e7df1cdee150dee619025aa3b2a4980070bee4f8cdd6976c0936d46",
"sha256": "19a6ce102e7df1cdee150dee619025aa3b2a4980070bee4f8cdd6976c0936d46"
},
"arm64_monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:6362f6087bc3821f4271c3d17b3a4f180b1e1326646ddfb60f6d27bfb5a2a357",
"sha256": "6362f6087bc3821f4271c3d17b3a4f180b1e1326646ddfb60f6d27bfb5a2a357"
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:745ba037da0e1fe62f2f22faa45a17655b89d8870bacd9db32597ce1fd779509",
"sha256": "745ba037da0e1fe62f2f22faa45a17655b89d8870bacd9db32597ce1fd779509"
},
"arm64_big_sur": {
"sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:e94cf1b66df0d712bbfbf509b98efaf31d39a61b82999314e1f3c0e45195c51a",
"sha256": "e94cf1b66df0d712bbfbf509b98efaf31d39a61b82999314e1f3c0e45195c51a"
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:6830f0bd5d06dca19d2bcd614e6d0c87e7a3d703d33bce90d0448a83310dddcc",
"sha256": "6830f0bd5d06dca19d2bcd614e6d0c87e7a3d703d33bce90d0448a83310dddcc"
},
"ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:dacbfeca6cbe99fc73448f08c0289f135e807bc220ac1dcb61952410f1b43535",
"sha256": "dacbfeca6cbe99fc73448f08c0289f135e807bc220ac1dcb61952410f1b43535"
},
"monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:456e0c95a565adbb45a29747abfadf41c838a7f09fae052a874e59429a94ef14",
"sha256": "456e0c95a565adbb45a29747abfadf41c838a7f09fae052a874e59429a94ef14"
},
"big_sur": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:d00204be714789fa8b35d4c6f6eea5813604aa09f3911635059973aa827d2e8c",
"sha256": "d00204be714789fa8b35d4c6f6eea5813604aa09f3911635059973aa827d2e8c"
},
"catalina": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:b07f7221f3c5225ad0037293cecb95bde4f0dba4fa19797d84a3376dd1ad02ea",
"sha256": "b07f7221f3c5225ad0037293cecb95bde4f0dba4fa19797d84a3376dd1ad02ea"
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:a5e30f5378aca201ca8bc7a350ebac28b3202366be1b37cf254f77c27761753a",
"sha256": "a5e30f5378aca201ca8bc7a350ebac28b3202366be1b37cf254f77c27761753a"
},
"x86_64_linux": {
"cellar": "/home/linuxbrew/.linuxbrew/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:c4a4ebd2f3f54b8f399551efaf47b3e419db2c729ffaf18a09e64bbf62d82f38",
"sha256": "c4a4ebd2f3f54b8f399551efaf47b3e419db2c729ffaf18a09e64bbf62d82f38"
"url": "https://ghcr.io/v2/homebrew/core/swiftformat/blobs/sha256:909ae79dbe735c9377355e202d07a58aeff1af1707ba7a3c843cf7c3b10f68a9",
"sha256": "909ae79dbe735c9377355e202d07a58aeff1af1707ba7a3c843cf7c3b10f68a9"
}
}
}
@ -135,12 +268,12 @@
},
"tap": {
"peripheryapp/periphery": {
"revision": "020a0b79994d454dbc8dbd886009137fd741b836"
"revision": "4f73aefe6e01ba2543b9ee50f7653d866784fd61"
}
},
"cask": {
"periphery": {
"version": "2.9.0",
"version": "2.18.0",
"options": {
"full_name": "periphery"
}
@ -149,21 +282,13 @@
},
"system": {
"macos": {
"monterey": {
"HOMEBREW_VERSION": "3.5.3-75-g39c9e2d",
"sonoma": {
"HOMEBREW_VERSION": "4.2.15-75-g221fde4",
"HOMEBREW_PREFIX": "/opt/homebrew",
"Homebrew/homebrew-core": "00e5383db36fddc6b26df896229289b42462e63e",
"CLT": "13.4.0.0.1.1651278267",
"Xcode": "13.4.1",
"macOS": "12.4"
},
"ventura": {
"HOMEBREW_VERSION": "3.6.2-17-g0b602f6",
"HOMEBREW_PREFIX": "/opt/homebrew",
"Homebrew/homebrew-core": "9f43be0861992b9109035ac00e999f66598ba6c2",
"CLT": "14.0.0.0.1.1661618636",
"Xcode": "14.0",
"macOS": "13.0"
"Homebrew/homebrew-core": "api",
"CLT": "15.3.0.0.1.1708646388",
"Xcode": "15.3",
"macOS": "14.4.1"
}
}
}

112
Makefile
View file

@ -50,7 +50,7 @@ help: ## (default) Displays this message
################################################################################
#
# Targets
# Info Targets
#
.PHONY: version
@ -65,26 +65,40 @@ 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: updateHeaders
updateHeaders: ## Updates private headers.
script/update_headers
.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: build-universal
build-universal: ## Builds a "fat" universal binary.
script/build --universal
.PHONY: test
test: build ## Runs tests.
script/test
@ -94,41 +108,14 @@ test: build ## Runs tests.
run: build
${EXECUTABLE_DIRECTORY}/${CMD_NAME} $(ARGS)
.PHONY: install
install: build ## Installs the project.
script/install $(PREFIX)
.PHONY: update-headers
update-headers: ## Updates private macOS headers.
script/update_headers
.PHONY: install-universal
install-universal: build-universal ## Installs a universal binary.
script/install --universal
.PHONY: uninstall
uninstall: ## Uninstalls the project.
script/uninstall
.PHONY: format
format: ## Formats source code.
script/format
.PHONY: lint
lint: ## Lints source code.
script/lint
.PHONY: danger
danger: ## Runs danger.
script/danger
.PHONY: bottle
bottle: ## Builds Homebrew bottle for the current system.
script/bottle
.PHONY: package
package: build ## Packages the project.
script/package
.PHONY: packageInstall
packageInstall: package ## Installs the package.
script/package_install
################################################################################
#
# 🕊️ Swift Package Targets
#
.PHONY: describe
describe: ## Describes the Swift package.
@ -145,3 +132,44 @@ dependencies: resolve ## Lists SwiftPM 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
.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: bottle
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: ## Builds Homebrew bottle for the current system.
script/brew_release_validate

View file

@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git",
"state": {
"branch": null,
"revision": "35f9e770f54ce62dd8526470f14c6e137cef3eea",
"version": "2.1.1"
"revision": "3b123999de19bf04905bc1dfdb76f817b0f2cc00",
"version": "2.1.2"
}
},
{
@ -24,8 +24,8 @@
"repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state": {
"branch": null,
"revision": "c21f7bab5ca8eee0a9998bbd17ca1d0eb45d4688",
"version": "2.1.0"
"revision": "dc9af4781f2afdd1e68e90f80b8603be73ea7abc",
"version": "2.2.0"
}
},
{
@ -42,8 +42,8 @@
"repositoryURL": "https://github.com/mxcl/PromiseKit.git",
"state": {
"branch": null,
"revision": "43772616c46a44a9977e41924ae01d0e55f2f9ca",
"version": "6.18.1"
"revision": "8a98e31a47854d3180882c8068cc4d9381bf382d",
"version": "6.22.1"
}
},
{

View file

@ -0,0 +1,4 @@
// Generated by: script/version
enum Package {
static let version = "1.8.6"
}

View file

@ -4,8 +4,9 @@
#
# https://github.com/realm/SwiftLint#configuration
#
---
disabled_rules:
- force_cast
- force_try
- function_body_length
- force_cast
- force_try
- function_body_length

View file

@ -6,14 +6,47 @@
# Installs development dependencies and builds project dependencies.
#
function usage {
echo "Usage: bootstrap [-f]"
echo " -f option enables frozen mode"
exit 1
}
frozen=''
# Detect presence of `-f` frozen option
while getopts "f" opt; do
case "${opt}" in
f)
frozen='-f'
;;
*)
usage 1>&2
;;
esac
done
main() {
script/clean
echo "==> 👢 Bootstrapping"
# Install Homebrew tools
rm -f Brewfile.lock.json
brew bundle install --no-upgrade --verbose
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
if [[ ! -x "$(command -v mise)" ]]; then
brew install mise
fi
mise settings set experimental true
mise install --verbose
mise list --verbose
# Already installed on GitHub Actions runner.
if [[ ! -x "$(command -v swiftlint)" ]]; then

View file

@ -14,8 +14,9 @@
# Variables
#
BUILD_DIR="$PWD/.build"
BOTTLE_DIR="$BUILD_DIR/bottles"
BUILD_DIR="${PWD}/.build"
BOTTLE_DIR="${BUILD_DIR}/bottles"
CORE_TAP_PATH="$(brew --repository homebrew/core)"
MAS_VERSION=$(script/version)
ROOT_URL="https://github.com/mas-cli/mas/releases/download/v${MAS_VERSION}"
@ -36,34 +37,34 @@ 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'))"
# 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"
echo "CURRENT_OS_VERSION_MAJOR: ${CURRENT_OS_VERSION_MAJOR}"
echo "CURRENT_OS_VERSION_MINOR: ${CURRENT_OS_VERSION_MINOR}"
case "${CURRENT_OS_VERSION_MAJOR}" in
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 better."
exit 1
;;
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 better."
exit 1
;;
esac
# Prefix platform with architecture
@ -107,23 +108,23 @@ echo "==> 🍼 Bottling mas ${MAS_VERSION} 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
brew bottle --verbose --no-rebuild --root-url="${ROOT_URL}" mas-cli/tap/mas
if ! test -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 "<BREW_HOME>/Library/Taps/homebrew/homebrew-core"
echo "${CORE_TAP_PATH}"
exit 1
fi
SHA256=$(shasum --algorithm 256 "${OLD_FILENAME}" | cut -f 1 -d ' ' -)
mkdir -p "$BOTTLE_DIR"
mkdir -p "${BOTTLE_DIR}"
# Start of bottle block
BOTTLE_BLOCK=$(
cat <<-EOF
bottle do
root_url "$ROOT_URL"
root_url "${ROOT_URL}"
EOF
)
@ -139,10 +140,10 @@ 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"
sha256 cellar: :any_skip_relocation, ${os}: "${SHA256}"
EOF
)
done
@ -160,5 +161,3 @@ ls -l "${BOTTLE_DIR}"
echo "${BOTTLE_BLOCK}"
brew remove mas-cli/tap/mas
open "${BOTTLE_DIR}"

11
script/brew_build_interactive Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash -e
#
# script/brew_build_interactive
# mas
#
# https://docs.brew.sh/Formula-Cookbook#check-the-build-system
#
HOMEBREW_NO_INSTALL_FROM_API=1 \
brew reinstall \
--interactive mas

204
script/brew_core_update Executable file
View file

@ -0,0 +1,204 @@
#!/bin/bash -e
#
# script/brew_core_update
# mas
#
# Updates mas Homebrew core formula:
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/mas.rb
#
# brew bump-formula-pr --help
#
CORE_TAP_PATH="$(brew --repository homebrew/core)"
CORE_FORMULA_PATH="${CORE_TAP_PATH}/Formula/"
CORE_MAS_FORMULA_PATH="${CORE_FORMULA_PATH}/m/mas.rb"
PROJECT_PATH="$(git rev-parse --show-toplevel)"
SWIFT_PACKAGE="${PROJECT_PATH}/Sources/MasKit/Package.swift"
LOCAL_MAS_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas.rb"
LOCAL_TAP_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas-tap.rb"
function usage {
echo "Usage: brew_core_update [-d] v0.0 [sha1_hash]"
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
}
# Max 3 arguments
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'
;;
*)
usage 1>&2
;;
esac
done
shift $((OPTIND - 1))
# DRY_RUN environment variable
# shellcheck disable=SC2153
if [[ $DRY_RUN == 'true' ]]; then
echo='echo (DRY-RUN):'
dry_run='-d'
fi
# arg 1 - version tag
if [[ -n "${1}" ]]; then
MAS_VERSION="${1}"
else
MAS_VERSION="v$(script/version)"
fi
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
echo "REVISION: ${REVISION}"
################################################################################
#
# Update Version
#
script/version_bump "${MAS_VERSION}" "$REVISION"
branch_name="releases/release-${MAS_VERSION}"
$echo git branch "${branch_name}"
$echo git switch "${branch_name}"
$echo git add \
"${SWIFT_PACKAGE}" \
"${LOCAL_MAS_FORMULA_PATH}" \
"${LOCAL_TAP_FORMULA_PATH}"
$echo git commit --message="🔖 Version ${MAS_VERSION}"
################################################################################
#
# 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 "${LOCAL_MAS_FORMULA_PATH}" "${CORE_MAS_FORMULA_PATH}"
# 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 "Checking to see if this update can be a simple bump."
# diff "${LOCAL_MAS_FORMULA_PATH}" "${CORE_MAS_FORMULA_PATH}"
echo "==> 🧪 Updating homebrew-core formula mas (${MAS_VERSION}, ${REVISION})"
if [[ $dry_run == '-d' ]]; then
# -n, --dry-run Print what would be done rather than doing
# it.
# --write-only Make the expected file modifications without
# taking any Git actions.
dry_run="--dry-run"
fi
echo "Validating formula"
brew bump-formula-pr \
--tag="${MAS_VERSION}" \
--revision="${REVISION}" \
--strict \
--verbose \
"${dry_run}" \
mas
# brew exit status
status=$?
if [[ ${status} -ne 0 ]]; then
echo "Formula did not validate using 'brew bump-formula-pr'"
exit ${status}
fi
pushd "${CORE_FORMULA_PATH}"
echo "Updating homebrew/core formula with a PR"
$echo brew bump-formula-pr \
--tag="${MAS_VERSION}" \
--revision="${REVISION}" \
--commit \
--fork-org mas-cli \
--online \
--strict \
--verbose \
"${dry_run}" \
mas
popd
################################################################################
#
# Create pr on mas-cli/mas
#
$echo gh pr create \
--assignee phatblat \
--base main \
--draft \
--fill

View file

@ -1,77 +0,0 @@
#!/bin/bash -e
#
# script/brew_formula_update
# mas
#
# Updates mas Homebrew core formula:
# https://github.com/Homebrew/homebrew-core/blob/master/Formula/mas.rb
#
# brew bump-formula-pr --help
#
BREW_CORE_PATH="$(brew --prefix)/Library/Taps/homebrew/homebrew-core/Formula"
function usage {
echo "Usage: brew_formula_bump [v1.0] [sha1_hash]"
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
}
# arg 1 - version tag
if test -n "$1"; then
MAS_VERSION="$1"
else
MAS_VERSION="v$(script/version)"
fi
# arg 2 - revision (commit hash)
if test -n "$2"; then
REVISION="$2"
else
REVISION=$(git rev-parse "$MAS_VERSION")
fi
echo "Checking to see if this update can be a simple bump."
diff "Homebrew/mas.rb" "$BREW_CORE_PATH/mas.rb"
# diff exit status
status=$?
formula_revisions=0
if test $status -ne 0; then
echo "There are changes in the local formula (Homebrew/mas.rb) that haven't been released yet."
#exit $status
formula_revisions=1
fi
echo "==> 🧪 Updating homebrew-core formula mas ($MAS_VERSION, $REVISION)"
echo "Validating formula"
brew bump-formula-pr \
--tag="$MAS_VERSION" \
--revision="$REVISION" \
--strict \
mas
# brew exit status
status=$?
if test $status -ne 0; then
echo "Formula did not validate using 'brew bump-formula-pr'"
exit $status
fi
pushd "$BREW_CORE_PATH" || exit 2
echo "Updating formula"
if test $formula_revisions -eq 1; then
# Options to
dry_run="--dry-run --write"
fi
brew bump-formula-pr \
--tag="$MAS_VERSION" \
--revision="$REVISION" \
--strict \
--verbose \
"$dry_run" \
mas

118
script/brew_tap_update Executable file
View file

@ -0,0 +1,118 @@
#!/bin/bash -e
#
# script/brew_tap_update
# mas
#
# Updates mas custom tap formula:
# https://github.com/mas-cli/homebrew-tap/blob/main/Formula/mas.rb
#
MAS_TAP_PATH="$(brew --repository mas-cli/tap)"
MAS_TAP_PATH_FORMULA="${MAS_TAP_PATH}/Formula/mas.rb"
PROJECT_PATH="$(git rev-parse --show-toplevel)"
LOCAL_TAP_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas-tap.rb"
function usage {
echo "Usage: brew_tap_update [-d] v0.0 [sha1_hash]"
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
}
# Max 3 arguments
if [[ $# -gt 3 ]]; then
usage 1>&2
fi
echo='echo'
# Detect presence of `-d` dry run option
while getopts "d" o; do
case "${o}" in
d)
echo='echo (DRY-RUN):'
;;
*)
usage 1>&2
;;
esac
done
# DRY_RUN environment variable
# shellcheck disable=SC2153
if [[ $DRY_RUN == 'true' ]]; then
echo='echo (DRY-RUN):'
fi
# arg 1 - version tag
if [[ -n "${1}" ]]; then
MAS_VERSION="${1}"
else
MAS_VERSION="v$(script/version)"
fi
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
echo "REVISION: ${REVISION}"
################################################################################
#
# Update Version
#
branch_name="releases/release-${MAS_VERSION}"
$echo git switch "${branch_name}"
################################################################################
#
# Create branch on mas-cli/homebrew-tap
#
# Ensure mas is tapped
if ! [[ -d "${MAS_TAP_PATH}" ]]; then
brew tap mas-cli/tap
fi
pushd "${MAS_TAP_PATH}"
branch_name="releases/release-${MAS_VERSION}"
$echo git branch "${branch_name}"
$echo git switch "${branch_name}"
# Update tap formula version
cp -v "${LOCAL_TAP_FORMULA_PATH}" "${MAS_TAP_PATH_FORMULA}"
$echo git add \
"${MAS_TAP_PATH_FORMULA}"
$echo git commit --message="🔖 Version ${MAS_VERSION}"
popd
# Build in mas project
script/bottle
################################################################################
#
# Create PR on mas-cli/homebrew-tap
#
pushd "${MAS_TAP_PATH}"
$echo gh pr create \
--assignee phatblat \
--base main \
--draft \
--fill
popd

View file

@ -1,14 +0,0 @@
#!/bin/bash -e
#
# script/build_artifacts
# mas
#
# Runs all related scripts for generating all artifacts.
#
MAS_VERSION=$(script/version)
echo "Updating mas $MAS_VERSION Homebrew formula"
script/brew_formula_update
script/bottle

View file

@ -13,18 +13,13 @@
echo "==> 🚨 Formatting mas"
for LINTER in markdownlint shfmt swiftformat swiftlint; do
for LINTER in markdownlint prettier shfmt swiftformat swiftlint yamllint; do
if [[ ! -x "$(command -v ${LINTER})" ]]; then
echo "error: ${LINTER} is not installed. Run 'script/bootstrap' or 'brew install ${LINTER}'."
exit 1
fi
done
echo
echo "--> 🖊 Markdown"
markdownlint --config .markdownlint.json --fix .github .
echo
echo "--> 🕊️ Swift"
for SOURCE in Package.swift Sources Tests; do
swiftformat ${SOURCE}
@ -32,8 +27,17 @@ for SOURCE in Package.swift Sources Tests; do
swiftlint lint --fix --strict ${SOURCE}
done
echo
echo "--> 📜 Bash"
shfmt -i 2 -l -w contrib/ script/
echo "--> 〽️ Markdown"
markdownlint --config .markdownlint.json --fix .github .
script/lint
echo "--> 🖊 YAML"
# shellcheck disable=SC2046
prettier --write $(yamllint --list-files .)
echo "--> 📜 Bash"
shfmt \
--write \
--list \
--indent 2 \
--case-indent \
contrib/ script/

View file

@ -12,21 +12,13 @@
echo "==> 🚨 Linting mas"
for LINTER in git markdownlint periphery shfmt swiftformat swiftlint; do
for LINTER in git markdownlint periphery shfmt swiftformat swiftlint yamllint; do
if [[ ! -x "$(command -v ${LINTER})" ]]; then
echo "error: ${LINTER} is not installed. Run 'script/bootstrap' or 'brew install ${LINTER}'."
exit 1
fi
done
echo "--> 🌳 Git"
git diff --check
echo
echo "--> 🖊 Markdown"
markdownlint --config .markdownlint.json .github .
echo
echo "--> 🕊️ Swift"
for SOURCE in Package.swift Sources Tests; do
swiftformat --lint ${SOURCE}
@ -35,7 +27,20 @@ for SOURCE in Package.swift Sources Tests; do
done
periphery scan
echo
echo "--> 🌳 Git"
git diff --check
echo "--> 〽️ Markdown"
markdownlint --config .markdownlint.json .github .
echo "--> 🖊 YAML"
yamllint .
echo "--> 📜 Bash"
shellcheck --shell=bash script/*
shfmt -d -i 2 -l contrib/ script/
shfmt \
--diff \
--list \
--indent 2 \
--case-indent \
contrib/ script/

View file

@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/bash -ue
#
# script/version
# mas
@ -6,19 +6,10 @@
# Displays the current marketing version of mas.
#
# This no longer works with MARKETING_VERSION build setting in Info.plist
# agvtool what-marketing-version -terse1
MAS_VERSION=$(git describe --abbrev=0 --tags)
if git describe >/dev/null 2>&1; then
last_tag=$(git describe --abbrev=0 --tags 2>/dev/null || true)
# Use MAS_VERSION environment varible unless unset
MAS_VERSION=${MAS_VERSION:-$last_tag}
fi
MAS_VERSION=${MAS_VERSION#v}
SCRIPT_PATH=$(dirname "$(which "$0")")
cat <<EOF >"${SCRIPT_PATH}/../Sources/MasKit/Package.swift"
// Generated by: script/version
enum Package {
static let version = "${MAS_VERSION}"
}
EOF
echo "${MAS_VERSION}"

56
script/version_bump Executable file
View file

@ -0,0 +1,56 @@
#!/bin/bash -e
#
# script/version_bump
# mas
#
# Increments the marketing version of mas.
#
PROJECT_PATH="$(git rev-parse --show-toplevel)"
PACKAGE_MANIFEST="${PROJECT_PATH}/Sources/MasKit/Package.swift"
LOCAL_MAS_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas.rb"
LOCAL_TAP_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas-tap.rb"
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"
exit 1
}
if [[ $# -lt 1 ]]; then
usage
fi
# arg 1 - version tag
if test -n "${1}"; then
MAS_VERSION=${1}
fi
# arg 2 - revision (commit hash)
if test -n "${2}"; then
REVISION="${2}"
else
REVISION=$(git rev-parse "${MAS_VERSION}")
fi
echo "MAS_VERSION: ${MAS_VERSION}"
echo "REVISION: ${REVISION}"
# Write new version into swift package
cat <<EOF >"${PACKAGE_MANIFEST}"
// Generated by: script/version
enum Package {
static let version = "${MAS_VERSION#v}"
}
EOF
echo
cat "${PACKAGE_MANIFEST}"
# 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}"
done