updated homebrew installer to include cask and ci tests
This commit is contained in:
parent
0d9a887e0a
commit
aea8bc54c2
8 changed files with 222 additions and 65 deletions
122
scripts/generate-homebrew-cask.sh
Executable file
122
scripts/generate-homebrew-cask.sh
Executable file
|
|
@ -0,0 +1,122 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'USAGE'
|
||||
Usage: scripts/generate-homebrew-cask.sh \
|
||||
--version VERSION \
|
||||
--github-repo OWNER/REPO \
|
||||
--arm-dmg PATH \
|
||||
--intel-dmg PATH \
|
||||
--output PATH
|
||||
|
||||
Generates a Homebrew cask for GitComet from macOS DMG artifacts.
|
||||
USAGE
|
||||
}
|
||||
|
||||
version=""
|
||||
github_repo=""
|
||||
arm_dmg=""
|
||||
intel_dmg=""
|
||||
out_path=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--version)
|
||||
version="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--github-repo)
|
||||
github_repo="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--arm-dmg)
|
||||
arm_dmg="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--intel-dmg)
|
||||
intel_dmg="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--output)
|
||||
out_path="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown arg: $1" >&2
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$version" || -z "$github_repo" || -z "$arm_dmg" || -z "$intel_dmg" || -z "$out_path" ]]; then
|
||||
echo "All arguments are required." >&2
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if ! [[ "$github_repo" =~ ^[^/]+/[^/]+$ ]]; then
|
||||
echo "Invalid --github-repo '$github_repo'. Expected OWNER/REPO." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ! -f "$arm_dmg" ]]; then
|
||||
echo "arm DMG not found: $arm_dmg" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$intel_dmg" ]]; then
|
||||
echo "intel DMG not found: $intel_dmg" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sha256_file() {
|
||||
local file="$1"
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
sha256sum "$file" | awk '{print $1}'
|
||||
return
|
||||
fi
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$file" | awk '{print $1}'
|
||||
return
|
||||
fi
|
||||
echo "No SHA256 tool found (sha256sum or shasum required)." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
arm_sha="$(sha256_file "$arm_dmg")"
|
||||
intel_sha="$(sha256_file "$intel_dmg")"
|
||||
|
||||
mkdir -p "$(dirname "$out_path")"
|
||||
|
||||
cat > "$out_path" <<EOF2
|
||||
cask "gitcomet" do
|
||||
arch arm: "arm64", intel: "x86_64"
|
||||
|
||||
version "${version}"
|
||||
sha256 arm: "${arm_sha}", intel: "${intel_sha}"
|
||||
|
||||
url "https://github.com/${github_repo}/releases/download/v#{version}/gitcomet-v#{version}-macos-#{arch}.dmg"
|
||||
name "GitComet"
|
||||
desc "Fast, resource-efficient Git GUI written in Rust"
|
||||
homepage "https://github.com/${github_repo}"
|
||||
|
||||
depends_on macos: ">= :ventura"
|
||||
|
||||
app "GitComet.app"
|
||||
|
||||
caveats do
|
||||
<<~EOS
|
||||
Optional CLI:
|
||||
brew install gitcomet-cli
|
||||
EOS
|
||||
end
|
||||
end
|
||||
EOF2
|
||||
|
||||
echo "Generated Homebrew cask: $out_path"
|
||||
|
|
@ -110,8 +110,8 @@ linux_name="$(basename "$linux_tar")"
|
|||
mkdir -p "$(dirname "$out_path")"
|
||||
|
||||
cat > "$out_path" <<EOF2
|
||||
class Gitcomet < Formula
|
||||
desc "Fast, resource-efficient Git GUI written in Rust"
|
||||
class GitcometCli < Formula
|
||||
desc "GitComet command-line binary"
|
||||
homepage "https://github.com/${github_repo}"
|
||||
version "${version}"
|
||||
license "AGPL-3.0-only"
|
||||
|
|
@ -136,33 +136,7 @@ class Gitcomet < Formula
|
|||
end
|
||||
|
||||
def install
|
||||
if OS.mac?
|
||||
libexec.install "GitComet.app"
|
||||
bin.install_symlink libexec/"GitComet.app/Contents/MacOS/gitcomet"
|
||||
else
|
||||
bin.install "gitcomet"
|
||||
end
|
||||
end
|
||||
|
||||
def post_install
|
||||
return unless OS.mac?
|
||||
|
||||
target_app = libexec/"GitComet.app"
|
||||
return unless target_app.exist?
|
||||
|
||||
apps_dir = Pathname.new(File.expand_path("~/Applications"))
|
||||
apps_dir.mkpath unless apps_dir.exist?
|
||||
|
||||
launcher_link = apps_dir/"GitComet.app"
|
||||
if launcher_link.exist? && !launcher_link.symlink?
|
||||
opoo "Skipping ~/Applications/GitComet.app link because a non-symlink path already exists."
|
||||
return
|
||||
end
|
||||
|
||||
launcher_link.unlink if launcher_link.symlink?
|
||||
launcher_link.make_symlink(target_app)
|
||||
rescue StandardError => e
|
||||
opoo "Failed to link GitComet.app into ~/Applications: #{e}"
|
||||
bin.install "gitcomet"
|
||||
end
|
||||
|
||||
test do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue