Class: Fastlane::Actions::PublishIosSdkAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/stream_actions/actions/publish_ios_sdk.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.available_optionsObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/fastlane/plugin/stream_actions/actions/publish_ios_sdk.rb', line 62

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :version,
      description: 'Release version (not required if release type is set)'
    ),
    FastlaneCore::ConfigItem.new(
      key: :sdk_names,
      description: 'SDK names to release (deprecated)',
      is_string: false,
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :skip_spm,
      description: 'Skip release to GitHub and SPM?',
      is_string: false,
      optional: true,
      default_value: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :skip_pods,
      description: 'Skip release to CocoaPods?',
      is_string: false,
      optional: true,
      default_value: false
    ),
    FastlaneCore::ConfigItem.new(
      key: :podspec_names,
      description: 'Podspec names to release',
      is_string: false,
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      env_name: 'GITHUB_REPOSITORY',
      key: :github_repo,
      description: 'Github repository name'
    ),
    FastlaneCore::ConfigItem.new(
      env_name: 'GITHUB_TOKEN',
      key: :github_token,
      description: 'GITHUB_TOKEN environment variable'
    ),
    FastlaneCore::ConfigItem.new(
      key: :skip_branch_check,
      description: 'Skip branch check',
      is_string: false,
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :skip_git_status_check,
      description: 'Skip git status check',
      is_string: false,
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :use_changelog,
      description: 'Use the changelog as a testflight instructions',
      is_string: false,
      default_value: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :changelog_path,
      env_name: 'FL_CHANGELOG_PATH',
      description: 'The path to your project CHANGELOG.md',
      is_string: true,
      default_value: './CHANGELOG.md'
    ),
    FastlaneCore::ConfigItem.new(
      key: :changelog,
      description: 'Static changelog',
      is_string: true,
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :upload_assets,
      description: 'Path to assets to be uploaded with the release',
      is_string: false,
      optional: true
    )
  ]
end

.descriptionObject



58
59
60
# File 'lib/fastlane/plugin/stream_actions/actions/publish_ios_sdk.rb', line 58

def self.description
  'Publish iOS SDKs'
end

.ensure_everything_is_set_up(params) ⇒ Object



41
42
43
44
# File 'lib/fastlane/plugin/stream_actions/actions/publish_ios_sdk.rb', line 41

def self.ensure_everything_is_set_up(params)
  other_action.ensure_git_branch(branch: 'main') unless params[:skip_branch_check]
  other_action.ensure_git_status_clean unless params[:skip_git_status_check]
end

.ensure_release_tag_is_new(version_number) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/stream_actions/actions/publish_ios_sdk.rb', line 46

def self.ensure_release_tag_is_new(version_number)
  if other_action.git_tag_exists(tag: version_number)
    UI.user_error!("Tag for version #{version_number} already exists!")
  else
    UI.success("Ignore the red warning above. Tag for version #{version_number} is alright!")
  end
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/fastlane/plugin/stream_actions/actions/publish_ios_sdk.rb', line 144

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

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fastlane/plugin/stream_actions/actions/publish_ios_sdk.rb', line 4

def self.run(params)
  skip_spm = params[:skip_spm].to_s.casecmp('true').zero?
  skip_pods = params[:skip_pods].to_s.casecmp('true').zero?
  version_number = params[:version]

  unless skip_spm
    ensure_everything_is_set_up(params)
    ensure_release_tag_is_new(version_number)

    changes =
      if params[:use_changelog]
        params[:changelog] || other_action.read_changelog(version: version_number, changelog_path: params[:changelog_path])
      else
        version_number
      end

    other_action.set_github_release(
      repository_name: params[:github_repo],
      api_token: params[:github_token],
      name: version_number,
      tag_name: version_number,
      description: changes,
      commitish: other_action.current_branch,
      upload_assets: params[:upload_assets],
      is_prerelease: version_number.downcase.include?('beta')
    )
  end

  unless skip_pods
    podspecs = params[:podspec_names]&.map { |sdk| "#{sdk}.podspec" } || []
    podspecs.each { |podspec| other_action.pod_push_safely(podspec: podspec) }
  end

  destination = skip_spm ? 'CocoaPods' : skip_pods ? 'SPM' : 'Error'
  UI.success("Github release v#{version_number} has been published to #{destination} 🚢")
end