Skip to content

Instantly share code, notes, and snippets.

@jb510
Created July 29, 2025 16:05
Show Gist options
  • Select an option

  • Save jb510/89c31a3f892d2415b3824b250e441e99 to your computer and use it in GitHub Desktop.

Select an option

Save jb510/89c31a3f892d2415b3824b250e441e99 to your computer and use it in GitHub Desktop.

Revisions

  1. jb510 revised this gist Jul 29, 2025. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions update_freecad_weekly.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    #!/bin/bash
    set -e

    # After installing chmod +x update_freecad_weekly.sh
    # to run ./update_freecad_weekly.sh

    # === Configuration ===
    PLATFORM="arm64" # Change this to "x86_64" for Intel Macs
    APP_NAME="FreeCAD.app"
  2. jb510 created this gist Jul 29, 2025.
    48 changes: 48 additions & 0 deletions update_freecad_weekly.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    #!/bin/bash
    set -e

    # === Configuration ===
    PLATFORM="arm64" # Change this to "x86_64" for Intel Macs
    APP_NAME="FreeCAD.app"
    INSTALL_PATH="/Applications/$APP_NAME"
    TMP_DIR="/tmp/freecad_update"
    RELEASES_URL="https://api.github.com/repos/FreeCAD/FreeCAD/releases"

    mkdir -p "$TMP_DIR"
    cd "$TMP_DIR"

    echo "πŸ” Fetching latest FreeCAD weekly release info for $PLATFORM..."

    DMG_INFO=$(curl -s "$RELEASES_URL" | jq -r --arg platform "$PLATFORM" '
    [.[] | select(.tag_name | test("weekly"))][0].assets[]
    | select(.name | endswith(".dmg") and contains("macOS") and contains($platform))
    | {name: .name, url: .browser_download_url}
    ')

    DMG_NAME=$(echo "$DMG_INFO" | jq -r '.name')
    DMG_URL=$(echo "$DMG_INFO" | jq -r '.url')

    if [[ -z "$DMG_URL" || "$DMG_URL" == "null" ]]; then
    echo "❌ Could not find a macOS .dmg for architecture: $PLATFORM"
    exit 1
    fi

    echo "βœ… Found .dmg: $DMG_NAME"
    echo "⬇️ Downloading from: $DMG_URL"
    curl -L "$DMG_URL" -o "$DMG_NAME"

    echo "πŸ”Œ Mounting .dmg..."
    MOUNT_POINT=$(hdiutil attach "$DMG_NAME" | grep "/Volumes" | awk '{print $3}')

    echo "πŸ—‘οΈ Removing old FreeCAD (if it exists)..."
    if [ -d "$INSTALL_PATH" ]; then
    sudo rm -rf "$INSTALL_PATH"
    fi

    echo "πŸ“¦ Copying new FreeCAD to /Applications..."
    cp -R "$MOUNT_POINT/$APP_NAME" /Applications/

    echo "⏏️ Ejecting volume..."
    hdiutil detach "$MOUNT_POINT"

    echo "βœ… FreeCAD Weekly (standalone) has been installed to /Applications."