diff --git a/Gemfile b/Gemfile index 0a42548..760fea8 100644 --- a/Gemfile +++ b/Gemfile @@ -11,3 +11,4 @@ gem "rubocop" gem "rubocop-rake" gem "rubocop-rspec" gem "simplecov", require: false, group: :test +gem "tty-prompt" diff --git a/Rakefile b/Rakefile index 2f38bf0..41265ce 100644 --- a/Rakefile +++ b/Rakefile @@ -2,6 +2,7 @@ require "bundler/gem_tasks" require "rspec/core/rake_task" +require "tty-prompt" RSpec::Core::RakeTask.new(:spec) @@ -19,3 +20,17 @@ task :test_swift do end FileUtils.rm_rf("tests") end + +desc "Sets lib version to the semantic version given, and push it to remote." +task :bump, [:v] do |t, args| + version = args[:v] || raise("A version is required. Pass it like `rake bump[1.2.3]`") + next unless TTY::Prompt.new.yes?("Would you like to set the new version of the app to be '#{version}'?") + version_filename = "lib/arkana/version.rb" + version_file_contents = File.read(version_filename) + new_version_file_contents = version_file_contents.gsub(/VERSION = \"(?:.*)\"/, "VERSION = \"#{version}\"") + File.open(version_filename, "w") {|file| file.puts new_version_file_contents } + sh("bundle install") + sh("git add #{version_filename} Gemfile.lock") + sh("git commit -m 'Bump app version to v#{version}.'") + sh("git push origin") +end