fastlane-plugin-shorebird 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ce08cc5837ec5f3081731726d4c695f6dc6f32ba0758a8fbf699e0682ded09a
4
- data.tar.gz: 9cdb3863b127508f37e06c5a822a10e4a5d53de7a61119dec786e69b5afa4ad2
3
+ metadata.gz: 3598208825af69bed26dcbc75b64a7ece57ee3e1a4c885a834520e515f6123b6
4
+ data.tar.gz: dabb3fe9f66621470cae27a1ac0d64e6ca76b1c08a22920838e1e88ae924eb31
5
5
  SHA512:
6
- metadata.gz: 3ece6e4e48c54e892d5ffc1fb150f0734dc2746a32277cd27b5ab2b021c4bf47fd27eaea0b2b276c641c24a706a5d180a8e3daadc5f5c628958a49b8bc102092
7
- data.tar.gz: af71067070f017aa5e12854f89395e7da4677e8ce99a49c49030e74022cfc3ccb1cf369ee3ea63af9e39d24d18570e918180cdfb2e2911ff2ab1106a7b40e50b
6
+ metadata.gz: 44b9996afb7fa9b27d57541846dbfe723311f3557cdcc23613c1306217fd1cb3cb1fd798c3b5516a1af83a8cfa5997cae89254160d46be9fb04434900e94d5ca
7
+ data.tar.gz: 34113a2a2371db314f16c5ecdfd57c84244397d2a451fe90ac6029aa3b8747687b278ec7735731af895cf17a8f866622d5d21ebc6339e8f328406a34c2aee4d5
@@ -1,24 +1,66 @@
1
1
  require 'fastlane/action'
2
2
  require_relative '../helper/shorebird_helper'
3
+ require 'gym'
4
+ require 'plist'
5
+ require 'tempfile'
3
6
 
4
7
  module Fastlane
5
8
  module Actions
6
9
  class ShorebirdReleaseAction < Action
7
10
  def self.run(params)
8
11
  platform = params[:platform]
9
- Fastlane::Actions.sh("shorebird release #{platform} #{params[:args]}".strip)
12
+ params[:args] ||= ""
10
13
 
11
14
  if platform == "ios"
12
- # Get the most recently-created IPA file
13
- ipa_file = Dir.glob('../build/ios/ipa/*.ipa')
14
- .sort_by! { |f| File.stat(f).ctime }
15
- .reverse!
16
- .first
17
- puts("Setting IPA_OUTPUT_PATH to #{ipa_file}")
18
- lane_context[SharedValues::IPA_OUTPUT_PATH] = ipa_file
15
+ if export_options_plist_in_args?(params)
16
+ # If the user is already providing an export options plist, warn
17
+ UI.deprecated("--export-options-plist should not be passed in the args parameter. Please use the export_options parameter instead.")
18
+ else
19
+ provisioning_profile_mapping = Fastlane::Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]
20
+ export_options_plist_path = Helper::ExportOptionsPlist.generate_export_options_plist(params[:export_options], provisioning_profile_mapping)
21
+ optional_space = (params[:args].end_with?(" ") || params[:args].empty?) ? "" : " "
22
+ params[:args] = params[:args] + "#{optional_space}--export-options-plist #{export_options_plist_path}"
23
+ end
24
+ end
25
+
26
+ command = "shorebird release #{platform} #{params[:args]}".strip
27
+ Fastlane::Actions.sh(command)
28
+
29
+ if platform == "ios"
30
+ lane_context[SharedValues::IPA_OUTPUT_PATH] = most_recent_ipa_file
19
31
  end
20
32
  end
21
33
 
34
+ def self.most_recent_ipa_file
35
+ Dir.glob(ipa_path_pattern)
36
+ .sort_by! { |f| File.stat(f).mtime }
37
+ .reverse!
38
+ .first
39
+ end
40
+
41
+ # Traverses up the directory tree until it finds a pubspec.yaml file.
42
+ # If no parent directory contains a pubspec.yaml file, we assume we are
43
+ # not in a Flutter project and raise an error.
44
+ def self.project_root
45
+ current_dir = Dir.pwd
46
+ current_dir = File.expand_path('..', current_dir) until File.exist?(File.join(current_dir, 'pubspec.yaml')) || (current_dir == '/')
47
+ # If we've reached the root directory, we've failed to find a pubspec.yaml file.
48
+ if current_dir == '/'
49
+ raise "Could not find pubspec.yaml in the directory tree"
50
+ end
51
+
52
+ current_dir
53
+ end
54
+
55
+ # .ipa path relative to the project root
56
+ def self.ipa_path_pattern
57
+ File.join(project_root, 'build/ios/ipa', '*.ipa')
58
+ end
59
+
60
+ def self.export_options_plist_in_args?(params)
61
+ params[:args].include?("--export-options-plist")
62
+ end
63
+
22
64
  def self.description
