From dc04147ccf6161eb8231aaabc4b07676ff264f88 Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Tue, 25 Jul 2017 01:50:54 +0200 Subject: [PATCH] rake sync:all_files + use bundler in circle.yml --- Gemfile | 2 ++ Gemfile.lock | 34 ++++++++++++++++++++++++---------- circle.yml | 12 ++++++------ rakelib/changelog.rake | 13 +++++++++++++ rakelib/utils.rake | 24 ++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index 42481ded..28ee9c97 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,5 @@ source 'https://rubygems.org' gem 'cocoapods', '1.2.1' gem 'xcpretty' +gem 'rake' +gem 'octokit', '~> 4.7' diff --git a/Gemfile.lock b/Gemfile.lock index b7883956..cbeafa63 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,12 +2,14 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (2.3.5) - activesupport (4.2.8) + activesupport (4.2.9) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - claide (1.0.1) + addressable (2.5.1) + public_suffix (~> 2.0, >= 2.0.2) + claide (1.0.2) cocoapods (1.2.1) activesupport (>= 4.0.2, < 5) claide (>= 1.0.1, < 2.0) @@ -43,34 +45,46 @@ GEM cocoapods-try (1.1.0) colored2 (3.1.2) escape (0.0.4) + faraday (0.12.2) + multipart-post (>= 1.2, < 3) fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.0.3) - i18n (0.8.1) - minitest (5.10.1) + i18n (0.8.6) + minitest (5.10.3) molinillo (0.5.7) + multipart-post (2.0.0) nanaimo (0.2.3) nap (1.1.0) netrc (0.7.8) - rouge (1.11.1) + octokit (4.7.0) + sawyer (~> 0.8.0, >= 0.5.3) + public_suffix (2.0.5) + rake (12.0.0) + rouge (2.0.7) ruby-macho (1.1.0) + sawyer (0.8.1) + addressable (>= 2.3.5, < 2.6) + faraday (~> 0.8, < 1.0) thread_safe (0.3.6) tzinfo (1.2.3) thread_safe (~> 0.1) - xcodeproj (1.4.4) + xcodeproj (1.5.1) CFPropertyList (~> 2.3.3) - claide (>= 1.0.1, < 2.0) + claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.2.3) - xcpretty (0.2.6) - rouge (~> 1.8) + xcpretty (0.2.8) + rouge (~> 2.0.7) PLATFORMS ruby DEPENDENCIES cocoapods (= 1.2.1) + octokit (~> 4.7) + rake xcpretty BUNDLED WITH - 1.13.7 + 1.15.3 diff --git a/circle.yml b/circle.yml index 371376b0..44bcf53b 100644 --- a/circle.yml +++ b/circle.yml @@ -6,14 +6,14 @@ machine: dependencies: post: - - rake lint:install + - bundle exec rake lint:install - curl -sS https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash test: override: - - rake lint:code - - rake lint:tests - - rake xcode:test - - rake spm:test + - bundle exec rake lint:code + - bundle exec rake lint:tests + - bundle exec rake xcode:test + - bundle exec rake spm:test post: - - rake pod:lint + - bundle exec rake pod:lint diff --git a/rakelib/changelog.rake b/rakelib/changelog.rake index f9e49ddb..e8247b87 100644 --- a/rakelib/changelog.rake +++ b/rakelib/changelog.rake @@ -1,6 +1,8 @@ # Used constants: # none +require 'octokit' + namespace :changelog do desc 'Add the empty CHANGELOG entries after a new release' task :reset do |task| @@ -49,4 +51,15 @@ namespace :changelog do puts "\u{274C} Some wrong links found:\n" + all_wrong_links.join("\n") end end + + desc "Push the CHANGELOG's top section as a GitHub release" + task :push_github_release do + client = Utils.octokit_client + tag = Utils.top_changelog_version + body = Utils.top_changelog_entry + + repo_url = `git remote -v | grep push`.split(' ')[1] + repo_name = File.basename(repo_url, '.git') + client.create_release("SwiftGen/#{repo_name}", tag, :body => body) + end end diff --git a/rakelib/utils.rake b/rakelib/utils.rake index 5855346a..a3a35734 100644 --- a/rakelib/utils.rake +++ b/rakelib/utils.rake @@ -2,10 +2,13 @@ # none require 'json' +require 'octokit' class Utils COLUMN_WIDTH = 30 + ## [ Run commands ] ######################################################### + # formatter types :xcpretty # pass through xcpretty and store in artifacts :raw # store in artifacts @@ -25,6 +28,8 @@ class Utils end end + ## [ Convenience Helpers ] ################################################## + def self.podspec_version(file = '*') JSON.parse(`bundle exec pod ipc spec #{file}.podspec`)["version"] end @@ -36,6 +41,24 @@ class Utils /\((.*)\)$/.match(pod_vers)[1] # Just the 'x.y.z' part end + def self.octokit_client + token = File.exist?('.apitoken') && File.read('.apitoken') + token ||= File.exist?('../.apitoken') && File.read('../.apitoken') + Utils.print_error('No .apitoken file found') unless token + Octokit::Client.new(:access_token => token) + end + + def self.top_changelog_version(changelog_file = 'CHANGELOG.md') + `grep -m 1 '^## ' "#{changelog_file}" | sed 's/## //'`.strip + end + + def self.top_changelog_entry(changelog_file = 'CHANGELOG.md') + tag = self.top_changelog_version + `sed -n /'^## #{tag}$'/,/'^## '/p "#{changelog_file}"`.gsub(/^## .*$/,'').strip + end + + ## [ Print info/errors ] #################################################### + # print an info header def self.print_header(str) puts "== #{str.chomp} ==".format(:yellow, :bold) @@ -66,6 +89,7 @@ class Utils result end + ## [ Private helper functions ] ################################################## # run a command, pipe output through 'xcpretty' and store the output in CI artifacts