From c995baebcba8c40c1f4d7901459cb2f1f8aec417 Mon Sep 17 00:00:00 2001 From: Ben <git@othyn.com> Date: Fri, 14 Jul 2023 21:19:13 +0200 Subject: [PATCH] fix: Another attempt, the path spec wasn't the issue, so lets try and fix the script so that it fails correctly and stops the release process if the build fails, by correctly listening for the only exit codes that are 'fine', 0 or 2 --- fastlane/Fastfile | 57 ++++++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index a53dea0..ca844fe 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -16,15 +16,20 @@ platform :mac do ) # https://docs.fastlane.tools/actions/sh/#sh + # https://docs.fastlane.tools/advanced/actions/#using-the-sh-method # https://docs.fastlane.tools/advanced/fastlane/#directory-behavior - sh "sudo ../node_modules/.bin/create-dmg ../macos-auto-clicker/build/AutoClicker.app --overwrite ../build", log: true, error_callback: -> (result) { - # As the code signing will fail, it will respond with an exit code of 2 instead of a success of 0, - # which fastlane will flag as an error. However if the DMG fails to build, it will be an exit code of 1. - # It would be great if I could check the exit code and only flag as no error if the exit code is 2, - # but this does not appear to be possible - print(result) + # https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/helper/sh_helper.rb#L60 + # https://github.com/advoryanskiy/fastlane-plugin-dmg/pull/8/files#diff-3dea31081a0536cea09f436f364f5ce26853b49a023ac8b9836f64920e038cadR33 + sh "sudo", "../node_modules/.bin/create-dmg", "../build/AutoClicker.app", "--overwrite", "../build" do |status, result, command| error_occurred = false - } + + unless status.exitstatus == 0 || status.exitstatus == 2 + UI.error "Command #{command} (pid #{status.pid}) failed with status #{status.exitstatus}" + error_occurred = true + end + + UI.message "Output is #{result.inspect}" + end end lane :beta do @@ -95,15 +100,20 @@ platform :mac do ) # https://docs.fastlane.tools/actions/sh/#sh + # https://docs.fastlane.tools/advanced/actions/#using-the-sh-method # https://docs.fastlane.tools/advanced/fastlane/#directory-behavior - sh "sudo ../node_modules/.bin/create-dmg ../macos-auto-clicker/build/AutoClicker.app --overwrite ../build", log: true, error_callback: -> (result) { - # As the code signing will fail, it will respond with an exit code of 2 instead of a success of 0, - # which fastlane will flag as an error. However if the DMG fails to build, it will be an exit code of 1. - # It would be great if I could check the exit code and only flag as no error if the exit code is 2, - # but this does not appear to be possible - print(result) + # https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/helper/sh_helper.rb#L60 + # https://github.com/advoryanskiy/fastlane-plugin-dmg/pull/8/files#diff-3dea31081a0536cea09f436f364f5ce26853b49a023ac8b9836f64920e038cadR33 + sh "sudo", "../node_modules/.bin/create-dmg", "../build/AutoClicker.app", "--overwrite", "../build" do |status, result, command| error_occurred = false - } + + unless status.exitstatus == 0 || status.exitstatus == 2 + UI.error "Command #{command} (pid #{status.pid}) failed with status #{status.exitstatus}" + error_occurred = true + end + + UI.message "Output is #{result.inspect}" + end # https://docs.fastlane.tools/actions/set_github_release/#set_github_release set_github_release( @@ -199,15 +209,20 @@ platform :mac do ) # https://docs.fastlane.tools/actions/sh/#sh + # https://docs.fastlane.tools/advanced/actions/#using-the-sh-method # https://docs.fastlane.tools/advanced/fastlane/#directory-behavior - sh "sudo ../node_modules/.bin/create-dmg ../macos-auto-clicker/build/AutoClicker.app --overwrite ../build", log: true, error_callback: -> (result) { - # As the code signing will fail, it will respond with an exit code of 2 instead of a success of 0, - # which fastlane will flag as an error. However if the DMG fails to build, it will be an exit code of 1. - # It would be great if I could check the exit code and only flag as no error if the exit code is 2, - # but this does not appear to be possible - print(result) + # https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/helper/sh_helper.rb#L60 + # https://github.com/advoryanskiy/fastlane-plugin-dmg/pull/8/files#diff-3dea31081a0536cea09f436f364f5ce26853b49a023ac8b9836f64920e038cadR33 + sh "sudo", "../node_modules/.bin/create-dmg", "../build/AutoClicker.app", "--overwrite", "../build" do |status, result, command| error_occurred = false - } + + unless status.exitstatus == 0 || status.exitstatus == 2 + UI.error "Command #{command} (pid #{status.pid}) failed with status #{status.exitstatus}" + error_occurred = true + end + + UI.message "Output is #{result.inspect}" + end # https://docs.fastlane.tools/actions/set_github_release/#set_github_release set_github_release(