From 50a67baf03a39bf777259cce5934affcdf2a867d Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Wed, 12 Jan 2022 21:27:40 +0100 Subject: [PATCH] feat(misc): add scripts to publish homebrew cask --- scripts/publish_homebrew_version.sh | 43 +++++++++++++++++++++ scripts/resources/macos/formula_template.rb | 19 +++++++++ 2 files changed, 62 insertions(+) create mode 100755 scripts/publish_homebrew_version.sh create mode 100644 scripts/resources/macos/formula_template.rb diff --git a/scripts/publish_homebrew_version.sh b/scripts/publish_homebrew_version.sh new file mode 100755 index 0000000..7c378ae --- /dev/null +++ b/scripts/publish_homebrew_version.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -e + +if [[ -z "$VERSION" ]]; then + echo "Missing target VERSION environment variable, please specify it" + exit 1 +fi + +# Removing the v suffix, if present +VERSION=${VERSION#"v"} + +rm -Rf target/homebrew +mkdir -p target/homebrew/artifacts + +echo "Targeting version $VERSION" +echo "Downloading macOS artifacts" + +gh release download v$VERSION --pattern "Espanso-Mac*" --dir target/homebrew/artifacts + +echo "Reading artifacts hashes" +INTEL_SHA=$(cat target/homebrew/artifacts/Espanso-Mac-Intel.zip.sha256.txt | awk -F ' ' '{print $1}') +M1_SHA=$(cat target/homebrew/artifacts/Espanso-Mac-M1.zip.sha256.txt | awk -F ' ' '{print $1}') + +echo "Cloning tap repository" + +pushd target/homebrew +git clone git@github.com:espanso/homebrew-espanso.git + +pushd homebrew-espanso +echo "Rendering formula template" + +cat ../../../scripts/resources/macos/formula_template.rb | sed "s/{{{VERSION}}}/$VERSION/g" | \ + sed "s/{{{INTEL_SHA}}}/$INTEL_SHA/g" | sed "s/{{{M1_SHA}}}/$M1_SHA/g" > ./Casks/espanso.rb + +echo "Committing version update" +git add Casks/espanso.rb +git commit -m "Version bump: $VERSION" + +echo "Pushing changes" +git push + +echo "Done!" \ No newline at end of file diff --git a/scripts/resources/macos/formula_template.rb b/scripts/resources/macos/formula_template.rb new file mode 100644 index 0000000..7a3e299 --- /dev/null +++ b/scripts/resources/macos/formula_template.rb @@ -0,0 +1,19 @@ +cask "espanso" do + version "{{{VERSION}}}" + + if Hardware::CPU.intel? + url "https://github.com/federico-terzi/espanso/releases/download/v#{version}/Espanso-Mac-Intel.zip" + sha256 "{{{INTEL_SHA}}}" + else + url "https://github.com/federico-terzi/espanso/releases/download/v#{version}/Espanso-Mac-M1.zip" + sha256 "{{{M1_SHA}}}" + end + + name "Espanso" + desc "A Privacy-first, Cross-platform Text Expander" + homepage "https://espanso.org/" + + app "Espanso.app" + + zap trash: "~/Library/Caches/espanso" +end \ No newline at end of file