-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memoize version_select #10
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e3eee22
memoize the result of `version_select`, and allow us to change it fro…
djbe a2e321d
rubocop --autocorrect
djbe b5e71de
Fix Rakefile: quoting Xcode path
AliSoftware d9da312
Add rubocop in Gemfile + initial .rubocop.yml, then autocorrect
AliSoftware f77d5c9
Fixing more rubocop violations
AliSoftware c0ca5f2
Fix last rubocop warnings
AliSoftware 5c9e673
Generalize rubocop.yml to submodules
AliSoftware 4b016cd
Last rubocop warnings
AliSoftware File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
AllCops: | ||
TargetRubyVersion: 2.0 | ||
Exclude: | ||
- SwiftGenKit/Tests/Resources/**/* | ||
- SwiftGen/Resources/**/* | ||
|
||
Style/HashSyntax: | ||
Enabled: false | ||
|
||
Metrics/AbcSize: | ||
Max: 24 | ||
|
||
Metrics/BlockLength: | ||
Enabled: false | ||
|
||
Metrics/LineLength: | ||
Max: 140 | ||
|
||
Metrics/MethodLength: | ||
Max: 20 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'https://rubygems.org' | ||
|
||
gem 'cocoapods', '1.3.1' | ||
gem 'xcpretty' | ||
gem 'rake' | ||
gem 'octokit', '~> 4.7' | ||
gem 'plist', '~> 3.2' | ||
gem 'rake' | ||
gem 'rubocop' | ||
gem 'xcpretty' |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,15 @@ require 'uri' | |
require 'plist' | ||
|
||
namespace :repos do | ||
REPOS = [:StencilSwiftKit, :SwiftGenKit, :SwiftGen, :templates].freeze | ||
REPOS = %i[StencilSwiftKit SwiftGenKit SwiftGen templates].freeze | ||
desc 'Bootstrap this repository for development' | ||
task :bootstrap do | ||
REPOS.each do |repository| | ||
next if Dir.exists? "#{repository}" | ||
next if Dir.exist? repository.to_s | ||
|
||
sh "git clone [email protected]:SwiftGen/#{repository}.git --recursive" | ||
Dir.chdir("#{repository}") do | ||
sh "git submodule update --init --recursive" | ||
Dir.chdir(repository.to_s) do | ||
sh 'git submodule update --init --recursive' | ||
end | ||
end | ||
end | ||
|
@@ -46,7 +46,7 @@ end | |
|
||
namespace :submodules do | ||
def submodules(cmd) | ||
[:SwiftGenKit, :SwiftGen].each do |repository| | ||
%i[SwiftGenKit SwiftGen].each do |repository| | ||
Utils.print_header repository.to_s | ||
Dir.chdir(repository.to_s) do | ||
sh(cmd) | ||
|
@@ -62,8 +62,8 @@ namespace :submodules do | |
desc 'Show status for submodules of each repo' | ||
task :status do | ||
Utils.print_header "Current 'templates' commit" | ||
Dir.chdir('templates') { sh "git describe --all && git describe --always" } | ||
submodules("git submodule status") | ||
Dir.chdir('templates') { sh 'git describe --all && git describe --always' } | ||
submodules('git submodule status') | ||
end | ||
end | ||
|
||
|
@@ -79,7 +79,11 @@ namespace :release do | |
|
||
# Check if bundler is installed first, as we'll need it for the cocoapods task (and we prefer to fail early) | ||
`which bundler` | ||
results << Utils.table_result( $?.success?, 'Bundler installed', 'Please install bundler using `gem install bundler` and run `bundle install` first.') | ||
results << Utils.table_result( | ||
$CHILD_STATUS.success?, | ||
'Bundler installed', | ||
'Please install bundler using `gem install bundler` and run `bundle install` first.' | ||
) | ||
|
||
# Extract version from SwiftGen.podspec | ||
version = Utils.podspec_version('SwiftGen') | ||
|
@@ -89,32 +93,52 @@ namespace :release do | |
check_dep_versions = lambda do |pod| | ||
lock_version = Utils.podfile_lock_version(pod) | ||
pod_version = Utils.podspec_version(pod) | ||
results << Utils.table_result(lock_version == pod_version, "#{pod.ljust(Utils::COLUMN_WIDTH-10)} (#{pod_version})", "Please update #{pod} to latest version in your Podfile") | ||
results << Utils.table_result( | ||
lock_version == pod_version, | ||
"#{pod.ljust(Utils::COLUMN_WIDTH - 10)} (#{pod_version})", | ||
"Please update #{pod} to latest version in your Podfile" | ||
) | ||
end | ||
check_dep_versions.call('SwiftGenKit') | ||
check_dep_versions.call('StencilSwiftKit') | ||
|
||
# Check if version matches the Info.plist | ||
results << Utils.table_result(version == Utils.plist_version, "Info.plist version matches", "Please update the version numbers in the Info.plist file") | ||
results << Utils.table_result( | ||
version == Utils.plist_version, | ||
'Info.plist version matches', | ||
'Please update the version numbers in the Info.plist file' | ||
) | ||
|
||
# Check if submodule is aligned | ||
submodule_aligned = Dir.chdir('SwiftGen/Resources') do | ||
sh "git fetch origin >/dev/null" | ||
sh 'git fetch origin >/dev/null' | ||
`git rev-parse origin/master`.chomp == `git rev-parse HEAD`.chomp | ||
end | ||
results << Utils.table_result(submodule_aligned, "Submodule on origin/master", "Please align the submodule to master") | ||
results << Utils.table_result( | ||
submodule_aligned, | ||
'Submodule on origin/master', | ||
'Please align the submodule to master' | ||
) | ||
|
||
# Check if entry present in CHANGELOG | ||
changelog_entry = system(%Q{grep -q '^## #{Regexp.quote(version)}$' SwiftGen/CHANGELOG.md}) | ||
results << Utils.table_result(changelog_entry, "CHANGELOG, Entry added", "Please add an entry for #{version} in CHANGELOG.md") | ||
|
||
changelog_master = system(%q{grep -qi '^## Master' SwiftGen/CHANGELOG.md}) | ||
results << Utils.table_result(!changelog_master, "CHANGELOG, No master", 'Please remove entry for master in CHANGELOG') | ||
changelog_entry = system("grep -q '^## #{Regexp.quote(version)}$' SwiftGen/CHANGELOG.md") | ||
results << Utils.table_result( | ||
changelog_entry, | ||
'CHANGELOG, Entry added', | ||
"Please add an entry for #{version} in CHANGELOG.md" | ||
) | ||
|
||
changelog_master = system("grep -qi '^## Master' SwiftGen/CHANGELOG.md") | ||
results << Utils.table_result( | ||
!changelog_master, | ||
'CHANGELOG, No master', | ||
'Please remove entry for master in CHANGELOG' | ||
) | ||
|
||
exit 1 unless results.all? | ||
|
||
print "Release version #{version} [Y/n]? " | ||
exit 2 unless (STDIN.gets.chomp == 'Y') | ||
exit 2 unless STDIN.gets.chomp == 'Y' | ||
end | ||
|
||
desc 'Create a zip containing all the prebuilt binaries' | ||
|
@@ -125,7 +149,7 @@ namespace :release do | |
|
||
def post(url, content_type) | ||
uri = URI.parse(url) | ||
req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' => content_type}) | ||
req = Net::HTTP::Post.new(uri, initheader: { 'Content-Type' => content_type }) | ||
yield req if block_given? | ||
req.basic_auth 'AliSoftware', File.read('.apitoken').chomp | ||
|
||
|
@@ -144,15 +168,15 @@ namespace :release do | |
task :github => :zip do | ||
v = Utils.podspec_version | ||
|
||
changelog = `sed -n /'^## #{v}$'/,/'^## '/p SwiftGen/CHANGELOG.md`.gsub(/^## .*$/,'').strip | ||
changelog = `sed -n /'^## #{v}$'/,/'^## '/p SwiftGen/CHANGELOG.md`.gsub(/^## .*$/, '').strip | ||
Utils.print_header "Releasing version #{v} on GitHub" | ||
puts changelog | ||
|
||
json = post('https://api.github.com/repos/SwiftGen/SwiftGen/releases', 'application/json') do |req| | ||
req.body = { :tag_name => v, :name => v, :body => changelog, :draft => false, :prerelease => false }.to_json | ||
end | ||
|
||
upload_url = json['upload_url'].gsub(/\{.*\}/,"?name=swiftgen-#{v}.zip") | ||
upload_url = json['upload_url'].gsub(/\{.*\}/, "?name=swiftgen-#{v}.zip") | ||
zipfile = "SwiftGen/build/swiftgen-#{v}.zip" | ||
zipsize = File.size(zipfile) | ||
|
||
|
@@ -166,15 +190,15 @@ namespace :release do | |
|
||
desc 'pod trunk push SwiftGen to CocoaPods' | ||
task :cocoapods do | ||
Utils.print_header "Pushing pod to CocoaPods Trunk" | ||
Utils.print_header 'Pushing pod to CocoaPods Trunk' | ||
Dir.chdir('SwiftGen') do | ||
sh 'bundle exec pod trunk push SwiftGen.podspec' | ||
end | ||
end | ||
|
||
desc 'Release a new version on Homebrew and prepare a PR' | ||
task :homebrew do | ||
Utils.print_header "Updating Homebrew Formula" | ||
Utils.print_header 'Updating Homebrew Formula' | ||
tag = Utils.podspec_version | ||
revision = Dir.chdir('SwiftGen') { `git rev-list -1 #{tag}`.chomp } | ||
formulas_dir = Bundler.with_clean_env { `brew --repository homebrew/core`.chomp } | ||
|
@@ -187,17 +211,17 @@ namespace :release do | |
formula = File.read(formula_file) | ||
|
||
new_formula = formula | ||
.gsub(%r(:tag => ".*"), %Q(:tag => "#{tag}")) | ||
.gsub(%r(:revision => ".*"), %Q(:revision => "#{revision}")) | ||
.gsub(/:tag => ".*"/, %(:tag => "#{tag}")) | ||
.gsub(/:revision => ".*"/, %(:revision => "#{revision}")) | ||
File.write(formula_file, new_formula) | ||
Utils.print_header "Checking Homebrew formula..." | ||
Utils.print_header 'Checking Homebrew formula...' | ||
Bundler.with_clean_env do | ||
sh 'brew audit --strict --online swiftgen' | ||
sh 'brew upgrade swiftgen' | ||
sh 'brew test swiftgen' | ||
end | ||
|
||
Utils.print_header "Pushing to Homebrew" | ||
Utils.print_header 'Pushing to Homebrew' | ||
sh "git add #{formula_file}" | ||
sh "git commit -m 'swiftgen #{tag}'" | ||
sh "git push -u AliSoftware swiftgen-#{tag}" | ||
|
@@ -206,4 +230,4 @@ namespace :release do | |
end | ||
end | ||
|
||
task :default => "release:new" | ||
task :default => 'release:new' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'https://rubygems.org' | ||
|
||
gem 'cocoapods', '1.3.1' | ||
gem 'xcpretty' | ||
gem 'rake' | ||
gem 'octokit', '~> 4.7' | ||
gem 'rake' | ||
gem 'xcpretty' |
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 does that with with system ruby? I though that syntax was Ruby 2.1 or 2.2 only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik, it's ruby 1.9 syntax: