Skip to content

Commit

Permalink
Merge pull request #55 from squidowl/fix/macos-ci
Browse files Browse the repository at this point in the history
single ci script for macos
  • Loading branch information
casperstorm committed Jun 24, 2023
2 parents 8d99a5a + b2ea2c7 commit cd0a6e9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 63 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
target:
- target: macos
os: macos-latest
make: bash scripts/build-macos.sh dmg
make: bash scripts/build-macos.sh
binary_path: target/release/macos/halloy.dmg

runs-on: ${{ matrix.target.os }}
Expand All @@ -28,18 +28,6 @@ jobs:
toolchain: stable
override: true

- name: Assign version to .app
if: ${{ matrix.target.os == 'macos-latest' }}
run: |
VERSION=$(cat VERSION)
sed -i '' -e "s/{{ VERSION }}/$VERSION/g" "assets/macos/Halloy.app/Contents/Info.plist"
- name: Assign build to .app
if: ${{ matrix.target.os == 'macos-latest' }}
run: |
BUILD=${GITHUB_SHA::7}
sed -i '' -e "s/{{ BUILD }}/$BUILD/g" "assets/macos/Halloy.app/Contents/Info.plist"
- name: Build
run: ${{ matrix.target.make }}

Expand Down
77 changes: 27 additions & 50 deletions scripts/build-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,39 @@ ASSETS_DIR="assets"
RELEASE_DIR="target/release"
APP_NAME="Halloy.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"
APP_COMPLETIONS_DIR="$APP_EXTRAS_DIR/completions"

DMG_NAME="halloy.dmg"
DMG_DIR="$RELEASE_DIR/macos"

binary() {
export MACOSX_DEPLOYMENT_TARGET="11.0"
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"
}
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"
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 "Halloy" -fs HFS+ -srcfolder "$APP_DIR" -ov -format UDZO
echo "Packed '$APP_NAME' in '$APP_DIR'"

app() {
mkdir -p "$APP_BINARY_DIR"
mkdir -p "$APP_EXTRAS_DIR"
mkdir -p "$APP_COMPLETIONS_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'"
}

dmg() {
echo "Packing disk image..."
ln -sf /Applications "$DMG_DIR/Applications"
hdiutil create "$DMG_DIR/$DMG_NAME" -volname "Halloy" -fs HFS+ -srcfolder "$APP_DIR" -ov -format UDZO
echo "Packed '$APP_NAME' in '$APP_DIR'"
}


clean() {
cargo clean
}

case "$1" in
binary)
binary
;;
app)
app
;;
dmg)
app
dmg
;;
clean)
clean
;;
*)
echo " binary Build the $TARGET binary"
echo " app Create the $APP_NAME application bundle"
echo " dmg Create the $DMG_NAME disk image"
echo " clean Clean the project"
;;
esac

0 comments on commit cd0a6e9

Please sign in to comment.