23
65
  "Create a Shorebird release"
24
66
  end
@@ -45,6 +87,14 @@ module Fastlane
45
87
  optional: true,
46
88
  type: String,
47
89
  default_value: ""
90
+ ),
91
+ FastlaneCore::ConfigItem.new(
92
+ key: :export_options,
93
+ description: "Path to an export options plist or a hash with export options. Use 'xcodebuild -help' to print the full set of available options",
94
+ optional: true,
95
+ type: Hash,
96
+ skip_type_validation: true,
97
+ default_value: {}
48
98
  )
49
99
  ]
50
100
  end
@@ -0,0 +1,45 @@
1
+ module Fastlane
2
+ module Helper
3
+ class ExportOptionsPlist
4
+ # Generates an export options plist for use with Shorebird.
5
+ # In addition to handling data produced by match, it also updates the
6
+ # export options to ensure that the build number is not managed by Xcode
7
+ # and that the release method is set to app-store.
8
+ #
9
+ # @param export_options [Hash, String] The export options to use. If a hash, it will be used directly. If a string, it will be parsed as a plist file.
10
+ # @param provisioning_profile_mapping [Hash] The provisioning profile mapping from match. If provided, the provisioning profiles will be added to the export options plist.
11
+ # @return [String] The path to the generated export options plist.
12
+ def self.generate_export_options_plist(export_options, provisioning_profile_mapping = nil)
13
+ export_options_hash = {}
14
+ if export_options.kind_of?(Hash)
15
+ export_options_hash = export_options
16
+ export_options_hash[:method] ||= "app-store"
17
+ if provisioning_profile_mapping
18
+ # If match has provided provisioning profiles, put them in the export options plist
19
+ export_options_hash[:provisioningProfiles] = provisioning_profile_mapping
20
+ export_options_hash[:signingStyle] = 'manual'
21
+ end
22
+ elsif export_options.kind_of?(String)
23
+ export_options_path = File.expand_path(export_options)
24
+ unless File.exist?(export_options_path)
25
+ raise "export_options path #{export_options_path} does not exist"
26
+ end
27
+
28
+ export_options_hash = Plist.parse_xml(export_options_path)
29
+ end
30
+
31
+ # If manageAppVersionAndBuildNumber is not false, Shorebird won't
32
+ # work. If set to true (or not provided), Xcode will change the build
33
+ # number *after* the release is created, causing the app to be
34
+ # unpatchable.
35
+ export_options_hash[:manageAppVersionAndBuildNumber] = false
36
+ export_options_hash.compact!
37
+
38
+ tmp_path = Dir.mktmpdir('shorebird')
39
+ plist_path = File.join(tmp_path, "ExportOptions.plist")
40
+ File.write(plist_path, export_options_hash.to_plist)
41
+ plist_path
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Shorebird
3
- VERSION = "0.2.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-shorebird
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shorebird
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-07-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
- description:
14
12
  email: contact@shorebird.dev
15
13
  executables: []
16
14
  extensions: []
@@ -21,6 +19,7 @@ files:
21
19
  - lib/fastlane/plugin/shorebird.rb
22
20
  - lib/fastlane/plugin/shorebird/actions/shorebird_patch_action.rb
23
21
  - lib/fastlane/plugin/shorebird/actions/shorebird_release_action.rb
22
+ - lib/fastlane/plugin/shorebird/helper/export_options_plist.rb
24
23
  - lib/fastlane/plugin/shorebird/helper/shorebird_helper.rb
25
24
  - lib/fastlane/plugin/shorebird/version.rb
26
25
  homepage: https://github.com/shorebirdtech/fastlane-plugin-shorebird
@@ -28,7 +27,6 @@ licenses:
28
27
  - MIT
29
28
  metadata:
30
29
  rubygems_mfa_required: 'true'
31
- post_install_message:
32
30
  rdoc_options: []
33
31
  require_paths:
34
32
  - lib
@@ -43,8 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
41
  - !ruby/object:Gem::Version
44
42
  version: '0'
45
43
  requirements: []
46
- rubygems_version: 3.5.16
47
- signing_key:
44
+ rubygems_version: 3.6.9
48
45
  specification_version: 4
49
46
  summary: Create Shorebird releases and patches
50
47
  test_files: []