Class: Deployand::Command::Publish

Inherits:
Deployand::Command show all
Defined in:
lib/deployand/command/publish.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Publish

Returns a new instance of Publish.



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/deployand/command/publish.rb', line 32

def initialize(argv)
  @track = argv.shift_argument || argv.option('track', 'internal')
  @apk_path = argv.option('apk')
  @aab_path = argv.option('aab')
  @rollout_percentage = argv.option('rollout')
  @release_notes = argv.option('release-notes')
  @release_notes_file = argv.option('release-notes-file')
  @skip_upload_apk = argv.flag?('skip-upload-apk')
  @skip_upload_metadata = argv.flag?('skip-upload-metadata')
  @skip_upload_images = argv.flag?('skip-upload-images')
  @dry_run = argv.flag?('dry-run')
  super
end

Class Method Details

.optionsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/deployand/command/publish.rb', line 17

def self.options
  [
    ['--apk=PATH', 'Path to APK file'],
    ['--aab=PATH', 'Path to AAB file'],
    ['--track=TRACK', 'Release track (internal, alpha, beta, production)'],
    ['--rollout=PERCENTAGE', 'Staged rollout percentage (0-100)'],
    ['--release-notes=NOTES', 'Release notes for this version'],
    ['--release-notes-file=FILE', 'File containing release notes'],
    ['--skip-upload-apk', 'Skip APK/AAB upload (metadata only)'],
    ['--skip-upload-metadata', 'Skip metadata upload'],
    ['--skip-upload-images', 'Skip screenshots and images upload'],
    ['--dry-run', 'Validate without actually publishing']
  ].concat(super)
end

Instance Method Details

#runObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/deployand/command/publish.rb', line 66

def run
  print_info "Publishing to Google Play Store..."
  print_info "Track: #{@track}"
  print_info "Dry run mode" if @dry_run
  
  authenticate_google_play
  validate_app_bundle unless @skip_upload_apk
  upload_app_bundle unless @skip_upload_apk
   unless @skip_upload_metadata
  upload_images unless @skip_upload_images
  create_release
  
  if @dry_run
    print_success "Dry run completed successfully! No changes were made."
  else
    print_success "App published successfully to #{@track} track!"
    print_release_info
  end
end

#validate!Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/deployand/command/publish.rb', line 46

def validate!
  super
  
  valid_tracks = %w[internal alpha beta production]
  unless valid_tracks.include?(@track)
    help! "Invalid track '#{@track}'. Valid tracks: #{valid_tracks.join(', ')}"
  end
  
  if !@skip_upload_apk && !@apk_path && !@aab_path
    help! 'Either --apk or --aab path must be specified, or use --skip-upload-apk'
  end
  
  if @rollout_percentage
    percentage = @rollout_percentage.to_i
    if percentage < 0 || percentage > 100
      help! 'Rollout percentage must be between 0 and 100'
    end
  end
end