Last active
February 26, 2025 01:32
-
-
Save petetronic/0971f0f642221122f40735495a19c4f2 to your computer and use it in GitHub Desktop.
Script to update Positron on macOS
This file contains hidden or 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
#!/bin/bash | |
# Ensure jq is installed | |
if ! command -v jq &> /dev/null; then | |
echo "jq is required but not installed. Please install jq (e.g., 'brew install jq') and retry." | |
exit 1 | |
fi | |
# Set API URL for GitHub releases | |
API_URL="https://api.github.com/repos/posit-dev/positron/releases" | |
# Fetch latest release tag | |
LATEST_TAG=$(curl -s $API_URL | jq -r '.[0].tag_name') | |
# Validate response | |
if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then | |
echo "Failed to determine the latest release tag." | |
exit 1 | |
fi | |
# Construct the .dmg download URL | |
DMG_URL="https://cdn.posit.co/positron/prereleases/mac/universal/Positron-${LATEST_TAG}.dmg" | |
# Download the .dmg file | |
DMG_FILE="Positron-${LATEST_TAG}.dmg" | |
echo "Downloading: $DMG_URL" | |
curl -L -o "$DMG_FILE" "$DMG_URL" | |
# Validate download | |
if [[ ! -f "$DMG_FILE" ]]; then | |
echo "Download failed." | |
exit 1 | |
fi | |
# Mount the DMG | |
MOUNT_POINT="/Volumes/PositronInstaller" | |
hdiutil attach "$DMG_FILE" -mountpoint "$MOUNT_POINT" -nobrowse | |
# Find the application and copy to Applications folder | |
APP_NAME="Positron.app" | |
cp -R "$MOUNT_POINT/$APP_NAME" "/Applications/" | |
# Unmount and clean up | |
hdiutil detach "$MOUNT_POINT" | |
rm "$DMG_FILE" | |
echo "Positron installed successfully." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment