Bgerstle has uploaded a new change for review. https://gerrit.wikimedia.org/r/207848
Change subject: CI fixes ...................................................................... CI fixes Change-Id: I5afbacdfb916c88b21162928762d965735d748d9 --- M .gitignore M Gemfile M Gemfile.lock M fastlane/Appfile M fastlane/Deliverfile M fastlane/Fastfile M fastlane/lib/utils.rb 7 files changed, 227 insertions(+), 147 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia refs/changes/48/207848/1 diff --git a/.gitignore b/.gitignore index 6dbb5fe..02159c8 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ *.hmap *.ipa *.xcuserstate +*.dSYM.zip # Icons Wikipedia/Images.xcassets/AppIcon.appiconset/*.png diff --git a/Gemfile b/Gemfile index 449e109..5b621c6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source "https://rubygems.org" gem 'cocoapods', '~> 0.36.1' -gem 'fastlane', '~> 0.4.2' -gem 'git' +gem 'fastlane', '~> 0.12.0' +gem 'git', '= 1.2.8' diff --git a/Gemfile.lock b/Gemfile.lock index fb09ac8..76c7ce4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,9 +8,9 @@ thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.8) - aws-sdk (1.63.0) - aws-sdk-v1 (= 1.63.0) - aws-sdk-v1 (1.63.0) + aws-sdk (1.64.0) + aws-sdk-v1 (= 1.64.0) + aws-sdk-v1 (1.64.0) json (~> 1.4) nokogiri (>= 1.4.4) babosa (1.0.2) @@ -20,8 +20,9 @@ rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - cert (0.1.3) - fastlane_core (>= 0.2.0) + cert (0.1.9) + fastlane_core (>= 0.6.0) + certified (1.0.0) claide (0.8.1) cliver (0.3.2) cocoapods (0.36.1) @@ -50,69 +51,92 @@ netrc (= 0.7.8) cocoapods-try (0.4.3) colored (1.2) - commander (4.3.2) - highline (~> 1.7.1) - credentials_manager (0.1.3) + commander (4.3.3) + highline (~> 1.7.2) + credentials_manager (0.3.0) colored - highline + highline (>= 1.7.1) security - deliver (0.8.1) + cupertino (1.3.3) + certified (~> 1.0.0) + commander (~> 4.3) + highline (>= 1.7.1) + mechanize (~> 2.5.1) + nokogiri (~> 1.6.3) + security (~> 0.1.2) + term-ansicolor (~> 1.0.7) + terminal-table (~> 1.4.5) + deliver (0.9.3) + credentials_manager (>= 0.3.0) excon fastimage (~> 1.6.3) - fastlane_core (>= 0.2.0) + fastlane_core (>= 0.5.2) nokogiri (~> 1.6.5) plist (~> 3.1.0) prawn rubyzip (~> 1.1.6) + domain_name (0.5.24) + unf (>= 0.0.5, < 1.0.0) dotenv (0.11.1) dotenv-deployment (~> 0.0.2) dotenv-deployment (0.0.2) escape (0.0.4) - excon (0.45.1) + excon (0.45.3) faraday (0.8.9) multipart-post (~> 1.2.0) faraday_middleware (0.9.1) faraday (>= 0.7.4, < 0.10) fastimage (1.6.8) addressable (~> 2.3, >= 2.3.5) - fastlane (0.4.2) + fastlane (0.12.5) aws-sdk (~> 1.0) - cert (>= 0.1.3) - deliver (>= 0.7.13) - fastlane_core (>= 0.3.4) - frameit (>= 0.2.3) - nokogiri (~> 1.6.5) - pem (>= 0.3.8) - produce (>= 0.1.6) - shenzhen (~> 0.12.1) - sigh (>= 0.4.5) + cert (>= 0.1.7) + cupertino (>= 1.3.3) + deliver (>= 0.9.3) + fastlane_core (>= 0.6.2) + frameit (>= 1.0.0) + nokogiri (~> 1.6) + pem (>= 0.5.4) + produce (>= 0.2.0) + shenzhen (~> 0.12) + sigh (>= 0.4.10) slack-notifier (~> 1.0) - snapshot (>= 0.4.0) + snapshot (>= 0.7.0) terminal-notifier (~> 1.6.2) + terminal-table (~> 1.4.5) xcodeproj (~> 0.20) xcpretty (~> 0.1) - fastlane_core (0.3.4) + fastlane_core (0.6.2) babosa capybara (~> 2.4.3) colored commander (>= 4.1.0) - credentials_manager (>= 0.1.3) - highline + credentials_manager (>= 0.2.1) + excon (~> 0.45.0) + highline (>= 1.7.2) json multi_json phantomjs (~> 1.9.8) poltergeist (~> 1.5.1) - frameit (0.2.3) + frameit (1.0.1) deliver (> 0.3) fastimage (~> 1.6.3) - fastlane_core (>= 0.2.0) + fastlane_core (>= 0.5.0) mini_magick (~> 4.0.2) fuzzy_match (2.0.4) - git (1.2.9.1) - highline (1.7.1) + git (1.2.8) + highline (1.7.2) i18n (0.7.0) json (1.8.2) - mime-types (2.4.3) + mechanize (2.5.1) + domain_name (~> 0.5, >= 0.5.1) + mime-types (~> 1.17, >= 1.17.2) + net-http-digest_auth (~> 1.1, >= 1.1.1) + net-http-persistent (~> 2.5, >= 2.5.2) + nokogiri (~> 1.4) + ntlm-http (~> 0.1, >= 0.1.1) + webrobots (~> 0.0, >= 0.0.9) + mime-types (1.25.1) mini_magick (4.0.4) mini_portile (0.6.2) minitest (5.5.1) @@ -120,16 +144,19 @@ multi_json (1.11.0) multipart-post (1.2.0) nap (0.8.0) + net-http-digest_auth (1.4) + net-http-persistent (2.9.4) net-sftp (2.1.2) net-ssh (>= 2.6.5) net-ssh (2.9.2) netrc (0.7.8) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) + ntlm-http (0.1.1) open4 (1.3.4) pdf-core (0.5.1) - pem (0.3.8) - fastlane_core (>= 0.3.1) + pem (0.5.4) + fastlane_core (>= 0.6.0) phantomjs (1.9.8.0) plist (3.1.0) poltergeist (1.5.1) @@ -140,45 +167,51 @@ prawn (2.0.1) pdf-core (~> 0.5.1) ttfunk (~> 1.4.0) - produce (0.1.6) - fastlane_core (>= 0.2.0) + produce (0.2.0) + fastlane_core (>= 0.5.0) rack (1.6.0) rack-test (0.6.3) rack (>= 1.0) rubyzip (1.1.7) security (0.1.3) - shenzhen (0.12.1) + shenzhen (0.14.0) aws-sdk (~> 1.0) commander (~> 4.3) dotenv (~> 0.7) faraday (~> 0.8.9) faraday_middleware (~> 0.9) + highline (>= 1.7.1) json (~> 1.8) net-sftp (~> 2.1.2) plist (~> 3.1.0) rubyzip (~> 1.1) security (~> 0.1.3) terminal-table (~> 1.4.5) - sigh (0.4.7) - fastlane_core (>= 0.3.1) + sigh (0.4.10) + fastlane_core (>= 0.6.0) plist (~> 3.1.0) - slack-notifier (1.1.0) - snapshot (0.5.0) + slack-notifier (1.2.0) + snapshot (0.7.1) fastimage (~> 1.6.3) - fastlane_core (>= 0.2.0) - terminal-notifier (1.6.2) + fastlane_core (>= 0.5.0) + term-ansicolor (1.0.7) + terminal-notifier (1.6.3) terminal-table (1.4.5) thread_safe (0.3.5) ttfunk (1.4.0) tzinfo (1.2.2) thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.1) + webrobots (0.1.1) websocket-driver (0.5.4) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) xcodeproj (0.23.1) activesupport (>= 3) colored (~> 1.2) - xcpretty (0.1.8) + xcpretty (0.1.10) xpath (2.0.0) nokogiri (~> 1.3) @@ -187,5 +220,5 @@ DEPENDENCIES cocoapods (~> 0.36.1) - fastlane (~> 0.4.2) - git + fastlane (~> 0.12.0) + git (= 1.2.8) diff --git a/fastlane/Appfile b/fastlane/Appfile index 17c8caa..6496604 100644 --- a/fastlane/Appfile +++ b/fastlane/Appfile @@ -4,19 +4,4 @@ team_name "Wikimedia Foundation" # Account to use to submit builds -apple_id "cfl...@wikimedia.org" - -# Set the app identifier for each build (used to look up the app in itunes connect) -#app_identifier "org.wikimedia.wikipedia.tfalpha" - -# for_lane :alpha do -# app_identifier "org.wikimedia.wikipedia.tfbeta" -# end -# -# for_lane :beta do -# app_identifier "org.wikimedia.wikipedia.tfbeta" -# end -# -# for_lane :appstore do -# app_identifier "org.wikimedia.wikipedia" -# end +apple_id ENV['WMF_APPLE_USER_NAME'] diff --git a/fastlane/Deliverfile b/fastlane/Deliverfile index 4844a7e..9a0ce06 100644 --- a/fastlane/Deliverfile +++ b/fastlane/Deliverfile @@ -4,7 +4,7 @@ # hide_transporter_output # remove the '#' in the beginning of the line, to hide the output while uploading -# Set paths to the ipa file +# Tell deliver to use ENV vars populated by ipa action ipa ENV["IPA_OUTPUT_PATH"] beta_ipa ENV["IPA_OUTPUT_PATH"] @@ -13,8 +13,8 @@ # App Metadata ######################################## -# Set apple_id for Testflight builds -apple_id '981253550' +# Use apple id set by produce +apple_id ENV['PRODUCE_APPLE_ID'] copyright "#{Time.now.year} Wikimedia Foundation" @@ -26,3 +26,4 @@ # version '1.2' # you can pass this if you want to verify the version number with the ipa file config_json_folder './deliver' + diff --git a/fastlane/Fastfile b/fastlane/Fastfile index a43ae7a..9aab23a 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -7,12 +7,10 @@ require 'lib/utils.rb' +ENV['WMF_VERSION_NUMBER'] ||= get_version_short_string File.expand_path(File.join(ENV['PWD'], 'Wikipedia/Wikipedia-Info.plist')) + before_all do p ENV - unless reset_disabled? - reset_git_repo :force - ensure_git_status_clean - end end lane :test do @@ -21,6 +19,8 @@ end lane :alpha do + ensure_git_status_clean + run_unit_tests # Download the Certificate for signing @@ -35,31 +35,21 @@ # Create the app in iTunes Connect if needed produce({ - produce_username: 'cfl...@wikimedia.org', + produce_username: ENV['WMF_APPLE_USER_NAME'], produce_app_identifier: 'org.wikimedia.wikipedia.tfalpha', produce_app_identifier_suffix: '', #work around for: https://github.com/KrauseFx/produce/issues/27 produce_app_name: 'Wikipedia Alpha', produce_language: 'English', - produce_version: '4.1.1', + produce_version: ENV['WMF_VERSION_NUMBER'], produce_sku: '01985', }) - increment_build_number ENV['BUILD_NUMBER'].to_i - - # Create and sign the IPA (and DSYM) - ipa({ - scheme: 'Wikipedia Alpha', - configuration: 'Alpha', #Prevents fastlane from passing --configuration "Release" - bug? - clean: nil, # this means 'Do Clean'. Clean project before building. - archive: nil, # this means 'Do Archive'. Archive project to the Xcode organizer after building. - # verbose: nil, # this means 'Do Verbose'. - }) - - deploy_testflight_build - + deploy_testflight_build 'Wikipedia Alpha', 'Alpha' end lane :beta do + ensure_git_status_clean + run_unit_tests # Download the Certificate for signing @@ -74,37 +64,51 @@ # Create the app in iTunes Connect if needed produce({ - produce_username: 'cfl...@wikimedia.org', + produce_username: ENV['WMF_APPLE_USER_NAME'], produce_app_identifier: 'org.wikimedia.wikipedia.tfbeta', + produce_app_identifier_suffix: '', #work around for: https://github.com/KrauseFx/produce/issues/27 produce_app_name: 'Wikipedia Beta', produce_language: 'English', - produce_version: '4.1.1', + produce_version: ENV['WMF_VERSION_NUMBER'], produce_sku: '01984', }) - increment_build_number ENV['BUILD_NUMBER'].to_i + deploy_testflight_build 'Wikipedia Beta', 'Beta' +end - # Create and sign the IPA (and DSYM) - ipa({ - scheme: 'Wikipedia Beta', - configuration: 'Beta', #Prevents fastlane from passing --configuration "Release" - bug? - clean: true, - archive: nil +# Untested! +lane :appstore do + ensure_git_status_clean + + run_unit_tests + + # Download the Certificate for signing + cert + + # Create and/or download the right provisioning profile + sigh({ + provisioning_name: 'org.wikimedia.wikipedia AppStore', + app_identifier: 'org.wikimedia.wikipedia', }) - deploy_testflight_build + # Create the app in iTunes Connect if needed + produce({ + produce_username: ENV['WMF_APPLE_USER_NAME'], + produce_app_identifier: 'org.wikimedia.wikipedia', + produce_app_identifier_suffix: '', #work around for: https://github.com/KrauseFx/produce/issues/27 + produce_app_name: 'Wikipedia Mobile', + produce_language: 'English', + produce_version: ENV['WMF_VERSION_NUMBER'], + produce_sku: '01982', + }) + # Set variables for building and distributing + ENV['IPA_BUILD_SCHEME'] = 'Wikipedia' + ENV['IPA_BUILD_CONFIG'] = 'Release' + ENV['APP_APPLE_ID'] = '324715238' + + deploy_appstore_build end - -lane :appstore do - run_unit_tests - snapshot - frameit - unless deploy_disabled? - deliver :skip_deploy, :force - end -end - # after_all do |lane| # end diff --git a/fastlane/lib/utils.rb b/fastlane/lib/utils.rb index f9f55ed..307887f 100644 --- a/fastlane/lib/utils.rb +++ b/fastlane/lib/utils.rb @@ -2,13 +2,6 @@ require 'git' -ENV['HOCKEY_API_TOKEN'] = 'c881c19fd8d0401682c4640b7948ef5e' - -# Returns true if the `NO_RESET` env var is set to 1 -def reset_disabled? - ENV['NO_RESET'] == '1' -end - # Returns true if the `NO_DEPLOY` env var is set to 1 def deploy_disabled? ENV['NO_DEPLOY'] == '1' @@ -18,6 +11,7 @@ def test_disabled? ENV['NO_TEST'] == '1' end + # Runs goals from the project's Makefile, this requires going up to the project directory. # :args: Additional arguments to be passed to `make`. # Returns The result of the `make` command @@ -29,32 +23,34 @@ end def run_unit_tests - - unless test_disabled? - xctest({ - scheme: 'Wikipedia', - destination: "platform=iOS Simulator,name=iPhone 6,OS=8.3", - reports: [{ + return if test_disabled? + xctest({ + scheme: 'Wikipedia', + destination: "platform=iOS Simulator,name=iPhone 6,OS=8.3", + reports: [ + { report: "html", output: "build/reports/report.html" }, { report: "junit", output: "build/reports/report.xml" - }], - clean: nil - }) - - end + } + ], + clean: nil + }) end # Generate a list of commit subjects from `rev` to `HEAD` # :rev: The git SHA to start the log from, defaults to `ENV[LAST_SUCCESS_REV']` -def generate_git_commit_log(rev=ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT']) +def generate_git_commit_log(rev=ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD^^^^^') g = Git.open(ENV['PWD'], :log => Logger.new(STDOUT)) - change_log = g.log.between(rev).map { |c| "- " + c.message.lines.first.chomp }.join "\n" - "Commit Log:\n\n#{change_log}\n" - p change_log + begin + change_log = g.log.between(rev).map { |c| "- " + c.message.lines.first.chomp }.join "\n" + "Commit Log:\n\n#{change_log}\n" + rescue + "Unable to parse commit logs" + end end # Memoized version of `generate_git_commit_log` which stores the result in `ENV['GIT_COMMIT_LOG']`. @@ -62,24 +58,84 @@ ENV['GIT_COMMIT_LOG'] || ENV['GIT_COMMIT_LOG'] = generate_git_commit_log end -def deploy_testflight_build - unless deploy_disabled? - # Upload the DSYM to Hockey - hockey({ - api_token: ENV['HOCKEY_API_TOKEN'], - notes: '', - notify: 0, - status: 1, #Means do not make available for download - }) - - #Set "Feedback email" in iTunes Connect for Testflight builds - self.class.const_set("DELIVER_BETA_FEEDBACK_EMAIL", 'ab...@wikimedia.org') - #Set "What To Test" in iTunes Connect for Testflight builds, in the future, reference tickets instead of git commits - self.class.const_set("DELIVER_WHAT_TO_TEST", git_commit_log) - #Set "App Description" in iTunes Connect for Testflight builds, in the future set a better description - self.class.const_set("DELIVER_BETA_DESCRIPTION", git_commit_log) - - # Upload the IPA and DSYM to iTunes Connect - deliver :testflight, :beta, :skip_deploy, :force - end +# Parses JSON output of `plutil` +def info_plist_to_hash(path) + require 'json' + JSON.parse! %x[plutil -convert json -o - #{path}] end + +# Hack to read app version from Info.plist +def get_version_short_string(path) + plist_hash = info_plist_to_hash path + plist_hash['CFBundleShortVersionString'] +end + +def deploy_testflight_build(scheme, config) + return if deploy_disabled? + + # Used in Deliverfile to set app's identifier in iTC + ENV['APP_APPLE_ID'] = appId + + increment_version_number( + version_number: ENV['WMF_VERSION_NUMBER'] + ) + + # use Jenkins build number + increment_build_number( + build_number: ENV['BUILD_NUMBER'].to_i + ) + + # Create and sign the IPA (and DSYM) + ipa({ + scheme: scheme, + configuration: config, #Prevents fastlane from passing --configuration "Release" - bug? + clean: true, + archive: nil, + # verbose: nil, # this means 'Be Verbose'. + }) + + # Upload the DSYM to Hockey + hockey({ + notes: '', + notify: '0', #Means do not notify + status: '1', #Means do not make available for download + }) + + #Set "What To Test" in iTunes Connect for Testflight builds, in the future, reference tickets instead of git commits + ENV['DELIVER_WHAT_TO_TEST'] = git_commit_log + #Set "App Description" in iTunes Connect for Testflight builds, in the future set a better description + # ENV['DELIVER_BETA_DESCRIPTION'] = git_commit_log + + # Upload the IPA and DSYM to iTunes Connect + deliver( + force: true, # Set to true to skip PDF verification + beta: true, # Upload a new version to TestFlight + skip_deploy: true, # Set true to not submit app for review (works with both App Store and beta builds) + ) +end + +def deploy_appstore_build + return if deploy_disabled? + # Create and sign the IPA (and DSYM) + ipa({ + scheme: ENV['IPA_BUILD_SCHEME'], + configuration: ENV['IPA_BUILD_CONFIG'], #Prevents fastlane from passing --configuration "Release" - bug? + clean: true, + archive: nil, + # verbose: nil, # this means 'Be Verbose'. + }) + + # Upload the DSYM to Hockey + hockey({ + notes: '', + notify: '0', #Means do not notify + status: '1', #Means do not make available for download + }) + + # Upload the IPA and DSYM to iTunes Connect + deliver( + force: true, # Set to true to skip PDF verification + skip_deploy: true, # Set true to not submit app for review (works with both App Store and beta builds) + ) +end + -- To view, visit https://gerrit.wikimedia.org/r/207848 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5afbacdfb916c88b21162928762d965735d748d9 Gerrit-PatchSet: 1 Gerrit-Project: apps/ios/wikipedia Gerrit-Branch: master Gerrit-Owner: Bgerstle <bgers...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits