Class: Fastlane::Actions::AliyunossAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



52
53
54
# File 'lib/fastlane/plugin/aliyunoss/actions/aliyunoss_action.rb', line 52

def self.authors
  ["yigua"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/aliyunoss/actions/aliyunoss_action.rb', line 65

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :endpoint,
      env_name: "endpoint",
      description: "",
      optional: false),
    FastlaneCore::ConfigItem.new(key: :access_key_id,
      env_name: "access_key_id",
      description: "",
      optional: false),
    FastlaneCore::ConfigItem.new(key: :access_key_secret,
      env_name: "access_key_secret",
      description: "",
      optional: false),
    FastlaneCore::ConfigItem.new(key: :bucket_name,
      env_name: "bucket_name",
      description: "",
      optional: false),
    FastlaneCore::ConfigItem.new(key: :bucket_dir_path,
      env_name: "bucket_dir_path",
      description: "Storage directory for files",
      optional: false),
    FastlaneCore::ConfigItem.new(key: :ipa,
      env_name: "ipa",
      description: "Path to your ipa",
      default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH],
      optional: true,
      verify_block: proc do |value|
        UI.user_error!("Couldn't find ipa file at path '#{value}'") unless File.exist?(value)
      end),
    FastlaneCore::ConfigItem.new(key: :archive,
      env_name: "archive",
      description: "Path to your archive",
      default_value: Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE],
      optional: true,
      verify_block: proc do |value|
        UI.user_error!("Couldn't find archive file at path '#{value}'") unless File.exist?(value)
      end),
    FastlaneCore::ConfigItem.new(key: :dsym,
      env_name: "dsym",
      description: "Path to your dsym",
      default_value: Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH],
      optional: true,
      verify_block: proc do |value|
        UI.user_error!("Couldn't find dsym file at path '#{value}'") unless File.exist?(value)
      end)
  ]
end

.descriptionObject



48
49
50
# File 'lib/fastlane/plugin/aliyunoss/actions/aliyunoss_action.rb', line 48

def self.description
  "upload package to aliyunoss"
end

.detailsObject



60
61
62
63
# File 'lib/fastlane/plugin/aliyunoss/actions/aliyunoss_action.rb', line 60

def self.details
  # Optional:
  ""
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


114
115
116
117
118
119
120
# File 'lib/fastlane/plugin/aliyunoss/actions/aliyunoss_action.rb', line 114

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  [:ios].include?(platform)
  true
end

.return_valueObject



56
57
58
# File 'lib/fastlane/plugin/aliyunoss/actions/aliyunoss_action.rb', line 56

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



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
40
41
42
43
44
45
46
# File 'lib/fastlane/plugin/aliyunoss/actions/aliyunoss_action.rb', line 8

def self.run(params)
  UI.message("The aliyunoss plugin is working!")
  
  endpoint = params[:endpoint]
  access_key_id = params[:access_key_id]
  access_key_secret = params[:access_key_secret]
  bucket_name = params[:bucket_name]
  bucket_dir_path = params[:bucket_dir_path]

  ipa = params[:ipa]
  archive = params[:archive]
  dsym = params[:dsym]

  now = Time.now.strftime("%Y%m%d/%H%M%S")

  backup_archive = "#{File.expand_path(File.dirname(ipa))}/#{File.basename(ipa, ".*")}.xcarchive.zip"
  UI.message "compress xcarchive"
  Actions.sh(%(zip -r -X -y -q "#{backup_archive}" "#{File.expand_path(archive)}"))

  client = Aliyun::OSS::Client.new(
    endpoint: endpoint,
    access_key_id: access_key_id,
    access_key_secret: access_key_secret)
  bucket = client.get_bucket(bucket_name)

  UI.message "upload ipa: #{ipa}"
  bucket.put_object("#{bucket_dir_path}/#{now}/#{File.basename(ipa)}", :file => "#{ipa}")
  UI.message "upload ipa done"

  UI.message "upload archive: #{backup_archive}"
  bucket.put_object("#{bucket_dir_path}/#{now}/#{File.basename(backup_archive)}", :file => "#{backup_archive}")
  UI.message "upload archive done"

  UI.message "upload dsym: #{dsym}"
  bucket.put_object("#{bucket_dir_path}/#{now}/#{File.basename(dsym)}", :file => "#{dsym}")
  UI.message "upload dsym done"

  UI.message("The aliyunoss plugin done")
end