Class: Origen::Application::Release

Inherits:
Object
  • Object
show all
Includes:
Users, Utility, Utility::InputCapture, Utility::TimeAndDate
Defined in:
lib/origen/application/release.rb

Overview

Responsible for co-ordinating application releases

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utility

collector, read_hex, #which

Methods included from Utility::InputCapture

#find_space, #get_text, #split_long_line

Methods included from Utility::TimeAndDate

#time_now

Methods included from Users

#admins, #app_users, #current_user

Constructor Details

#initializeRelease

Returns a new instance of Release.



11
12
13
# File 'lib/origen/application/release.rb', line 11

def initialize
  @mailer = Utility::Mailer.new
end

Class Method Details

.valid_typesObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/origen/application/release.rb', line 15

def self.valid_types
  if Origen.config.semantically_version
    if Origen.app.version.development?
      [:development, :production]
    else
      [:development, :tiny, :minor, :major]
    end
  else
    [:development, :production]
  end
end

Instance Method Details

#run(options) ⇒ Object

Release a new application version



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
# File 'lib/origen/application/release.rb', line 28

def run(options)
  # Don't want plugin callbacks kicking in during the release process
  Origen.app.plugins.disable_current
  @options = options
  if authorized?
    Origen.app.plugins.validate_production_status(true)
    fail 'No revision control configured for this application, cannot release a new version' if Origen.app.rc.nil?

    unless Origen.app.rc.local_modifications.empty?
      puts <<-EOT
Your workspace has local modifications that are preventing the requested action
  - run 'origen rc mods' to see them.
      EOT
      exit 1
    end
    get_release_type unless type
    validate_branch
    # For development tags always include the latest updates from everyone else,
    # for production tag exactly what is in the user's workspace
    if type == :development && !options[:no_fetch]
      puts 'Fetching the latest version of all application files...'
      Origen.app.rc.checkout(force: true)
    end
    Origen.app.listeners_for(:validate_release).each(&:validate_release)
    lint_test
    get_latest_version_files
    base_version = Origen.app.version(refresh: true) # Read in the latest version
    get_release_note unless note
    new_version = get_or_confirm_version(type) # Don't mask this like the above!
    write_version(new_version)
    # Refresh the version in the current thread
    Origen.app.version(refresh: true)
    if Origen.app.version != new_version
      fail "Sorry something has gone wrong trying to update the version counter to #{new_version}!"
    end

    Origen.app.version_tracker.add_version(Origen.app.version) if Origen.app.version.production?
    write_history
    Origen.app.listeners_for(:before_release_tag).each do |listener|
      listener.before_release_tag(tag, note, type, selector, options)
    end
    puts "Tagging workspace, this could take a few minutes, don't interrupt..."
    Origen.app.rc.checkin("#{version_file} #{history_file} #{File.join(Origen.root, 'Gemfile.lock')}", force: true, comment: 'Updated app version and history')
    workspace_dirs.each do |wdir|
      Origen.app.rc.tag tag
    end
    begin
      Origen.client.release!
    rescue
      # Don't allow any server post errors to kill the release process
    end
    release_gem
    Origen.app.listeners_for(:after_release_tag).each do |listener|
      listener.after_release_tag(tag, note, type, selector, options)
    end
    @mailer.send_release_notice(tag, note, type, selector) unless options[:silent]
    Origen.app.listeners_for(:after_release_email).each do |listener|
      listener.after_release_email(tag, note, type, selector, options)
    end
    puts "Successfully released version #{Origen.app.version}!"
  end
end