meta: Revamped app-to-cask script, now outputs a rb file for the cask
This commit is contained in:
parent
fa68f7d88a
commit
ad0ee271ff
@ -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'
|
Loading…
x
Reference in New Issue
Block a user