Last active
May 15, 2018 23:51
-
-
Save psobko/05f82ed29727fb74325d5b09df22a0b0 to your computer and use it in GitHub Desktop.
Check if the locally installed version of Xcode is up to date by parsing Apple's releases XML.
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' | |
apple_releases = open('https://developer.apple.com/news/releases/rss/releases.rss').read | |
latest_xcode = /(?<=<title>Xcode )[0-9.]* \([A-Z0-9]*(?=\)<\/title>)/im.match(apple_releases).to_s.tr('(','').split(' ') | |
local_xcode = /(?<=Xcode )[0-9.].*/im.match(`xcodebuild -version`).to_s.split("\nBuild version ") | |
puts "Local Xcode version: #{local_xcode[0]} - #{local_xcode[1]}" | |
if Gem::Version.new(latest_xcode[0]) > Gem::Version.new(local_xcode[0]) | |
puts "A new version of Xcode is available: #{latest_xcode[0]} - #{latest_xcode[1]}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment