Skip to content

Commit

Permalink
Add rake task for creating releases on GitHub (jjochen#103)
Browse files Browse the repository at this point in the history
* Task for creating release on GitHub

* redeploy cocoapod after pushing new version to trunk
  • Loading branch information
jjochen authored Jan 8, 2018
1 parent 08ed1b4 commit fde5491
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ source 'https://rubygems.org' do
gem 'jazzy', '>= 0.9.0'
gem 'rake'
gem 'fileutils'
gem 'octokit'
end

1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ DEPENDENCIES
fileutils!
github_changelog_generator!
jazzy (>= 0.9.0)!
octokit!
rake!
synx!
xcpretty!
Expand Down
61 changes: 60 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ end

begin
require 'fileutils'
require 'octokit'
require 'cocoapods'

task default: :test

Expand Down Expand Up @@ -168,6 +170,29 @@ begin
task :push_podspec do
title "Pushing podspec"
sh 'bundle exec pod trunk push'
sh 'curl http://207.254.41.223:4567/redeploy/JJFloatingActionButton/latest'
end

desc 'Create release on github'
task :create_github_release do
title "Creating release on github"
repo = "jjochen/JJFloatingActionButton"
version = version_from_podspec
body = changelog_for_version version
options = {
:name => version,
:body => body,
:draft => false,
:prerelease => false
}

puts "repo: #{repo}"
puts "version: #{version}"
puts "body: \n#{body}"

client = Octokit::Client.new :access_token => ENV['JJ_GITHUB_TOKEN']
release = client.create_release repo, version, options
puts "#{release.name} created."
end

rescue LoadError, NameError => e
Expand Down Expand Up @@ -282,7 +307,7 @@ def test_documentation_coverage
search_string = '100% documented'
if File.foreach(file_path).grep(/#{Regexp.escape(search_string)}/).any?
puts "'#{search_string}' found in #{file_path}"
else
else
error_message "'#{search_string}' not found in #{file_path}"
exit 1
end
Expand All @@ -298,6 +323,40 @@ def update_version_in_podspec(version)
File.open(file_name, "w") {|file| file.puts new_contents }
end

def version_from_podspec
spec = Pod::Specification.from_file('JJFloatingActionButton.podspec')
version = spec.version.to_s()
if version.nil? || version.empty?
error_message "podspec version not found."
exit 1
end
return version
end

def changelog_for_version(version)
check_parameter(version)
changelog = ""
File.open("CHANGELOG.md") do |f|
in_version = false
f.each_line do |line|
if in_version
if line.match(/^\#\# \[.*/)
break
elsif
changelog.concat(line)
end
elsif line.match(/^\#\# \[#{version}\].*/)
in_version = true
end
end
end
if changelog.nil? || changelog.empty?
error_message "changelog for version #{verion} not found."
exit 1
end
return changelog
end

def create_release_branch_and_commit(version)
title "Creating release branch and commit"
check_parameter(version)
Expand Down

0 comments on commit fde5491

Please sign in to comment.