From 65783f75328bfcc42e360f42ed7ab803feae0773 Mon Sep 17 00:00:00 2001 From: Beniamin Sarkisian Date: Wed, 5 May 2021 10:44:33 +0300 Subject: [PATCH 1/3] Add app_version and app_build_number parameters to specify build --- lib/watchbuild/options.rb | 10 ++++++++++ lib/watchbuild/runner.rb | 13 ++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/watchbuild/options.rb b/lib/watchbuild/options.rb index 70e0578..0a212c9 100644 --- a/lib/watchbuild/options.rb +++ b/lib/watchbuild/options.rb @@ -14,6 +14,16 @@ def self.available_options description: 'The bundle identifier of your app', code_gen_sensitive: true, default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier)), + FastlaneCore::ConfigItem.new(key: :app_version, + env_name: 'APP_VERSION', + description: 'The version of your app', + type: String, + optional: true), + FastlaneCore::ConfigItem.new(key: :app_build_number, + env_name: 'APP_BUILD_NUMBER', + description: 'The build number of your app', + type: String, + optional: true), FastlaneCore::ConfigItem.new(key: :username, short_option: '-u', env_name: 'FASTLANE_USER', diff --git a/lib/watchbuild/runner.rb b/lib/watchbuild/runner.rb index 1628dd6..e0d5f83 100644 --- a/lib/watchbuild/runner.rb +++ b/lib/watchbuild/runner.rb @@ -137,9 +137,16 @@ def notify_terminal(build, minutes, url) # Otherwise fetches a build (to get updated state) def find_build(build) if build.nil? - build = app.get_builds(includes: Spaceship::ConnectAPI::Build::ESSENTIAL_INCLUDES).select do |build| - build.processing_state == Spaceship::ConnectAPI::Build::ProcessingState::PROCESSING - end.sort_by(&:uploaded_date).last + if app_version = WatchBuild.config[:app_version] && app_build_number = WatchBuild.config[:app_build_number] + build = app.get_builds(includes: Spaceship::ConnectAPI::Build::ESSENTIAL_INCLUDES).find do |build| + build.processing_state == Spaceship::ConnectAPI::Build::ProcessingState::PROCESSING && + build.app_version == app_version && build.version == app_build_number + end + else + build = app.get_builds(includes: Spaceship::ConnectAPI::Build::ESSENTIAL_INCLUDES).select do |build| + build.processing_state == Spaceship::ConnectAPI::Build::ProcessingState::PROCESSING + end.sort_by(&:uploaded_date).last + end else build = Spaceship::ConnectAPI::Build.get(build_id: build.id, includes: Spaceship::ConnectAPI::Build::ESSENTIAL_INCLUDES) end From 6339e331707f8a1ced87cc742b7c1e12777817cc Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 12 Jul 2021 13:26:09 -0500 Subject: [PATCH 2/3] Improved some logic with app_version and app_build_number --- lib/watchbuild/runner.rb | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/watchbuild/runner.rb b/lib/watchbuild/runner.rb index e0d5f83..d0659da 100644 --- a/lib/watchbuild/runner.rb +++ b/lib/watchbuild/runner.rb @@ -137,16 +137,27 @@ def notify_terminal(build, minutes, url) # Otherwise fetches a build (to get updated state) def find_build(build) if build.nil? - if app_version = WatchBuild.config[:app_version] && app_build_number = WatchBuild.config[:app_build_number] - build = app.get_builds(includes: Spaceship::ConnectAPI::Build::ESSENTIAL_INCLUDES).find do |build| - build.processing_state == Spaceship::ConnectAPI::Build::ProcessingState::PROCESSING && - build.app_version == app_version && build.version == app_build_number + builds = app.get_builds(includes: Spaceship::ConnectAPI::Build::ESSENTIAL_INCLUDES).select do |build| + build.processing_state == Spaceship::ConnectAPI::Build::ProcessingState::PROCESSING + end + + puts "builds: #{builds.size}" + + # Filter specific app_verison if specified + if (app_version = WatchBuild.config[:app_version]) + builds = builds.select do |build| + build.app_version.to_s == app_version.to_s end - else - build = app.get_builds(includes: Spaceship::ConnectAPI::Build::ESSENTIAL_INCLUDES).select do |build| - build.processing_state == Spaceship::ConnectAPI::Build::ProcessingState::PROCESSING - end.sort_by(&:uploaded_date).last end + + # Filter specific app_build_number if specified + if (app_build_number = WatchBuild.config[:app_build_number]) + builds = builds.select do |build| + build.version.to_s == app_build_number.to_s + end + end + + build = builds.sort_by(&:uploaded_date).last else build = Spaceship::ConnectAPI::Build.get(build_id: build.id, includes: Spaceship::ConnectAPI::Build::ESSENTIAL_INCLUDES) end From 0ac7a1dd97ed861ec539e1f78f33b57189df86d0 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Mon, 12 Jul 2021 19:33:32 -0500 Subject: [PATCH 3/3] Remove puts --- lib/watchbuild/runner.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/watchbuild/runner.rb b/lib/watchbuild/runner.rb index d0659da..36629e9 100644 --- a/lib/watchbuild/runner.rb +++ b/lib/watchbuild/runner.rb @@ -141,8 +141,6 @@ def find_build(build) build.processing_state == Spaceship::ConnectAPI::Build::ProcessingState::PROCESSING end - puts "builds: #{builds.size}" - # Filter specific app_verison if specified if (app_version = WatchBuild.config[:app_version]) builds = builds.select do |build|