-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,38 @@ | ||
#!/bin/bash | ||
|
||
PLATFORM="linux" | ||
|
||
TARGET_OLD="xmodits-gui" | ||
TARGET="xmodits" | ||
ASSETS_DIR="assets" | ||
RELEASE_DIR="target/release" | ||
APP_NAME="xmodits.app" | ||
APP_TEMPLATE="$ASSETS_DIR/macos/$APP_NAME" | ||
APP_TEMPLATE_PLIST="$APP_TEMPLATE/Contents/Info.plist" | ||
APP_DIR="$RELEASE_DIR/macos" | ||
APP_BINARY="$RELEASE_DIR/$TARGET" | ||
APP_BINARY_DIR="$APP_DIR/$APP_NAME/Contents/MacOS" | ||
APP_EXTRAS_DIR="$APP_DIR/$APP_NAME/Contents/Resources" | ||
|
||
DMG_NAME="xmodits.dmg" | ||
DMG_DIR="$RELEASE_DIR/macos" | ||
|
||
VERSION=$(cat VERSION) | ||
BUILD=$(git describe --always --dirty --exclude='*') | ||
|
||
# update version and build | ||
sed -i '' -e "s/{{ VERSION }}/$VERSION/g" "$APP_TEMPLATE_PLIST" | ||
sed -i '' -e "s/{{ BUILD }}/$BUILD/g" "$APP_TEMPLATE_PLIST" | ||
|
||
# build binary | ||
export MACOSX_DEPLOYMENT_TARGET="11.0" | ||
rustup target add x86_64-apple-darwin | ||
rustup target add aarch64-apple-darwin | ||
cargo build --release --target=x86_64-apple-darwin | ||
cargo build --release --target=aarch64-apple-darwin | ||
lipo "target/x86_64-apple-darwin/release/$TARGET" "target/aarch64-apple-darwin/release/$TARGET" -create -output "$APP_BINARY" | ||
|
||
# build app | ||
mkdir -p "$APP_BINARY_DIR" | ||
mkdir -p "$APP_EXTRAS_DIR" | ||
cp -fRp "$APP_TEMPLATE" "$APP_DIR" | ||
cp -fp "$APP_BINARY" "$APP_BINARY_DIR" | ||
touch -r "$APP_BINARY" "$APP_DIR/$APP_NAME" | ||
echo "Created '$APP_NAME' in '$APP_DIR'" | ||
|
||
# package dmg | ||
echo "Packing disk image..." | ||
ln -sf /Applications "$DMG_DIR/Applications" | ||
hdiutil create "$DMG_DIR/$DMG_NAME" -volname "xmodits" -fs HFS+ -srcfolder "$APP_DIR" -ov -format UDZO | ||
echo "Packed '$APP_NAME' in '$APP_DIR'" | ||
|
||
|
||
# https://github.com/squidowl/halloy/blob/9393792c43d705740ccddce561c52931ae098472/scripts/build-macos.sh | ||
|
||
FEATURES="build_info","wgpu" | ||
|
||
PROFILE="release" | ||
RELEASE_DIR="target/$PROFILE" | ||
|
||
BINARY_OLD="$RELEASE_DIR/$TARGET_OLD" | ||
|
||
|
||
ARCHIVE_DIR="$RELEASE_DIR/archive" | ||
ARTIFACT_DIR="$RELEASE_DIR/artifact" | ||
|
||
|
||
cargo build -p xmodits-gui --profile $PROFILE --features=$FEATURES | ||
|
||
# create directories | ||
mkdir -p $ARCHIVE_DIR | ||
mkdir -p $ARTIFACT_DIR | ||
|
||
# copy and rename xmodits-gui to xmodits in archive folder | ||
cp $BINARY_OLD $ARCHIVE_DIR/$TARGET | ||
|
||
# copy extra files | ||
cp README.md $ARCHIVE_DIR | ||
cp LICENSE $ARCHIVE_DIR | ||
|
||
chmod +x $ARCHIVE_DIR/$TARGET | ||
|
||
ARCHIVE_NAME="$TARGET-v$($BINARY_OLD --version)-$PLATFORM-$ARCH.zip" | ||
ARCHIVE_PATH="$ARTIFACT_DIR/$ARCHIVE_NAME" | ||
|
||
zip -j $ARCHIVE_PATH $ARCHIVE_DIR/* |