Skip to content

Commit

Permalink
fix: install pkl during preinstall
Browse files Browse the repository at this point in the history
  • Loading branch information
willswire committed Oct 1, 2024
1 parent 29b7043 commit 87b75ff
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ jobs:
SCHEME: Cosmic
ARCHIVE: Cosmic.xcarchive

- name: Copy pkl to archive
run: sudo cp /usr/local/bin/pkl Cosmic.xcarchive/Products/usr/local/bin/pkl

- name: Build installer package
run: |
pkgbuild --root "Cosmic.xcarchive/Products" \
Expand Down
2 changes: 2 additions & 0 deletions scripts/postinstall
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/zsh

set -euo pipefail

echo "Running postinstall script..."

# Define variables
Expand Down
34 changes: 34 additions & 0 deletions scripts/preinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/zsh

set -euo pipefail

echo "Running preinstall script..."

# Define variables
PKL_VERSION='0.26.3'
PKL_ARCH='macos-aarch64'
PKL_URL="https://github.com/apple/pkl/releases/download/${PKL_VERSION}/pkl-${PKL_ARCH}"
PKL_DEST="/usr/local/bin/pkl"

# Ensure the destination directory exists and is writable
if [ ! -d "$(dirname "$PKL_DEST")" ]; then
echo "Creating directory $(dirname "$PKL_DEST")..."
sudo mkdir -p "$(dirname "$PKL_DEST")" || { echo "Failed to create directory $(dirname "$PKL_DEST")"; exit 1; }
fi

# Download the PKL file
echo "Downloading PKL from $PKL_URL..."
if curl -L --fail -o "$PKL_DEST" "$PKL_URL"; then
if sudo chmod +x "$PKL_DEST"; then
echo "Downloaded and installed PKL successfully to /usr/local/bin."
else
echo "Failed to make $PKL_DEST executable"
exit 1
fi
else
echo "Failed to download PKL from $PKL_URL"
exit 1
fi

echo "Preinstall script completed successfully."
exit 0

0 comments on commit 87b75ff

Please sign in to comment.