diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5a633b..fcf0101 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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" \ diff --git a/scripts/postinstall b/scripts/postinstall index 4a812f5..efc9534 100755 --- a/scripts/postinstall +++ b/scripts/postinstall @@ -1,5 +1,7 @@ #!/bin/zsh +set -euo pipefail + echo "Running postinstall script..." # Define variables diff --git a/scripts/preinstall b/scripts/preinstall new file mode 100755 index 0000000..2dc8ce5 --- /dev/null +++ b/scripts/preinstall @@ -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