Skip to content

Commit

Permalink
fix: Another attempt, the path spec wasn't the issue, so lets try and…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
othyn committed Jul 14, 2023
1 parent 6d4825e commit c995bae
Showing 1 changed file with 36 additions and 21 deletions.
57 changes: 36 additions & 21 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c995bae

Please sign in to comment.