Class: Fastlane::Actions::MergeReleaseToMainAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.available_optionsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fastlane/plugin/stream_actions/actions/merge_release_to_main.rb', line 45

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      env_name: 'USER_LOGIN',
      key: :author,
      description: 'Github user name',
      optional: true
    ),
    FastlaneCore::ConfigItem.new(
      key: :github_team_name,
      description: 'Github team name',
      default_value: 'ios-developers'
    )
  ]
end

.descriptionObject



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

def self.description
  'Merge release branch to main'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/fastlane/plugin/stream_actions/actions/merge_release_to_main.rb', line 61

def self.is_supported?(platform)
  true
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
# File 'lib/fastlane/plugin/stream_actions/actions/merge_release_to_main.rb', line 4

def self.run(params)
  other_action.ensure_git_status_clean

  release_branch =
    if other_action.is_ci
      # This API operation needs the "admin:org" scope.
      ios_team = `gh api orgs/GetStream/teams/#{params[:github_team_name]}/members -q '.[].login'`.split("\n")
      UI.user_error!("#{params[:author]} is not a member of the iOS Team") unless ios_team.include?(params[:author])

      other_action.current_branch
    else
      release_branches = sh(command: 'git branch -a').delete(' ').split("\n").grep(%r(origin/.*release/))
      UI.user_error!("Expected 1 release branch, found #{release_branches.size}") if release_branches.size != 1

      release_branches.first
    end

  UI.user_error!("`#{release_branch}`` branch does not match the release branch pattern: `release/*`") unless release_branch.start_with?('release/')

  sh('git config pull.ff only')
  sh('git fetch --all --tags --prune')
  sh("git checkout #{release_branch}")
  sh("git pull origin #{release_branch} --ff-only")
  sh('git checkout main')
  sh('git pull origin main --ff-only')
  sh("git merge #{release_branch} --ff-only")
  sh('git push origin main')

  comment = "Publication of the release has been launched 👍"
  UI.important(comment)
  other_action.pr_comment(text: comment)
end