|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +mac_dir="./bin/macOS" |
| 4 | +mac_app_dir="$mac_dir/Unrailed Save Scummer.app" |
| 5 | +mac_app_contents_dir="$mac_app_dir/Contents" |
| 6 | + |
| 7 | +rm -rf "./bin" |
| 8 | + |
| 9 | +pkger |
| 10 | + |
| 11 | +mkdir -p "$mac_app_contents_dir/"{MacOS,Resources} |
| 12 | + |
| 13 | +# build ICNS |
| 14 | +mkdir "./assets/images/icon.iconset" |
| 15 | +for size in 128 256 512; do |
| 16 | + sips -z "$size" "$size" "./assets/images/icon.png" --out "./assets/images/icon.iconset/icon_${size}x${size}.png" |
| 17 | +done |
| 18 | +png2icns "./assets/images/icon.icns" "./assets/images/icon.iconset/"*.png |
| 19 | +cp "./assets/images/icon.icns" "$mac_dir/.VolumeIcon.icns" |
| 20 | +cp "./assets/images/icon.icns" "$mac_app_contents_dir/Resources/icon.icns" |
| 21 | + |
| 22 | +# package images |
| 23 | +cp "./assets/images/icon.png" "$mac_app_contents_dir/Resources/" |
| 24 | + |
| 25 | +# template Info.plist |
| 26 | +eval "cat <<EOF |
| 27 | +$(<"./assets/Info.plist") |
| 28 | +EOF |
| 29 | +" 2> /dev/null > "$mac_app_contents_dir/Info.plist" |
| 30 | + |
| 31 | +# Prepare DMG assets |
| 32 | +cp "./assets/dmg-contents/USS.DS_Store" "$mac_dir/.DS_Store" |
| 33 | +ln -s "/Applications" "$mac_dir/Applications" |
| 34 | + |
| 35 | +# build |
| 36 | +GOOS=darwin GOARCH=amd64 go build -o "$mac_app_contents_dir/MacOS/unrailed-save-scummer-amd64-darwin" . |
| 37 | +GOOS=linux GOARCH=amd64 go build -o "./bin/unrailed-save-scummer-amd64-linux" . |
| 38 | +GOOS=windows GOARCH=amd64 go build -o "./bin/unrailed-save-scummer-amd64-windows.exe" . |
| 39 | + |
| 40 | +# Package macOS app into DMG |
| 41 | +case "$(uname)" in |
| 42 | +"Darwin") |
| 43 | + width=600 |
| 44 | + height=400 |
| 45 | + create-dmg \ |
| 46 | + --volname "Unrailed Save Scummer" \ |
| 47 | + --volicon "./assets/images/icon.icns" \ |
| 48 | + --window-size $width $height \ |
| 49 | + --icon-size $(expr $height / 4) \ |
| 50 | + --icon "Unrailed Save Scummer.app" $(expr $width / 4 - $height / 8) $(expr $height / 2 - $height / 8) \ |
| 51 | + --hide-extension "Unrailed Save Scummer.app" \ |
| 52 | + --app-drop-link $(expr $width \* 3 / 4 - $height / 8) $(expr $height / 2 - $height / 8) \ |
| 53 | + --hdiutil-quiet \ |
| 54 | + --no-internet-enable \ |
| 55 | + "./bin/unrailed-save-scummer-amd64-darwin.dmg" "$mac_app_dir" |
| 56 | + ;; |
| 57 | +"Linux") |
| 58 | + # dd if=/dev/zero of=/tmp/foo.dmg bs=1M count=64 |
| 59 | + # mkfs.hfsplus -v ThisIsFoo /tmp/foo.dmg |
| 60 | + genisoimage \ |
| 61 | + -V "Unrailed Save Scummer" -D -R -apple -no-pad \ |
| 62 | + -o "./bin/unrailed-save-scummer-amd64-darwin.dmg" "$mac_app_dir" |
| 63 | + ;; |
| 64 | +*) |
| 65 | + >&2 echo "Unknown build platform!" |
| 66 | +esac |
0 commit comments