Include modulo in macOS packaging

This commit is contained in:
Federico Terzi 2020-08-16 19:06:19 +02:00
parent 4ad96eb2f3
commit b2bfb9737f
2 changed files with 21 additions and 2 deletions

View File

@ -211,6 +211,16 @@ def build_mac(package_info):
with open(hash_file, "w") as hf:
hf.write(sha256_hash.hexdigest())
modulo_sha_url = "https://github.com/federico-terzi/modulo/releases/download/v{0}/modulo-mac.sha256.txt".format(package_info.modulo_version)
print("Pulling SHA signature from:", modulo_sha_url)
modulo_sha_file = os.path.join(TARGET_DIR, "modulo.sha256")
urllib.request.urlretrieve(modulo_sha_url, modulo_sha_file)
modulo_sha = None
with open(modulo_sha_file, "r") as sha_f:
modulo_sha = sha_f.read()
if modulo_sha is None:
raise Exception("Cannot determine modulo SHA")
print("Processing Homebrew formula template")
with open("packager/mac/espanso.rb", "r") as formula_template:
content = formula_template.read()
@ -219,6 +229,8 @@ def build_mac(package_info):
content = content.replace("{{{app_desc}}}", package_info.description)
content = content.replace("{{{app_url}}}", package_info.url)
content = content.replace("{{{app_version}}}", package_info.version)
content = content.replace("{{{modulo_version}}}", package_info.modulo_version)
content = content.replace("{{{modulo_sha}}}", modulo_sha)
# Calculate hash
with open(archive_target, "rb") as f:

View File

@ -4,11 +4,18 @@
class Espanso < Formula
desc "{{{app_desc}}}"
homepage "{{{app_url}}}"
url "https://github.com/federico-terzi/espanso/releases/latest/download/espanso-mac.tar.gz"
url "https://github.com/federico-terzi/espanso/releases/v{{{app_version}}}/download/espanso-mac.tar.gz"
sha256 "{{{release_hash}}}"
version "{{{app_version}}}"
resource "modulo" do
url "https://github.com/federico-terzi/modulo/releases/download/v{{{modulo_version}}}/modulo-mac"
sha256 "{{{modulo_sha}}}"
end
def install
bin.install "espanso"
resource("modulo").stage { bin.install "modulo-mac" => "modulo" }
end
end