Skip to content

Commit be8cebb

Browse files
committed
Add InstabugBuildIosAppAction for iOS build with metadata reporting
1 parent cbc2cc6 commit be8cebb

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
require 'fastlane/action'
2+
require_relative '../helper/instabug_stores_upload_helper'
3+
4+
module Fastlane
5+
module Actions
6+
class InstabugBuildIosAppAction < Action
7+
def self.run(params)
8+
UI.message("Starting Instabug iOS build...")
9+
10+
# Extract Instabug-specific parameters
11+
branch_name = params.delete(:branch_name)
12+
instabug_api_key = params.delete(:instabug_api_key)
13+
14+
# Validate required parameters
15+
if branch_name.nil? || branch_name.empty?
16+
UI.user_error!("branch_name is required for Instabug reporting")
17+
end
18+
19+
begin
20+
# Report build start to Instabug
21+
Helper::InstabugStoresUploadHelper.report_status(
22+
branch_name: branch_name,
23+
api_key: instabug_api_key,
24+
status: "inprogress",
25+
step: "build_app"
26+
)
27+
28+
# Execute the actual iOS build
29+
result = Actions::BuildIosAppAction.run(params)
30+
31+
# Report build success to Instabug
32+
Helper::InstabugStoresUploadHelper.report_status(
33+
branch_name: branch_name,
34+
api_key: instabug_api_key,
35+
status: "success",
36+
step: "build_app"
37+
)
38+
39+
UI.success("iOS build completed successfully!")
40+
result
41+
rescue => e
42+
UI.error("iOS build failed: #{e.message}")
43+
44+
# Report build failure to Instabug
45+
Helper::InstabugStoresUploadHelper.report_status(
46+
branch_name: branch_name,
47+
api_key: instabug_api_key,
48+
status: "failure",
49+
step: "build_app"
50+
)
51+
raise e
52+
end
53+
end
54+
55+
def self.description
56+
"Build iOS app with Instabug metadata reporting"
57+
end
58+
59+
def self.authors
60+
["Instabug Company"]
61+
end
62+
63+
def self.return_value
64+
"Returns the result from build_ios_app action"
65+
end
66+
67+
def self.details
68+
"This action wraps the standard build_ios_app action and adds Instabug-specific metadata reporting. It tracks build events per branch and provides better observability for engineering teams."
69+
end
70+
71+
def self.available_options
72+
# Start with the original build_ios_app options
73+
options = Actions::BuildIosAppAction.available_options
74+
75+
# Add Instabug-specific options
76+
instabug_options = [
77+
FastlaneCore::ConfigItem.new(
78+
key: :branch_name,
79+
env_name: "INSTABUG_BRANCH_NAME",
80+
description: "The branch name for tracking builds",
81+
optional: false,
82+
type: String
83+
),
84+
FastlaneCore::ConfigItem.new(
85+
key: :instabug_api_key,
86+
env_name: "INSTABUG_API_KEY",
87+
description: "Instabug API key for reporting build events",
88+
optional: false,
89+
type: String,
90+
sensitive: true
91+
)
92+
]
93+
94+
# Combine both sets of options
95+
options + instabug_options
96+
end
97+
98+
def self.is_supported?(platform)
99+
[:ios, :mac].include?(platform)
100+
end
101+
102+
def self.example_code
103+
[
104+
'instabug_build_ios_app(
105+
branch_name: "main",
106+
instabug_api_key: "your-api-key",
107+
workspace: "MyApp.xcworkspace",
108+
scheme: "MyApp",
109+
export_method: "app-store",
110+
configuration: "Release"
111+
)'
112+
]
113+
end
114+
115+
def self.category
116+
:building
117+
end
118+
end
119+
end
120+
end

0 commit comments

Comments
 (0)