From fa68f7d88a687726ce39a01c0ab606d4b771465b Mon Sep 17 00:00:00 2001 From: june Date: Mon, 17 Mar 2025 18:47:30 +1300 Subject: [PATCH] meta: Add script to create and upload casks to S3 --- .gitignore | 1 + script/app-to-cask.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .gitignore create mode 100755 script/app-to-cask.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..79b5594 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/.DS_Store diff --git a/script/app-to-cask.sh b/script/app-to-cask.sh new file mode 100755 index 0000000..b298468 --- /dev/null +++ b/script/app-to-cask.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Assign arguments to variables +APP_FILE=$1 +ZIP_PATH=$(basename $APP_FILE) +# S3_BUCKET="https://dl.breadone.xyz/cask" +S3_BUCKET="https://dl.breadone.xyz/homebrew/casks" + +echo "compressing $APP_FILE to $ZIP_PATH.zip" + +# Compress the file +ditto -c -k --sequesterRsrc --keepParent $APP_FILE $ZIP_PATH.zip + +# Get hash of file +hash=$(sha256 $ZIP_PATH.zip | awk '{ print $4 }') +echo "SHA256: $hash" + +# get reported version of app +version=$(mdls -name kMDItemVersion $APP_FILE | awk '{ print $3 }') +echo "Version: $version" + +# Upload the .app file to the specified S3 bucket +curl -X PUT "$S3_BUCKET/$ZIP_PATH.zip" \ + -H "Content-Type: application/octet-stream" \ + --data-binary "@$ZIP_PATH.zip" + +echo "Deleting $ZIP_PATH.zip..." +rm $ZIP_PATH.zip