Skip to content

[GCSI-409] Add Fastlane build step #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 75 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,87 @@ fastlane add_plugin instabug-stores-upload

## About instabug-stores-upload

Wrapper plugin for uploading builds to App Store and Play Store with Instabug-specific metadata reporting.
Wrapper plugin for uploading builds to App Store and Play Store with Instabug-specific metadata reporting. This plugin provides custom actions that wrap the standard Fastlane actions and automatically report build and upload events to Instabug systems for better observability and integration into internal pipelines.

**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
### Available Actions

- `instabug_build_ios_app` - Build iOS apps with Instabug reporting
- `instabug_build_android_app` - Build Android apps with Instabug reporting
- `instabug_upload_to_app_store` - Upload iOS builds to App Store with Instabug reporting
- `instabug_upload_to_play_store` - Upload Android builds to Play Store with Instabug reporting

### Features

- Automatic reporting of build and upload events to Instabug
- Branch-based tracking for Instabug Agents observability
- Integration with existing Fastlane workflows
- Support for both iOS and Android platforms
- Secure API communication with Instabug services

## Example

Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.

**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
### Usage Examples

#### iOS Build
```ruby
lane :build_ios do
instabug_build_ios_app(
branch_name: "main",
instabug_api_key: ENV["INSTABUG_API_KEY"],
workspace: "MyApp.xcworkspace",
scheme: "MyApp",
export_method: "app-store",
configuration: "Release"
)
end
```

#### Android Build
```ruby
lane :build_android do
instabug_build_android_app(
branch_name: "main",
instabug_api_key: ENV["INSTABUG_API_KEY"],
task: "assembleRelease",
project_dir: "android/",
properties: {
"android.injected.signing.store.file" => "keystore.jks",
"android.injected.signing.store.password" => ENV["KEYSTORE_PASSWORD"],
"android.injected.signing.key.alias" => "key0",
"android.injected.signing.key.password" => ENV["KEY_PASSWORD"]
}
)
end
```

#### iOS Upload
```ruby
lane :upload_ios do
instabug_upload_to_app_store(
branch_name: "main",
instabug_api_key: ENV["INSTABUG_API_KEY"],
ipa: "path/to/your/app.ipa",
skip_screenshots: true,
skip_metadata: true
)
end
```

#### Android Upload
```ruby
lane :upload_android do
instabug_upload_to_play_store(
branch_name: "main",
instabug_api_key: ENV["INSTABUG_API_KEY"],
package_name: "com.example.app",
aab: "path/to/your/app.aab",
track: "internal",
skip_upload_screenshots: true
)
end
```

## Run tests for this plugin

Expand Down
36 changes: 35 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
# Fastfile for Instabug Stores Upload Plugin

# Example lane for building iOS app with Instabug reporting
lane :build_ios_app do |options|
branch_name = options[:branch_name]

instabug_build_ios_app(
branch_name: branch_name,
instabug_api_key: ENV["INSTABUG_API_KEY"],
# All standard build_ios_app parameters are supported
workspace: "MyApp.xcworkspace",
scheme: "MyApp",
export_method: "app-store",
configuration: "Release"
)
end

# Example lane for building Android app with Instabug reporting
lane :build_android_app do |options|
branch_name = options[:branch_name]

instabug_build_android_app(
branch_name: branch_name,
instabug_api_key: ENV["INSTABUG_API_KEY"],
# All standard gradle parameters are supported
task: "assembleRelease",
project_dir: "android/",
properties: {
"android.injected.signing.store.file" => "keystore.jks",
"android.injected.signing.store.password" => ENV["KEYSTORE_PASSWORD"],
"android.injected.signing.key.alias" => "key0",
"android.injected.signing.key.password" => ENV["KEY_PASSWORD"]
}
)
end

# Example lane for uploading to App Store with Instabug reporting
lane :upload_to_app_store do |options|
branch_name = options[:branch_name]
Expand All @@ -24,4 +58,4 @@ lane :upload_to_play_store do |options|
aab: "path/to/your/app.aab",
track: "internal"
)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
require 'fastlane/action'
require_relative '../helper/instabug_stores_upload_helper'

module Fastlane
module Actions
class InstabugBuildAndroidAppAction < Action
def self.run(params)
UI.message("Starting Instabug Android build...")

# Extract Instabug-specific parameters
branch_name = params.delete(:branch_name)
instabug_api_key = params.delete(:instabug_api_key)

