Skip to content

Commit

Permalink
test macos build script
Browse files Browse the repository at this point in the history
  • Loading branch information
B0ney committed Oct 18, 2023
1 parent 0d5065c commit c7971bf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 47 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build_gui_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ jobs:
make: powershell dist/build-windows.ps1
artifact_path: "target/release/artifact/*"

# - target: macos
# os: macos-latest
# make: bash dist/build-macos.sh
- target: macos
os: macos-latest
make: bash dist/build-macos.sh
artifact_path: "target/release/artifact/*"

runs-on: ${{ matrix.target.os }}

Expand Down
79 changes: 35 additions & 44 deletions dist/build-macos.sh
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/*

0 comments on commit c7971bf

Please sign in to comment.