class Fastlane::Actions::CreateChangelogAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/create_changelog.rb, line 82
def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ["cball"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/create_changelog.rb, line 60
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :title,
                                 env_name: "FL_CREATE_CHANGELOG_TITLE",
                                 description: "What title should we use for the CHANGELOG?",
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :commit_message,
                                 env_name: "FL_CREATE_CHANGELOG_COMMIT_MESSAGE",
                                 description: "What should the commit message be?",
                                 type: String,
                                 default_value: "chore(changelog): Update CHANGELOG [skip ci]")
  ]
end
description() click to toggle source

@!group documentation

# File lib/fastlane/plugin/react_native_release/actions/create_changelog.rb, line 52
def self.description
  "Determines if a release should happen based on conventional commits."
end
details() click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/create_changelog.rb, line 56
def self.details
  "If using conventional commits, only continues to release if there are features / fixes."
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/create_changelog.rb, line 87
def self.is_supported?(platform)
  [:ios, :android].include?(platform)
end
return_value() click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/create_changelog.rb, line 74
def self.return_value
  # If your method provides a return value, you can describe here what it does
end
run(params) click to toggle source
# File lib/fastlane/plugin/react_native_release/actions/create_changelog.rb, line 6
def self.run(params)
  title = params[:title]
  commit_message = params[:commit_message]
  # Determine our local branch name, set the upstream, and pull.
  # We need to pull since another build may have already finished and created a changelog
  local_branch ||= other_action.git_branch.gsub(/origin/, '')
  sh("git branch --set-upstream-to=origin/#{local_branch} #{local_branch}")
  other_action.git_pull 

  # Get release notes since last version
  # This exports a slack and a regular markdown format
  notes = other_action.conventional_changelog(title: title, format: 'slack')
  notesMD = other_action.conventional_changelog(title: title, format: 'markdown')

  # Prepend new Changelog to existing one
  UI.message("pre-pending to CHANGELOG")
  UI.message(notes)
  new_file = '../CHANGELOG.md.new'
  original_file = '../CHANGELOG.md'

  open(new_file, 'w') do |nf|
    notesMD.split("\n").each { |line| nf.puts line }
    nf.puts "\n"
    
    File.foreach(original_file) do |li|
      nf.puts li
    end
  end

  File.delete original_file
  File.rename new_file, original_file

  # Commit it
  other_action.git_commit(
    path: [File.join(Dir.pwd, original_file)],
    message: commit_message,
    skip_git_hooks: true
  )

  { plain: notes, markdown: notesMD }
end