# Validate required parameters
if branch_name.nil? || branch_name.empty?
UI.user_error!("branch_name is required for Instabug reporting")
end

begin
# Report build start to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
api_key: instabug_api_key,
status: "inprogress",
step: "build_app"
)

# Execute the actual Android build using gradle
result = Actions::GradleAction.run(params)

# Report build success to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
api_key: instabug_api_key,
status: "success",
step: "build_app"
)

UI.success("Android build completed successfully!")
result
rescue => e
UI.error("Android build failed: #{e.message}")

# Report build failure to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
api_key: instabug_api_key,
status: "failure",
step: "build_app"
)
raise e
end
end

def self.description
"Build Android app with Instabug metadata reporting"
end

def self.authors
["Instabug Company"]
end

def self.return_value
"Returns the result from gradle action"
end

def self.details
"This action wraps the standard gradle action and adds Instabug-specific metadata reporting. It tracks build events per branch and provides better observability for engineering teams."
end

def self.available_options
# Start with the original gradle options
options = Actions::GradleAction.available_options

# Add Instabug-specific options
instabug_options = [
FastlaneCore::ConfigItem.new(
key: :branch_name,
env_name: "INSTABUG_BRANCH_NAME",
description: "The branch name for tracking builds",
optional: false,
type: String
),
FastlaneCore::ConfigItem.new(
key: :instabug_api_key,
env_name: "INSTABUG_API_KEY",
description: "Instabug API key for reporting build events",
optional: false,
type: String,
sensitive: true
)
]

# Combine both sets of options
options + instabug_options
end

def self.is_supported?(platform)
platform == :android
end

def self.example_code
[
'instabug_build_android_app(
branch_name: "main",
instabug_api_key: "your-api-key",
task: "assembleRelease",
project_dir: "android/",
properties: {
"android.injected.signing.store.file" => "keystore.jks",
"android.injected.signing.store.password" => "password",
"android.injected.signing.key.alias" => "key0",
"android.injected.signing.key.password" => "password"
}
)'
]
end

def self.category
:building
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
require 'fastlane/action'
require_relative '../helper/instabug_stores_upload_helper'

module Fastlane
module Actions
class InstabugBuildIosAppAction < Action
def self.run(params)
UI.message("Starting Instabug iOS build...")

# Extract Instabug-specific parameters
branch_name = params.delete(:branch_name)
instabug_api_key = params.delete(:instabug_api_key)

# Validate required parameters
if branch_name.nil? || branch_name.empty?
UI.user_error!("branch_name is required for Instabug reporting")
end

begin
# Report build start to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
api_key: instabug_api_key,
status: "inprogress",
step: "build_app"
)

# Execute the actual iOS build
result = Actions::BuildIosAppAction.run(params)

# Report build success to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
api_key: instabug_api_key,
status: "success",
step: "build_app"
)

UI.success("iOS build completed successfully!")
result
rescue => e
UI.error("iOS build failed: #{e.message}")

# Report build failure to Instabug
Helper::InstabugStoresUploadHelper.report_status(
branch_name: branch_name,
api_key: instabug_api_key,
status: "failure",
step: "build_app"
)
raise e
end
end

def self.description
"Build iOS app with Instabug metadata reporting"
end

def self.authors
["Instabug Company"]
end

def self.return_value
"Returns the result from build_ios_app action"
end

def self.details
"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."
end

def self.available_options
# Start with the original build_ios_app options
options = Actions::BuildIosAppAction.available_options

# Add Instabug-specific options
instabug_options = [
FastlaneCore::ConfigItem.new(
key: :branch_name,
env_name: "INSTABUG_BRANCH_NAME",
description: "The branch name for tracking builds",
optional: false,
type: String
),
FastlaneCore::ConfigItem.new(
key: :instabug_api_key,
env_name: "INSTABUG_API_KEY",
description: "Instabug API key for reporting build events",
optional: false,
type: String,
sensitive: true
)
]

# Combine both sets of options
options + instabug_options
end

def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end

def self.example_code
[
'instabug_build_ios_app(
branch_name: "main",
instabug_api_key: "your-api-key",
workspace: "MyApp.xcworkspace",
scheme: "MyApp",
export_method: "app-store",
configuration: "Release"
)'
]
end

def self.category
:building
end
end
end
end
Loading