Skip to content

Instantly share code, notes, and snippets.

@hlung
Last active August 15, 2019 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlung/c4821b12e17d2c6d097343e4210c784f to your computer and use it in GitHub Desktop.
Save hlung/c4821b12e17d2c6d097343e4210c784f to your computer and use it in GitHub Desktop.
lane :replace_podspec_version do |options|
# Input file (content) => "s.version = '0.1.0'"
# Input new_version => "0.2.0"
# Output file (content) => "s.version = '0.2.0'"
# Note: For debugging, you can remove -i to make it print output to console without editing file in place.
# Somehow backup file *.bak has to be created for edit in-place (-i) option, otherwise sed command will fail.
sh("cd ..; sed -i bk \"s/\\(s.version.*['\\\"]\\).*\\(['\\\"]\\)/\\1#{options[:new_version]}\\2/g\" #{options[:file]}")
end
lane :get_podspec_version do |options|
# Input file (content) => "s.version = '0.1.0'"
# Output => "0.1.0"
sh("cd ..; pcregrep -o1 \"s.version.*[\\\'\\\"](.*)[\\\'\\\"]\" #{options[:file]}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment