Skip to content

Commit

Permalink
release dmg zip
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabrielides committed Dec 2, 2024
1 parent 94ec631 commit 6cde6a1
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ jobs:
CFLAGS_x86_64_pc_windows_gnu: "-O2"

- name: Package release
run: |
zip -r dash-evo-tool-${{ matrix.platform }}.zip dash-evo-tool/
run: "${GITHUB_WORKSPACE}/scripts/pack.sh 0.6.0 ${{ matrix.platform }} ${{ matrix.ext }}"

- name: Attest
uses: actions/attest-build-provenance@v1
Expand All @@ -137,8 +136,8 @@ jobs:
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: dash-evo-tool-${{ matrix.platform }}.zip
path: dash-evo-tool-${{ matrix.platform }}.zip
name: dash-evo-tool
path: dist/**

release:
name: Create GitHub Release
Expand Down
141 changes: 141 additions & 0 deletions scripts/pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/bin/bash

set -e

VERSION="$1"
PLATFORM="$2"
EXT="$3"

if [ -z "PLATFORM" ]; then
echo "Error"
exit 1
fi

create_zip_package() {
echo "Building ZIP for $PLATFORM version $VERSION"
echo "extention is:$EXT"

zip -r $DIST_DIR/dash-evo-tool-"$PLATFORM".zip $BUILD_DIR
}

create_dmg_package() {
echo "Building DMG for $PLATFORM version $VERSION"
echo "extention is:$EXT"

APP_BUNDLE_NAME="$APP_NAME.app"
APP_BUNDLE_DIR="$BUILD_DIR/$APP_BUNDLE_NAME"
CONTENTS_DIR="$APP_BUNDLE_DIR/Contents"
MACOS_DIR="$CONTENTS_DIR/MacOS"
RESOURCES_DIR="$CONTENTS_DIR/Resources"

# Create directories for the .app bundle
mkdir -p "$APP_BUNDLE_DIR"
mkdir -p "$MACOS_DIR"
mkdir -p "$RESOURCES_DIR"

# Copy the binary into the app bundle
cp "$BUILD_DIR/$APP_NAME" "$MACOS_DIR/"

ICON_SOURCE="$ROOT_PATH/mac_os/AppIcons/appstore.png"
ICONSET_DIR="$BUILD_DIR/AppIcon.iconset"
mkdir -p "$ICONSET_DIR"

sips -z 16 16 "$ICON_SOURCE" --out "$ICONSET_DIR/icon_16x16.png"
sips -z 32 32 "$ICON_SOURCE" --out "$ICONSET_DIR/[email protected]"
sips -z 32 32 "$ICON_SOURCE" --out "$ICONSET_DIR/icon_32x32.png"
sips -z 64 64 "$ICON_SOURCE" --out "$ICONSET_DIR/[email protected]"
sips -z 128 128 "$ICON_SOURCE" --out "$ICONSET_DIR/icon_128x128.png"
sips -z 256 256 "$ICON_SOURCE" --out "$ICONSET_DIR/[email protected]"
sips -z 256 256 "$ICON_SOURCE" --out "$ICONSET_DIR/icon_256x256.png"
sips -z 512 512 "$ICON_SOURCE" --out "$ICONSET_DIR/[email protected]"
sips -z 512 512 "$ICON_SOURCE" --out "$ICONSET_DIR/icon_512x512.png"
cp "$ICON_SOURCE" "$ICONSET_DIR/[email protected]"

# Convert iconset to .icns
iconutil -c icns "$ICONSET_DIR" -o "$RESOURCES_DIR/AppIcon.icns"

# Clean up the iconset directory
rm -rf "$ICONSET_DIR"
# Create a minimal Info.plist file
cat <<EOF > "$CONTENTS_DIR/Info.plist"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>$APP_NAME</string>
<key>CFBundleDisplayName</key>
<string>$APP_NAME</string>
<key>CFBundleExecutable</key>
<string>$APP_NAME</string>
<key>CFBundleIdentifier</key>
<string>com.example.$APP_NAME</string>
<key>CFBundleVersion</key>
<string>$VERSION</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>LSMinimumSystemVersion</key>
<string>10.9</string>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
</dict>
</plist>
EOF

# Create the .dmg directory structure
DMG_DIR="$BUILD_DIR/dmg_content"
mkdir -p "$DMG_DIR"

# Copy the .app bundle into the dmg content directory
cp -R "$APP_BUNDLE_DIR" "$DMG_DIR/"

# Create a symbolic link to the Applications folder
ln -s /Applications "$DMG_DIR/Applications"

# Create the .dmg file
hdiutil create -volname "$APP_NAME Installer" \
-srcfolder "$DMG_DIR" \
-ov -format UDZO \
"$DIST_DIR/$APP_NAME-$PLATFORM.dmg"
}

echo "Starting"

FULL_PATH=$(realpath "$0")
DIR_PATH=$(dirname "$FULL_PATH")
ROOT_PATH=$(dirname "$DIR_PATH")

APP_NAME="dash-evo-tool"
BUILD_DIR="$ROOT_PATH/dash-evo-tool"
DIST_DIR="$ROOT_PATH/dist"

mkdir -p "$DIST_DIR"

case "$PLATFORM" in
x86_64-mac)
create_dmg_package
;;
arm64-mac)
create_dmg_package
;;
x86_64-linux)
create_zip_package
;;
arm64-linux)
create_zip_package
;;
windows)
create_zip_package
;;
*)
echo "Invalid command."
echo "$cmd_usage"
exit 1
;;
esac

rm -rf "$BUILD_DIR"
echo "Done."

0 comments on commit 6cde6a1

Please sign in to comment.