-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add action to generate snapshot builds #19
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0317c98
Add action to generate snapshot builds
trevor-e f7092f7
factor
trevor-e 40d2e4d
Fetch team id from appfile if present
trevor-e c622058
don't remove dSYMs
trevor-e 6dcdc0d
Bring back warning
trevor-e b6e4703
Cleanup
trevor-e File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
lib/fastlane/plugin/emerge/actions/emerge_snapshot_action.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
require 'fastlane/action' | ||
require 'fastlane_core/print_table' | ||
require_relative '../helper/emerge_helper' | ||
require_relative '../helper/git' | ||
require_relative '../helper/github' | ||
require 'pathname' | ||
require 'tmpdir' | ||
require 'json' | ||
require 'fileutils' | ||
|
||
module Fastlane | ||
module Actions | ||
class EmergeSnapshotAction < Action | ||
def self.run(params) | ||
api_token = params[:api_token] | ||
|
||
git_params = Helper::EmergeHelper.make_git_params | ||
pr_number = params[:pr_number] || git_params.pr_number | ||
branch = params[:branch] || git_params.branch | ||
sha = params[:sha] || git_params.sha | ||
base_sha = params[:base_sha] || git_params.base_sha | ||
repo_name = params[:repo_name] || git_params.repo_name | ||
gitlab_project_id = params[:gitlab_project_id] | ||
tag = params[:tag] | ||
config_path = params[:config_path] | ||
scheme = params[:scheme] | ||
configuration = params[:configuration] | ||
team_id = params[:team_id] || CredentialsManager::AppfileConfig.try_fetch_value(:team_id) | ||
|
||
Dir.mktmpdir do |temp_dir| | ||
archive_name = "#{scheme}-Emerge-Snapshots" | ||
archive_path = "#{temp_dir}/build/#{archive_name}.xcarchive" | ||
make_debug_build( | ||
scheme: scheme, | ||
configuration: configuration, | ||
team_id: team_id, | ||
archive_path: archive_path | ||
) | ||
Helper::EmergeHelper.copy_config(config_path, archive_path) | ||
Xcodeproj::Plist.write_to_path({ "NAME" => "Emerge Upload" }, "#{archive_path}/Info.plist") | ||
|
||
zip_file_path = "#{temp_dir}/build/#{archive_name}.xcarchive.zip" | ||
ZipAction.run( | ||
path: archive_path, | ||
output_path: zip_file_path, | ||
exclude: [], | ||
include: [] | ||
) | ||
|
||
params = { | ||
appIdSuffix: 'snapshots', | ||
prNumber: pr_number, | ||
branch: branch, | ||
sha: sha, | ||
baseSha: base_sha, | ||
repoName: repo_name, | ||
gitlabProjectId: gitlab_project_id, | ||
tag: tag || "default" | ||
} | ||
upload_id = Helper::EmergeHelper.perform_upload(api_token, params, zip_file_path) | ||
UI.success("🎉 Your app is processing, you can find the results at https://emergetools.com/snapshot/#{upload_id}") | ||
end | ||
end | ||
|
||
def self.make_debug_build(scheme:, configuration:, team_id:, archive_path:) | ||
other_action.gym( | ||
scheme: scheme, | ||
configuration: configuration, | ||
skip_codesigning: true, | ||
clean: true, | ||
export_method: "development", | ||
export_team_id: team_id, | ||
skip_package_ipa: true, | ||
archive_path: archive_path | ||
) | ||
end | ||
|
||
def self.description | ||
"Fastlane plugin for Emerge to generate iOS snapshots" | ||
end | ||
|
||
def self.authors | ||
["Emerge Tools"] | ||
end | ||
|
||
def self.return_value | ||
"If successful, returns the upload id of the generated snapshot build" | ||
end | ||
|
||
def self.details | ||
"" | ||
end | ||
|
||
def self.available_options | ||
[ | ||
FastlaneCore::ConfigItem.new(key: :api_token, | ||
env_name: "EMERGE_API_TOKEN", | ||
description: "An API token for Emerge", | ||
optional: false, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :scheme, | ||
description: "The scheme of your app to build", | ||
optional: false, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :configuration, | ||
description: "The configuration of your app to use", | ||
optional: false, | ||
default_value: "Debug", | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :team_id, | ||
env_name: "EXPORT_TEAM_ID", | ||
description: "The Apple Team ID to use for exporting the archive. If not provided, we will try to use the team_id from the Appfile", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :config_path, | ||
description: "Path to Emerge YAML config path", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :pr_number, | ||
description: "The PR number that triggered this upload", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :branch, | ||
description: "The current git branch", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :sha, | ||
description: "The git SHA that triggered this build", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :base_sha, | ||
description: "The git SHA of the base build", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :repo_name, | ||
description: "Full name of the respository this upload was triggered from. For example: EmergeTools/Emerge", | ||
optional: true, | ||
type: String), | ||
FastlaneCore::ConfigItem.new(key: :gitlab_project_id, | ||
description: "Id of the gitlab project this upload was triggered from", | ||
optional: true, | ||
type: Integer), | ||
FastlaneCore::ConfigItem.new(key: :tag, | ||
description: "String to label the build. Useful for grouping builds together in our dashboard, like development, default, or pull-request", | ||
optional: true, | ||
type: String) | ||
] | ||
end | ||
|
||
def self.is_supported?(platform) | ||
platform == :ios | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Fastlane | ||
module Emerge | ||
VERSION = "0.8.0" | ||
VERSION = "0.9.0" | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing this in the new response handling code, where did it go?