meta: Revamped app-to-cask script, now outputs a rb file for the cask

This commit is contained in:
june 2025-03-17 19:25:52 +13:00
parent fa68f7d88a
commit ad0ee271ff
Signed by untrusted user who does not match committer: breadone
GPG Key ID: FDC19FE143200483

View File

@ -2,27 +2,41 @@
# Assign arguments to variables # Assign arguments to variables
APP_FILE=$1 APP_FILE=$1
ZIP_PATH=$(basename $APP_FILE) S3_BUCKET="https://dl.breadone.xyz/cask" # prod
# S3_BUCKET="https://dl.breadone.xyz/cask" # S3_BUCKET="https://dl.breadone.xyz/homebrew/casks" # staging
S3_BUCKET="https://dl.breadone.xyz/homebrew/casks"
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 # 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 # Get hash of file
hash=$(sha256 $ZIP_PATH.zip | awk '{ print $4 }') hash=$(sha256 $ZIP_PATH | 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 # 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" \ -H "Content-Type: application/octet-stream" \
--data-binary "@$ZIP_PATH.zip" --data-binary "@$ZIP_PATH"
echo "Deleting $ZIP_PATH.zip..." # output (mostly complete) cask file
rm $ZIP_PATH.zip 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'