Created
September 10, 2016 12:43
-
-
Save alyssais/d1d4a4342dc0bbd617a05528ba5758e4 to your computer and use it in GitHub Desktop.
Automated Xcode installation on pre-release OS X with mas-cli. mas-cli requires Xcode to compile, so this script downloads a binary of mas-cli, uses it just to install Xcode, then uses the newly installed Xcode to compile mas-cli and replace the pre-compiled binary.
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
#!/usr/bin/env ruby | |
require "open-uri" | |
require "json" | |
RELEASES_URL = "https://api.github.com/repos/argon/mas/releases" | |
ASSET_NAME = "mas-cli.zip" | |
EXECUTABLE_NAME = "mas" | |
XCODE_ID = "497799835" | |
releases = JSON.parse(open(RELEASES_URL).read) | |
release = releases.first | |
Dir.mktmpdir do |tmp_dir| | |
asset_path = File.join(tmp_dir, ASSET_NAME) | |
asset = release["assets"].find { |a| a["name"] == ASSET_NAME } | |
download_url = asset["browser_download_url"] | |
File.write asset_path, open(download_url).read | |
Dir.chdir(tmp_dir) { system "unzip", "-q", asset_path } | |
executable_path = File.join(tmp_dir, EXECUTABLE_NAME) | |
email = (print "Apple ID email: "; gets.chomp) | |
password = (print "Apple ID password: "; gets.chomp) | |
system executable_path, "signin", email, password | |
system executable_path, "install", XCODE_ID | |
system "brew", "install", "--build-from-source", "mas" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment