From 8820e6def1bccfef63bcaf9e55c38aea0d2926b2 Mon Sep 17 00:00:00 2001 From: poka <poka@p2p.legal> Date: Sat, 25 May 2024 16:29:53 +0200 Subject: [PATCH] add script to install macos bin --- .gitlab-ci.yml | 10 +++++-- Dockerfile.ci | 4 +++ scripts/Info.plist | 62 +++++++++++++++++++++++++++++++++++++++ scripts/install_gcli.scpt | 18 ++++++++++++ 4 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 scripts/Info.plist create mode 100644 scripts/install_gcli.scpt diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 42a2928..032be86 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,7 @@ build_linux: build_macos: stage: build_macos - image: poka/rust-osxcross:1.0.2 + image: poka/rust-osxcross:latest script: # Install the required dependencies - rustup target add x86_64-apple-darwin @@ -41,9 +41,13 @@ build_macos: - rm -rf target/macos - mkdir -p target/macos - cargo bundle --release --target x86_64-apple-darwin - # Zip the gcli.app before moving it + # Add Info.plist and install_gcli.scpt - cd target/x86_64-apple-darwin/release/bundle/osx - - echo -e "Unzip gcli.zip and move the gcli.app folder to /Applications/ folder.\nenjoy" > instructions.txt + - mkdir -p gcli.app/Contents/Resources/Scripts + - cp /opt/Info.plist gcli.app/Contents/Info.plist + - cp /opt/install_gcli.scpt gcli.app/Contents/Resources/Scripts/install_gcli.scpt + - echo -e "Just unzip gcli.app and open it.\nenjoy" > instructions.txt + # Zip the gcli.app before moving it - zip -r gcli.zip gcli.app instructions.txt - mv gcli.zip ../../../../macos/ # target/macos/ artifacts: diff --git a/Dockerfile.ci b/Dockerfile.ci index 0ed562c..900570f 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -44,5 +44,9 @@ ENV CXX="o64-clang++" # Add rust target for macOS RUN rustup target add x86_64-apple-darwin +# Copy scripts +COPY scripts/install_gcli.scpt /opt/install_gcli.scpt +COPY scripts/Info.plist /opt/Info.plist + # Define the entrypoint CMD ["bash"] diff --git a/scripts/Info.plist b/scripts/Info.plist new file mode 100644 index 0000000..8220ab9 --- /dev/null +++ b/scripts/Info.plist @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDisplayName</key> + <string>gcli</string> + <key>CFBundleExecutable</key> + <string>osascript</string> + <key>CFBundleIdentifier</key> + <string>com.axiomteam.gcli</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>gcli</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>0.2.13</string> + <key>CFBundleVersion</key> + <string>20240522.234244</string> + <key>CSResourcesFileMapped</key> + <true/> + <key>LSRequiresCarbon</key> + <true/> + <key>NSHighResolutionCapable</key> + <true/> + <key>NSAppleScriptEnabled</key> + <true/> + <key>CFBundleURLTypes</key> + <array> + <dict> + <key>CFBundleURLName</key> + <string>gcli script</string> + <key>CFBundleURLSchemes</key> + <array> + <string>file</string> + </array> + </dict> + </array> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>scpt</string> + </array> + <key>CFBundleTypeIconFile</key> + <string>ScriptEditorAppIcon.icns</string> + <key>CFBundleTypeName</key> + <string>AppleScript</string> + <key>CFBundleTypeRole</key> + <string>Editor</string> + </dict> + </array> + <key>CFBundleExecutable</key> + <string>osascript</string> + <key>CFBundleScriptPath</key> + <string>Contents/Resources/Scripts/install_gcli.scpt</string> +</dict> +</plist> diff --git a/scripts/install_gcli.scpt b/scripts/install_gcli.scpt new file mode 100644 index 0000000..8a93d8a --- /dev/null +++ b/scripts/install_gcli.scpt @@ -0,0 +1,18 @@ +-- Ask user if they want to install gcli +set userResponse to display dialog "Do you want to install gcli to /usr/local/bin?" buttons {"No", "Yes"} default button "Yes" + +if button returned of userResponse is "Yes" then + -- Run shell script to move gcli with administrator privileges + try + do shell script "mv gcli.app/Contents/MacOS/gcli /usr/local/bin" with administrator privileges + display dialog "gcli has been installed to /usr/local/bin and is now available in your PATH." + on error errMsg number errorNumber + if errorNumber is -128 then + display dialog "Installation cancelled." + else + display dialog "An error occurred: " & errMsg + end if + end try +else + display dialog "Installation cancelled." +end if -- GitLab