From ad0ee271ff413418e19e2eaf01ed32c9fcad17d8 Mon Sep 17 00:00:00 2001 From: june Date: Mon, 17 Mar 2025 19:25:52 +1300 Subject: [PATCH] meta: Revamped app-to-cask script, now outputs a rb file for the cask --- script/app-to-cask.sh | 44 ++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/script/app-to-cask.sh b/script/app-to-cask.sh index b298468..ecbb2e0 100755 --- a/script/app-to-cask.sh +++ b/script/app-to-cask.sh @@ -2,27 +2,41 @@ # 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" +S3_BUCKET="https://dl.breadone.xyz/cask" # prod +# S3_BUCKET="https://dl.breadone.xyz/homebrew/casks" # staging -echo "compressing $APP_FILE to $ZIP_PATH.zip" +# get reported version of app, remove quotes, print just the version +version=$(mdls -name kMDItemVersion $APP_FILE | tr -d '"' | awk '{print $3}') + +# just the app file name, eg Things3.app +FILENAME=$(basename $APP_FILE) + +# remove extension, eg Things3 +APP_NAME="${FILENAME%.app}" + +# interpolate to final zip name, eg Things3-3.12.5.zip +ZIP_PATH="$APP_NAME-$version.zip" # Compress the file -ditto -c -k --sequesterRsrc --keepParent $APP_FILE $ZIP_PATH.zip +ditto -c -k --sequesterRsrc --keepParent $APP_FILE $ZIP_PATH # 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" +hash=$(sha256 $ZIP_PATH | awk '{ print $4 }') # Upload the .app file to the specified S3 bucket -curl -X PUT "$S3_BUCKET/$ZIP_PATH.zip" \ +curl -X PUT "$S3_BUCKET/$ZIP_PATH" \ -H "Content-Type: application/octet-stream" \ - --data-binary "@$ZIP_PATH.zip" + --data-binary "@$ZIP_PATH" -echo "Deleting $ZIP_PATH.zip..." -rm $ZIP_PATH.zip +# output (mostly complete) cask file +echo 'cask "'$(echo "$APP_NAME" | tr '[:upper:]' '[:lower:]')'" do' # lowercase appname +echo ' version "'$version'"' +echo ' sha256 "'$hash'"' +echo '' +echo ' url "'$S3_BUCKET/$ZIP_PATH'"' +echo ' name "'$APP_NAME'"' +echo ' desc "ENTER_DESCRIPTION"' +echo ' homepage "ENTER_HOMEPAGE"' +echo '' +echo ' app "'$FILENAME'"' +echo 'end' \ No newline at end of file