fastlane-plugin-sunny_project 0.1.17 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 426973fe5f7c18010e37c7b8ff92669cde5f41248810362002422880f0963fb3
4
- data.tar.gz: dc20fc4d05f9393fea6a2120196b51b286dcf11406df5d62d08ea961b25b6d97
3
+ metadata.gz: 42911dd4d19f1f6d97f8a405a4fd77297f9cbaa4bb3799f4aeea86171c7e4937
4
+ data.tar.gz: 41feddd1a00ba67e10a18330bed8561b9ebccf52c26c606b2806ef9298fc34af
5
5
  SHA512:
6
- metadata.gz: ba58a0be7e3d4aea68a5b3891832e77448d9158de7374cf1a70f46bac23424e7ded5ccba011fd1788c6e10079fe4a3091e1c1f4809dd743f57d2e95e4abb0013
7
- data.tar.gz: ab7cc77b694686df6786c30f9f4e40dc389cf9f3b7737140ee29cbccc128d219ca7d1fc55963fa94a0da7e8e1252f230558e4f77ceaec245fb0db4bf9d945a33
6
+ metadata.gz: 9f01acd98e752ed2d5a2d55574bb6e5cd6730ff83a679c9a1a476871a29781dab9be46b5fb367f790ed3f09821a1001957de22c8a02e3e6b4891ee8adb6de2cb
7
+ data.tar.gz: 9d3fa97eb577500c022baced2c03e5f5ed6be59a827d1f2303a1133f162b25f413fd846ee80a8d13f10ade62812d74ee788f0b1c8a8948b725bfb4f57f5fbe06
@@ -5,21 +5,7 @@ module Fastlane
5
5
  module Actions
6
6
  class FinalizeVersionAction < Action
7
7
  def self.run(options)
8
- version = Sunny.current_semver
9
- # If we got this far, let's commit the build number and update the git tags. If the rest of the pro
10
- # process fails, we should revert this because it will mess up our commit logs
11
- Sunny.run_action(GitCommitAction, path: %w[./pubspec.yaml ./pubspec.lock ./CHANGELOG.md],
12
- allow_nothing_to_commit: true,
13
- message: "Version bump to: #{version.major}.#{version.minor}.#{version.patch}#800#{version.build}")
14
- Sunny.run_action(AddGitTagAction,
15
- tag: "sunny/builds/v#{version.build}",
16
- force: true,
17
- sign: false,
18
- )
19
- Sunny.run_action(PushGitTagsAction, log: true)
20
- if File.exist?(Sunny.release_notes_file)
21
- File.delete(Sunny.release_notes_file)
22
- end
8
+ Sunny.finalize_version(options)
23
9
  end
24
10
 
25
11
  def self.description
@@ -40,15 +26,15 @@ module Fastlane
40
26
  end
41
27
 
42
28
  def self.available_options
43
- [
29
+ [
44
30
  FastlaneCore::ConfigItem.new(key: :tag_group,
45
31
  env_name: "SUNNY_PROJECT_TAG_GROUP",
46
32
  description: "The name of the tag group",
47
33
  optional: false,
48
34
  type: String,
49
35
  default_value: "sunny/builds"),
36
+ ]
50
37
 
51
- ]
52
38
  end
53
39
 
54
40
  def self.is_supported?(platform)
@@ -0,0 +1,155 @@
1
+ require 'fastlane/action'
2
+
3
+ # require 'ci'
4
+ require_relative '../helper/sunny_project_helper'
5
+ require 'yaml'
6
+
7
+ require_relative '../helper/plugin_options'
8
+
9
+ module Fastlane
10
+ module Actions
11
+ class LocalPackagesAction < Action
12
+ def self.run(options)
13
+ puts("Incoming: #{options.class}")
14
+
15
+ unless options
16
+ options = FastlaneCore::Configuration.create(self.available_options, {})
17
+ end
18
+ options.load_configuration_file("Sunnyfile")
19
+ options.load_configuration_file(".Sunnyfile")
20
+
21
+ params = options
22
+ params.all_keys.each do |k|
23
+ puts("#{k} => #{params[k]}")
24
+ end
25
+
26
+ plugins = params[:sunny_plugins]
27
+ plugin_folder = params[:sunny_plugin_folder]
28
+ # pubspec = YAML.load_file("pubspec.yaml")
29
+ local_mode = params[:sunny_local_mode]
30
+ is_local = "local".eql?(local_mode)
31
+ UI.command_output("Local #{local_mode} creates #{is_local}")
32
+
33
+ unless is_local
34
+ UI.user_error!("Not set to local development. Not checking out")
35
+ return
36
+ end
37
+
38
+ roots = []
39
+ Dir.chdir(plugin_folder) do
40
+ plugins.keys.each do |key|
41
+ info = plugins[key] ? plugins[key] : "#{key}"
42
+ folder = key
43
+ root_folder = nil
44
+ branch = nil
45
+ path = nil
46
+ repo = key
47
+ if info.is_a?(String)
48
+ repo = info
49
+ root_folder = key
50
+ else
51
+ path = info[:path]
52
+ branch = info[:branch] if info[:branch]
53
+ repo = info[:repo] if info[:repo]
54
+ folder = repo
55
+ root_folder = if path
56
+ repo
57
+ else
58
+ key
59
+ end
60
+ end
61
+ UI.header("#{folder}")
62
+ if roots.include?(root_folder)
63
+ UI.message "Skipping root #{root_folder} - already processed"
64
+ else
65
+ git_repo = "git@github.com:SunnyApp/#{repo}.git"
66
+
67
+ plugin_exists = Dir.exist?("./#{root_folder}")
68
+ if !plugin_exists || options[:force]
69
+ UI.important("Checking out plugin #{repo} to #{root_folder}")
70
+ Sunny.exec_cmd("clone #{key}", "git clone #{git_repo} #{root_folder}", quiet: true)
71
+ else
72
+ UI.message("Plugin already cloned: #{root_folder}")
73
+ end
74
+
75
+ roots.push(root_folder)
76
+
77
+ Dir.chdir("./#{folder}") do
78
+ if branch
79
+ UI.important("Verifying branch #{branch}")
80
+ unless Sunny.is_branch(branch)
81
+ if Sunny.is_clean
82
+ Sunny.exec_cmd("checkout branch #{branch}", "git checkout #{branch}")
83
+ else
84
+ UI.user_error!("Needs to be on branch #{branch}, but repo is not clean. You will need to manually fix this")
85
+ end
86
+ end
87
+ end
88
+
89
+ if params[:update]
90
+ begin
91
+ Sunny.run_action(GitPullAction, rebase: true)
92
+ rescue StandardError => e
93
+ UI.error("---------- Failed to update ---------------")
94
+ UI.error("There are changes to the working tree. Check ")
95
+ UI.error("the status of each repo below and make any fixes.")
96
+ UI.error("------------------------------------------------")
97
+
98
+ UI.command_output(cmd("myrepos status", "git status --porcelain", args = options))
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ end
107
+
108
+ def self.description
109
+ "Checks out local dart packages"
110
+ end
111
+
112
+ def self.authors
113
+ ["ericmartineau"]
114
+ end
115
+
116
+ def self.return_value
117
+ # If your method provides a return value, you can describe here what it does
118
+ end
119
+
120
+ def self.details
121
+ # Optional:
122
+ ""
123
+ end
124
+
125
+ def self.available_options
126
+ opts = [
127
+ FastlaneCore::ConfigItem.new(key: :update,
128
+ env_name: "SUNNY_UPDATE",
129
+ description: "Whether to update each plugin",
130
+ type: Object,
131
+ optional: true),
132
+ FastlaneCore::ConfigItem.new(key: :force,
133
+ env_name: "SUNNY_FORCE",
134
+ description: "Whether to update each plugin",
135
+ type: Object,
136
+ optional: true),
137
+ ]
138
+
139
+ Fastlane::SunnyProject::Options.available_options.each do |option|
140
+ opts.push(option)
141
+ end
142
+ opts
143
+ end
144
+
145
+ def self.is_supported?(platform)
146
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
147
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
148
+ #
149
+ # [:ios, :mac, :android].include?(platform)
150
+ true
151
+ end
152
+ end
153
+ end
154
+ end
155
+
@@ -0,0 +1,68 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/sunny_project_helper'
3
+ require 'semantic'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class PubReleaseAction < Action
8
+ def self.run(options)
9
+ unless options[:skip_dirty_check]
10
+ Sunny.run_action(EnsureGitStatusCleanAction)
11
+ end
12
+
13
+ Sunny.do_increase_version(options)
14
+ # Whatever happened with the incrementing, this is the build number we're
15
+ # going with
16
+ changes = Sunny.release_notes(options)
17
+ puts(changes)
18
+
19
+ Sunny.exec_cmd("pub publish", "pub publish -f")
20
+ Sunny.finalize_version(options)
21
+ end
22
+
23
+ def self.description
24
+ "Releases a dart package"
25
+ end
26
+
27
+ def self.authors
28
+ ["ericmartineau"]
29
+ end
30
+
31
+ def self.return_value
32
+ # If your method provides a return value, you can describe here what it does
33
+ end
34
+
35
+ def self.details
36
+ # Optional:
37
+ ""
38
+ end
39
+
40
+ def self.available_options
41
+ opts = [
42
+ FastlaneCore::ConfigItem.new(key: :skip_dirty_check,
43
+ description: "Whether to skip dirty repo check",
44
+ optional: true, type: Object),
45
+
46
+ ]
47
+ Fastlane::Actions::FinalizeVersionAction.available_options.each do |option|
48
+ opts.push(option)
49
+ end
50
+ Fastlane::Actions::IncreaseVersionAction.available_options.each do |option|
51
+ opts.push(option)
52
+ end
53
+ Fastlane::Actions::ReleaseNotesAction.available_options.each do |option|
54
+ opts.push(option)
55
+ end
56
+ opts
57
+ end
58
+
59
+ def self.is_supported?(platform)
60
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
61
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
62
+ #
63
+ # [:ios, :mac, :android].include?(platform)
64
+ true
65
+ end
66
+ end
67
+ end
68
+ end
@@ -26,20 +26,15 @@ end
26
26
  module Fastlane
27
27
  module Actions
28
28
  class PubspecDoctorAction < Action
29
- def self.run(options)
29
+ def self.run(params)
30
30
 
31
- params = FastlaneCore::Configuration.create(Fastlane::SunnyProject::Options.available_options, {})
32
- params.load_configuration_file("Sunnyfile")
33
- options.all_keys.each do |key|
34
- puts("override #{key} => #{options[key]}")
35
- params.set(key, options[key])
36
- end
37
- params.all_keys.each do |k|
38
- puts("#{k} => #{params[k]}")
31
+ unless params
32
+ params = FastlaneCore::Configuration.create(self.available_options, {})
39
33
  end
34
+ params.load_configuration_file("Sunnyfile")
35
+ params.load_configuration_file(".Sunnyfile")
40
36
 
41
37
  plugins = params[:sunny_plugins]
42
- branches = params[:sunny_plugins_branches]
43
38
  plugin_folder = params[:sunny_plugin_folder]
44
39
  pubspec = YAML.load_file("pubspec.yaml")
45
40
  local_mode = params[:sunny_local_mode]
@@ -116,7 +111,14 @@ module Fastlane
116
111
  end
117
112
 
118
113
  def self.available_options
119
- Fastlane::SunnyProject::Options.available_options
114
+ opts = [
115
+
116
+ ]
117
+
118
+ Fastlane::SunnyProject::Options.available_options.each do |option|
119
+ opts.push(option)
120
+ end
121
+ opts
120
122
  end
121
123
 
122
124
  def self.is_supported?(platform)
@@ -8,7 +8,7 @@ module Fastlane
8
8
 
9
9
  class ReleaseNotesAction < Action
10
10
  def self.run(options)
11
-
11
+ Sunny.release_notes(options)
12
12
  end
13
13
 
14
14
  def self.description
@@ -30,7 +30,7 @@ module Fastlane
30
30
 
31
31
  def self.available_options
32
32
  [
33
- FastlaneCore::ConfigItem.new(key: :changes,
33
+ FastlaneCore::ConfigItem.new(key: :changelog,
34
34
  env_name: "SUNNY_PROJECT_CHANGES",
35
35
  description: "Change log text",
36
36
  optional: true,
@@ -0,0 +1,71 @@
1
+ require_relative '../helper/sunny_project_helper'
2
+ require 'semantic'
3
+ require 'yaml'
4
+
5
+ require_relative '../helper/plugin_options'
6
+
7
+ module Fastlane
8
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
9
+ module Actions
10
+ class SunnyBuildRunnerAction < Action
11
+ def self.run(options)
12
+ Sunny.build_runner(options)
13
+ end
14
+
15
+ def self.description
16
+ "Cleans and runs flutter build_runner"
17
+ end
18
+
19
+ def self.authors
20
+ ["ericmartineau"]
21
+ end
22
+
23
+ def self.return_value
24
+ # If your method provides a return value, you can describe here what it does
25
+ end
26
+
27
+ def self.details
28
+ # Optional:
29
+ ""
30
+ end
31
+
32
+ def self.available_options
33
+ [
34
+ FastlaneCore::ConfigItem.new(key: :clean,
35
+ env_name: "SUNNY_CLEAN",
36
+ description: "Whether to clean",
37
+ optional: true, type: Object),
38
+
39
+ FastlaneCore::ConfigItem.new(key: :flutter,
40
+ env_name: "SUNNY_FLUTTER",
41
+ description: "Path to flutter sdk",
42
+ optional: true, type: String),
43
+ FastlaneCore::ConfigItem.new(key: :skip_pub,
44
+ env_name: "SUNNY_SKIP_PUB",
45
+ description: "Whether to skip pub get",
46
+ optional: true, type: Object),
47
+
48
+ FastlaneCore::ConfigItem.new(key: :skip_gen,
49
+ env_name: "SUNNY_SKIP_GEN",
50
+ description: "Whether to skip generation",
51
+ optional: true, type: Object),
52
+
53
+ FastlaneCore::ConfigItem.new(key: :verbose,
54
+ env_name: "SUNNY_VERBOSE",
55
+ description: "Verbose or not",
56
+ optional: true, type: Object),
57
+
58
+ ]
59
+ end
60
+
61
+ def self.is_supported?(platform)
62
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
63
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
64
+ #
65
+ # [:ios, :mac, :android].include?(platform)
66
+ true
67
+ end
68
+ end
69
+ end
70
+ end
71
+
@@ -0,0 +1,110 @@
1
+ require_relative '../helper/sunny_project_helper'
2
+ require 'semantic'
3
+ require 'yaml'
4
+
5
+ require_relative '../helper/plugin_options'
6
+
7
+ module Fastlane
8
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
9
+ module Actions
10
+ class SunnyBuildWebAction < Action
11
+ def self.run(options)
12
+ unless options[:skip_build_runner]
13
+ Sunny.build_runner(options)
14
+ end
15
+ flutter = Sunny.get_flutter(options[:flutter])
16
+ profile = if options[:profile]
17
+ " --profile"
18
+ else
19
+ ""
20
+ end
21
+
22
+ build_cmd = "build web#{profile} --web-renderer #{options[:renderer]}"
23
+ Sunny.exec_cmd_options("flutter #{build_cmd}", "#{flutter} #{build_cmd}", options)
24
+
25
+ if options[:deploy]
26
+ Sunny.exec_cmd_options("firebase deploy", "firebase deploy", options)
27
+ end
28
+ end
29
+
30
+ def self.description
31
+ "Builds a web project"
32
+ end
33
+
34
+ def self.authors
35
+ ["ericmartineau"]
36
+ end
37
+
38
+ def self.return_value
39
+ # If your method provides a return value, you can describe here what it does
40
+ end
41
+
42
+ def self.details
43
+ # Optional:
44
+ ""
45
+ end
46
+
47
+ def self.available_options
48
+ [
49
+ FastlaneCore::ConfigItem.new(key: :skip_build_runner,
50
+ env_name: "SUNNY_SKIP_BUILD_RUNNER",
51
+ description: "Whether to skip the build_runner phase",
52
+ optional: true, type: Object),
53
+
54
+ FastlaneCore::ConfigItem.new(key: :clean,
55
+ env_name: "SUNNY_CLEAN",
56
+ description: "Whether to clean",
57
+ optional: true, type: Object),
58
+
59
+ FastlaneCore::ConfigItem.new(key: :flutter,
60
+ env_name: "SUNNY_FLUTTER",
61
+ description: "Path to flutter sdk",
62
+ optional: true, type: String),
63
+ FastlaneCore::ConfigItem.new(key: :skip_pub,
64
+ env_name: "SUNNY_SKIP_PUB",
65
+ description: "Whether to skip pub get",
66
+ optional: true, type: Object),
67
+
68
+ FastlaneCore::ConfigItem.new(key: :skip_gen,
69
+ env_name: "SUNNY_SKIP_GEN",
70
+ description: "Whether to skip generation",
71
+ optional: true, type: Object),
72
+
73
+ FastlaneCore::ConfigItem.new(key: :renderer,
74
+ env_name: "SUNNY_RENDERER",
75
+ description: "The flutter web renderer to build with",
76
+ optional: false,
77
+ default_value: "auto", type: String),
78
+
79
+ FastlaneCore::ConfigItem.new(key: :profile,
80
+ env_name: "SUNNY_PROFILE",
81
+ description: "Whether to run in profile mode",
82
+ optional: true,
83
+ type: Object),
84
+
85
+ FastlaneCore::ConfigItem.new(key: :deploy,
86
+ env_name: "SUNNY_DEPLOY",
87
+ description: "Whether to deploy to firebase",
88
+ optional: true,
89
+ type: Object),
90
+
91
+ FastlaneCore::ConfigItem.new(key: :verbose,
92
+ env_name: "SUNNY_VERBOSE",
93
+ description: "Whether to show verbose output",
94
+ optional: true,
95
+ type: Object),
96
+
97
+ ]
98
+ end
99
+
100
+ def self.is_supported?(platform)
101
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
102
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
103
+ #
104
+ # [:ios, :mac, :android].include?(platform)
105
+ true
106
+ end
107
+ end
108
+ end
109
+ end
110
+
@@ -9,7 +9,7 @@ def resort_keys(input)
9
9
  keys = []
10
10
  input.each_key do |key|
11
11
  puts("Key #{key} #{key.class}")
12
- keys.push("#{key}")
12
+ keys.push(key.to_s)
13
13
  end
14
14
 
15
15
  keys = keys.sort
@@ -29,50 +29,76 @@ module Fastlane
29
29
  Sunny.run_action(EnsureGitStatusCleanAction)
30
30
  end
31
31
 
32
-
33
32
  sunny_file = Sunny.config(SunnyProject::Options.available_options, {})
34
- sunny_file.load_configuration_file("Sunnyfile")
33
+ sunny_file.load_configuration_file("Sunnyfile", skip_printing_values = true)
35
34
 
36
35
  app_file = CredentialsManager::AppfileConfig
37
- firebase_app_id=sunny_file[:firebase_app_id]
36
+ firebase_app_id = sunny_file[:firebase_app_id]
38
37
  unless firebase_app_id
39
38
  UI.user_error!("Missing firebase_app_id. Set this in Sunnyfile")
40
39
  end
41
40
 
42
41
  old_version = Sunny.current_semver
43
- build_number = ''
42
+ old_version_no_build = "#{old_version.major}.#{old_version.minor}.#{old_version.patch}"
43
+
44
+ new_version = ''
45
+
44
46
  ## If we're not going to build, we don't need to update
45
47
  # version numbers.
46
- if options[:build] and not options[:no_bump]
47
- if options[:release]
48
- build_number = Sunny.do_increase_version(build: true, patch: true)
48
+
49
+ if (not options[:skip_build]) && (not options[:no_bump])
50
+ if options[:patch]
51
+ new_version = Sunny.do_increase_version(type: "patch")
52
+ Sunny.update_ios_project_version(new_version)
53
+ elsif options[:minor]
54
+ new_version = Sunny.do_increase_version(type: "minor")
55
+ Sunny.update_ios_project_version(new_version)
56
+ elsif options[:build]
57
+ new_version = Sunny.do_increase_version(type: "build")
58
+ Sunny.update_ios_project_version(new_version)
49
59
  else
50
- build_number = Sunny.do_increase_version(build: true)
60
+ UI.user_error!("You must provide the type of version change. options are minor, patch, build.
61
+ You can also provide no_bump:true to keep the same build number")
51
62
  end
52
63
 
53
- unless build_number
64
+ unless new_version
54
65
  UI.user_error!("Version incrementing failed")
55
66
  return
56
67
  end
57
68
  end
58
69
 
70
+
71
+
59
72
  # Whatever happened with the incrementing, this is the build number we're
60
73
  # going with
61
- version = Sunny.current_semver
62
- UI.command_output("Build Version: #{version}")
74
+ version = new_version
75
+ version_no_build = "#{version.major}.#{version.minor}.#{version.patch}"
76
+ is_version_changed = old_version_no_build.eql?(version_no_build) != true
77
+ build_number = version.build
63
78
  changes = Sunny.release_notes(options)
64
- UI.important('--------------- CHANGELOG ------------------')
65
- UI.important(changes)
66
- UI.important('--------------------------------------------')
67
-
79
+ app_name = options[:app_name]
80
+ release_target = options[:release_target]
81
+
82
+ puts("")
83
+ build_summary = [
84
+ ["App name", (app_file.try_fetch_value(:app_identifier)).to_s],
85
+ ["Target", app_name],
86
+ ["Major version", is_version_changed ? "#{old_version_no_build} -> #{version_no_build}" : "#{version_no_build} (no change)"],
87
+ ["Build number", "#{old_version.build} -> #{build_number}"],
88
+ ["Releasing to", release_target,],
89
+ %W[Changelog #{changes}],
90
+ ]
91
+ UI.important("\n\n#{Terminal::Table.new(rows: FastlaneCore::PrintTable.transform_output(build_summary),
92
+ title: 'Build Summary')}")
93
+ puts("")
68
94
  # TRY to execute a build. if it fails, revert the version number changes
69
95
  begin
70
- if options[:build]
96
+ unless options[:skip_build]
71
97
  if options[:skip_flutter_build]
72
- UI.important "Skipping Flutter Build"
98
+ UI.important("Skipping Flutter Build")
73
99
  else
74
- UI.header "Run Flutter Build"
75
- Sunny.build_ios(build_number)
100
+ UI.header("Run Flutter Build")
101
+ Sunny.build_ios(version_no_build, build_number)
76
102
  end
77
103
  require 'match'
78
104
  build_opts = options[:build_options]
@@ -84,16 +110,16 @@ module Fastlane
84
110
 
85
111
  match_opts.load_configuration_file("Matchfile")
86
112
 
87
- UI.header "Read Appfile info"
113
+ UI.header("Read Appfile info")
88
114
  # Read the app identifier from Appfile
89
115
  app_identifier = app_file.try_fetch_value(:app_identifier)
90
- UI.command_output "App: #{app_identifier}"
116
+ UI.command_output("App: #{app_identifier}")
91
117
  unless app_identifier
92
118
  UI.user_error!("No app_identifier could be found")
93
119
  end
94
120
 
95
121
  MatchAction.run(match_opts)
96
- UI.header "Run Xcode Build"
122
+ UI.header("Run Xcode Build")
97
123
  Sunny.run_action(BuildAppAction, workspace: "ios/Runner.xcworkspace",
98
124
  scheme: "Runner",
99
125
  export_method: build_opts[1],
@@ -102,7 +128,7 @@ module Fastlane
102
128
  clean: options[:clean],
103
129
  export_options: {
104
130
  provisioningProfiles: {
105
- "#{app_identifier}" => "match #{build_opts[2]} #{app_identifier}",
131
+ app_identifier.to_s => "match #{build_opts[2]} #{app_identifier}",
106
132
  }
107
133
  },
108
134
  output_directory: "build/ios")
@@ -116,28 +142,27 @@ module Fastlane
116
142
  return
117
143
  end
118
144
 
119
- app_name = options[:app_name]
120
145
  # Commits the version number, deletes changelog file
121
- if options[:build] or options[:post_build]
146
+ if (not options[:skip_build]) || options[:post_build]
122
147
  unless options[:skip_symbols]
123
- UI.header "Upload Symbols to Crashlytics"
148
+ UI.header("Upload Symbols to Crashlytics")
124
149
  Sunny.run_action(UploadSymbolsToCrashlyticsAction, dsym_path: "./build/ios/#{app_name}.app.dSYM.zip",
125
150
  binary_path: "./ios/Pods/FirebaseCrashlytics/upload-symbols")
126
151
  end
127
152
 
128
- UI.header "Commit pubspec.yaml, Info.plist for version updates"
153
+ UI.header("Commit pubspec.yaml, Info.plist for version updates")
129
154
  # If we got this far, let's commit the build number and update the git tags. If the rest of the pro
130
155
  # process fails, we should revert this because it will mess up our commit logs
131
156
  Sunny.run_action(GitCommitAction,
132
157
  allow_nothing_to_commit: true,
133
- path: %w[./pubspec.yaml ./pubspec.lock ./Gemfile.lock ./ios/Runner/Info.plist],
134
- message: "\"Version bump to: #{version.major}.#{version.minor}.#{version.patch}#800#{version.build}\"")
135
- UI.header "Tagging repo v#{version.build}"
158
+ path: %w[./pubspec.yaml ./pubspec.lock ./ios/Podfile.lock ./Gemfile.lock ./ios/Runner/Info.plist],
159
+ message: "\"Version bump to: #{version_no_build}##{build_number}\"")
160
+ UI.header("Tagging repo v#{version.build}")
136
161
  Sunny.run_action(AddGitTagAction,
137
162
  grouping: "sunny-builds",
138
163
  prefix: "v",
139
164
  force: true,
140
- build_number: version.build
165
+ build_number: build_number
141
166
  )
142
167
  Sunny.run_action(PushGitTagsAction, force: false)
143
168
  end
@@ -145,10 +170,9 @@ module Fastlane
145
170
  unless options[:no_upload]
146
171
 
147
172
  # platform :ios do
148
- release_target = options[:release_target]
173
+
149
174
  if release_target == "firebase"
150
- UI.header "Firebase: uploading build/ios/#{app_name}.ipa"
151
- #require 'fastlane-plugin-firebase_app_distribution'
175
+ UI.header("Firebase: uploading build/ios/#{app_name}.ipa")
152
176
 
153
177
  Sunny.run_action(FirebaseAppDistributionAction,
154
178
  app: firebase_app_id,
@@ -157,7 +181,7 @@ module Fastlane
157
181
  debug: true
158
182
  )
159
183
  elsif release_target == "testflight"
160
- UI.header "Testflight: uploading build/ios/#{app_name}.ipa"
184
+ UI.header("Testflight: uploading build/ios/#{app_name}.ipa")
161
185
  Sunny.run_action(UploadToTestflightAction,
162
186
  ipa: "build/ios/#{app_name}.ipa",
163
187
  localized_build_info: {
@@ -178,7 +202,7 @@ module Fastlane
178
202
  end
179
203
 
180
204
  def self.description
181
- "Modify pubspec for local or git development"
205
+ "Perform ios or firebase release"
182
206
  end
183
207
 
184
208
  def self.authors
@@ -200,25 +224,34 @@ module Fastlane
200
224
  env_name: "SUNNY_NO_BUMP",
201
225
  description: "Whether to skip a bump",
202
226
  optional: true, type: Object),
203
- FastlaneCore::ConfigItem.new(key: :build,
204
- env_name: "SUNNY_BUILD",
205
- description: "Whether to perform a complete build",
227
+ FastlaneCore::ConfigItem.new(key: :skip_build,
228
+ env_name: "SUNNY_SKIP_BUILD",
229
+ description: "Whether to skip the building of the project",
206
230
  optional: true, type: Object),
207
231
  FastlaneCore::ConfigItem.new(key: :post_build,
208
232
  env_name: "SUNNY_POST_BUILD",
209
- description: "Whether to execute actions after building",
233
+ description: "Whether to execute actions after building. Can be used in conjunction with skip_build to avoid building the entire project, but still applying tags",
210
234
  optional: true, type: Object),
211
235
  FastlaneCore::ConfigItem.new(key: :skip_dirty_check,
212
236
  env_name: "SUNNY_SKIP_DIRTY_CHECK",
213
237
  description: "Whether to skip dirty repo check",
214
238
  optional: true, type: Object),
239
+
215
240
  FastlaneCore::ConfigItem.new(key: :clean,
216
241
  env_name: "SUNNY_CLEAN",
217
242
  description: "Whether to do a clean build",
218
243
  optional: true, type: Object),
219
- FastlaneCore::ConfigItem.new(key: :release,
220
- env_name: "SUNNY_RELEASE",
221
- description: "Whether to make a release vs patch build",
244
+ FastlaneCore::ConfigItem.new(key: :minor,
245
+ env_name: "SUNNY_MINOR",
246
+ description: "Whether to make a minor release",
247
+ optional: true, type: Object),
248
+ FastlaneCore::ConfigItem.new(key: :patch,
249
+ env_name: "SUNNY_PATCH",
250
+ description: "Whether to make a patch release",
251
+ optional: true, type: Object),
252
+ FastlaneCore::ConfigItem.new(key: :build,
253
+ env_name: "SUNNY_BUILD",
254
+ description: "Whether to increment only the build number for the release",
222
255
  optional: true, type: Object),
223
256
  FastlaneCore::ConfigItem.new(key: :changelog,
224
257
  env_name: "SUNNY_CHANGELOG",
@@ -237,7 +270,7 @@ module Fastlane
237
270
 
238
271
  FastlaneCore::ConfigItem.new(key: :release_target,
239
272
  env_name: "SUNNY_RELEASE_TARGET",
240
- description: "Where we're releasing to",
273
+ description: "Where we're releasing to, must be either fastlane or testflight",
241
274
  optional: false,
242
275
  type: String),
243
276
 
@@ -287,7 +320,7 @@ module Fastlane
287
320
 
288
321
  def visit_Psych_Nodes_Scalar(o)
289
322
  if o.value.is_a?(String)
290
- str = "#{o.value}"
323
+ str = (o.value).to_s
291
324
  if str.start_with?('^') || str.start_with?('..')
292
325
  @handler.scalar(o.value, o.anchor, o.tag, o.plain, o.quoted, 1)
293
326
  elsif str.start_with?('https://') || str.start_with?('git@')
@@ -12,38 +12,34 @@ module Fastlane
12
12
 
13
13
  def self.available_options
14
14
  [
15
- FastlaneCore::ConfigItem.new(key: :sunny_plugins,
16
- env_name: "SUNNY_PLUGINS",
17
- description: "The plugins",
18
- type: Hash,
19
- optional: true,),
20
- FastlaneCore::ConfigItem.new(key: :firebase_app_id,
21
- env_name: "SUNNY_FIREBASE_APP_ID",
22
- description: "Firebase app id",
23
- type: String,
24
- optional: true,),
25
- FastlaneCore::ConfigItem.new(key: :firebase_cli_path,
26
- env_name: "SUNNY_FIREBASE_CLI_PATH",
27
- description: "Firebase cli path",
28
- type: String,
29
- optional: true,),
30
- FastlaneCore::ConfigItem.new(key: :sunny_plugin_folder,
31
- env_name: "SUNNY_PLUGIN_FOLDER",
32
- description: "Folder that contains the packages",
33
- type: String,
34
- optional: false,
35
- default_value: '../plugin'),
36
- FastlaneCore::ConfigItem.new(key: :sunny_plugins_branches,
37
- env_name: "SUNNY_PLUGINS_BRANCHES",
38
- description: "Specific branches to use",
39
- type: Hash,
40
- optional: true,),
41
- FastlaneCore::ConfigItem.new(key: :sunny_local_mode,
42
- env_name: "SUNNY_LOCAL_MODE",
43
- description: "Whether the project uses local checked out packages",
44
- type: String,
45
- optional: true,
46
- default_value: "git"),
15
+ FastlaneCore::ConfigItem.new(key: :sunny_plugins,
16
+ env_name: "SUNNY_PLUGINS",
17
+ description: "The plugins",
18
+ type: Hash,
19
+ optional: true,),
20
+ FastlaneCore::ConfigItem.new(key: :firebase_app_id,
21
+ env_name: "SUNNY_FIREBASE_APP_ID",
22
+ description: "Firebase app id",
23
+ type: String,
24
+ optional: true,),
25
+ FastlaneCore::ConfigItem.new(key: :firebase_cli_path,
26
+ env_name: "SUNNY_FIREBASE_CLI_PATH",
27
+ description: "Firebase cli path",
28
+ type: String,
29
+ optional: true,),
30
+ FastlaneCore::ConfigItem.new(key: :sunny_plugin_folder,
31
+ env_name: "SUNNY_PLUGIN_FOLDER",
32
+ description: "Folder that contains the packages",
33
+ type: String,
34
+ optional: false,
35
+ default_value: '../plugin'),
36
+ # value should be 'git' or 'local'
37
+ FastlaneCore::ConfigItem.new(key: :sunny_local_mode,
38
+ env_name: "SUNNY_LOCAL_MODE",
39
+ description: "Whether the project uses local checked out packages",
40
+ type: String,
41
+ optional: true,
42
+ default_value: "git"),
47
43
 
48
44
  ]
49
45
  end
@@ -1,4 +1,5 @@
1
1
  require 'fastlane_core/ui/ui'
2
+ require 'fastlane/helper/sh_helper'
2
3
  require "fastlane"
3
4
 
4
5
  module Fastlane
@@ -21,6 +22,20 @@ module Fastlane
21
22
  end
22
23
  end
23
24
 
25
+ def self.is_clean
26
+ self.run_action(Fastlane::Actions::EnsureGitStatusCleanAction)
27
+ true
28
+ rescue
29
+ false
30
+ end
31
+
32
+ def self.is_branch(branch_name)
33
+ self.run_action(Fastlane::Actions::EnsureGitBranchAction, branch: branch_name)
34
+ true
35
+ rescue
36
+ false
37
+ end
38
+
24
39
  def self.config(available_options, options)
25
40
  FastlaneCore::Configuration.create(available_options, options)
26
41
  end
@@ -29,47 +44,98 @@ module Fastlane
29
44
  action.run(self.config(action.available_options, options))
30
45
  end
31
46
 
47
+ def self.mmp(semver)
48
+ "#{semver.major}.#{semver.minor}.#{semver.patch}"
49
+ end
50
+
32
51
  def self.do_increase_version(options)
33
- command = "pubver bump #{options[:type]} "
34
- if options[:type] == 'patch'
35
- command += "-b"
52
+ bump_type = options[:type]
53
+ bump_type = "build" unless bump_type
54
+ command = "pubver bump #{bump_type}"
55
+ unless bump_type.eql?('build')
56
+ command += " -b"
57
+ end
58
+ self.exec_cmd(command.to_s, command)
59
+
60
+ unless bump_type.eql?('build')
61
+ self.exec_cmd("also bump build", "pubver bump build")
36
62
  end
37
- self.exec_cmd("bump patch", command)
63
+
38
64
  self.current_semver
39
65
  end
40
66
 
67
+ def self.update_ios_project_version(new_version)
68
+ Dir.chdir("ios") {
69
+ puts("Updating XCode Project files: version:#{mmp(new_version)}, build: #{new_version.build}")
70
+ self.run_action(Fastlane::Actions::IncrementVersionNumberAction, version_number: mmp(new_version))
71
+ self.run_action(Fastlane::Actions::IncrementBuildNumberAction, build_number: new_version.build)
72
+ }
73
+ end
74
+
75
+ def self.config_to_hash(options)
76
+ hash = Hash([])
77
+ options.all_keys.each do |key|
78
+ hash.store(key, options.fetch(key, ask: false))
79
+ end
80
+ return hash
81
+ end
82
+
41
83
  def self.exec_cmd(name, *command, **args)
42
- if (command.count > 1)
43
- command = command.map { |item| Shellwords.escape item }
84
+ if command.count > 1
85
+ command = command.map { |item| Shellwords.escape(item) }
44
86
  end
45
87
  joined = command.join(" ")
46
88
  if args[:verbose]
47
89
  begin
48
- return sh(command)
90
+ return Fastlane::Actions.sh(*command, log:true, error_callback: ->(str) { UI.user_error!(">> #{name} failed << \n #{str}") })
49
91
  rescue StandardError => e
50
- UI.user_error! ">> #{name} failed << \n #{e}"
92
+ UI.user_error!(">> #{name} failed << \n #{e}")
51
93
  end
52
94
  else
53
95
  if args[:cmd_out]
54
- UI.command_output name
96
+ UI.command_output(name)
55
97
  elsif args[:quiet]
56
98
  else
57
99
  UI.command name
58
100
  end
59
101
 
60
102
  stdout, err, status = Open3.capture3(joined)
61
- UI.user_error! ">> #{name} failed << \n command: #{joined}\n error: #{err}" unless status == 0
103
+ UI.user_error!(">> #{name} failed << \n command: #{joined}\n error: #{err}") unless status == 0
62
104
  stdout
63
105
  end
64
106
  end
65
107
 
108
+ def self.exec_cmd_options(name, command, options)
109
+ return exec_cmd(name, command, **config_to_hash(options))
110
+ end
111
+
66
112
  def self.release_notes_file
67
113
  ".release-notes"
68
114
  end
69
115
 
70
116
  ### Reads the latest version from pubspec.yaml
71
117
  def self.current_semver
72
- Semantic::Version.new current_version_string
118
+ Semantic::Version.new(current_version_string)
119
+ end
120
+
121
+ def self.finalize_version(options)
122
+ version = self.current_semver
123
+ # If we got this far, let's commit the build number and update the git tags. If the rest of the pro
124
+ # process fails, we should revert this because it will mess up our commit logs
125
+ self.run_action(Fastlane::Actions::GitAddAction, path: %w[./pubspec.yaml ./pubspec.lock ./CHANGELOG.md])
126
+ self.run_action(Fastlane::Actions::GitCommitAction, path: %w[./pubspec.yaml ./pubspec.lock ./CHANGELOG.md],
127
+ allow_nothing_to_commit: false,
128
+
129
+ message: "Version bump to: #{version.major}.#{version.minor}.#{version.patch}#800#{version.build}")
130
+ self.run_action(Fastlane::Actions::AddGitTagAction,
131
+ tag: "sunny/builds/v#{version.build}",
132
+ force: true,
133
+ sign: false,
134
+ )
135
+ self.run_action(Fastlane::Actions::PushGitTagsAction, force: true)
136
+ if File.exist?(self.release_notes_file)
137
+ File.delete(self.release_notes_file)
138
+ end
73
139
  end
74
140
 
75
141
  def self.release_notes(options)
@@ -113,7 +179,7 @@ module Fastlane
113
179
  lines = ["## [#{v}]\n", " * #{changes}\n", "\n"] + lines
114
180
 
115
181
  output = File.new("CHANGELOG.md", "w")
116
- lines.each { |line| output.write line }
182
+ lines.each { |line| output.write(line) }
117
183
  output.close
118
184
  end
119
185
  changes
@@ -123,10 +189,36 @@ module Fastlane
123
189
  provided || ".fvm/flutter_sdk/bin/flutter"
124
190
  end
125
191
 
192
+ def self.build_runner(options)
193
+ flutter = get_flutter(options[:flutter])
194
+ opt_hash = config_to_hash(options)
195
+ if options[:clean]
196
+ exec_cmd("flutter clean", "#{flutter} clean", **opt_hash)
197
+ end
198
+
199
+ if options[:clean] || (!options[:skip_pub])
200
+ exec_cmd("flutter pub get", "#{flutter} pub get", **opt_hash)
201
+ end
202
+
203
+ if options[:clean] || (!options[:skip_gen])
204
+ dc = if options[:clean]
205
+ " --delete-conflicting-outputs"
206
+ else
207
+ ""
208
+ end
209
+ vb = if options[:verbose]
210
+ " -v"
211
+ else
212
+ ""
213
+ end
214
+ exec_cmd("flutter pub run build_runner build#{dc}#{vb}", "#{flutter} pub run build_runner build#{dc}#{vb}", **opt_hash)
215
+ end
216
+ end
217
+
126
218
  def self.override_version(**options)
127
219
  semver = options[:version]
128
220
  unless semver
129
- UI.user_error! "No version parameter found"
221
+ UI.user_error!("No version parameter found")
130
222
  return
131
223
  end
132
224
  self.exec_cmd("set_version", "pubver set #{semver}", quiet: true)
@@ -138,16 +230,17 @@ module Fastlane
138
230
  self.run_action(Fastlane::Actions::IncrementVersionNumberAction,
139
231
  version_number: "#{version.major}.#{version.minor}.#{version.patch}",
140
232
  xcodeproj: "ios/Runner.xcodeproj"
141
- )
233
+ )
142
234
  else
143
- UI.user_error! "No version found"
235
+ UI.user_error!("No version found")
144
236
  end
145
237
 
146
238
  end
147
239
 
148
- def self.build_ios(build_num, **options)
240
+ def self.build_ios(build_ver, build_num, **options)
149
241
  flutter = get_flutter(options[:flutter])
150
- self.exec_cmd("build flutter ios release #{build_num}", "#{flutter} build ios --release --no-tree-shake-icons --no-codesign --build-number=#{build_num}")
242
+
243
+ self.exec_cmd("build flutter ios release #{build_ver} #{build_num}", "#{flutter} build ios --release --no-tree-shake-icons --no-codesign")
151
244
  end
152
245
 
153
246
  ### Reads the latest version from pubspec.yaml
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module SunnyProject
3
- VERSION = "0.1.17"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-sunny_project
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ericmartineau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-05 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -150,10 +150,14 @@ files:
150
150
  - lib/fastlane/plugin/sunny_project/actions/finalize_version_action.rb
151
151
  - lib/fastlane/plugin/sunny_project/actions/generate_icons_action.rb
152
152
  - lib/fastlane/plugin/sunny_project/actions/increase_version_action.rb
153
+ - lib/fastlane/plugin/sunny_project/actions/local_packages_action.rb
153
154
  - lib/fastlane/plugin/sunny_project/actions/pub_publish_action.rb
155
+ - lib/fastlane/plugin/sunny_project/actions/pub_release_action.rb
154
156
  - lib/fastlane/plugin/sunny_project/actions/pubspec_doctor_action.rb
155
157
  - lib/fastlane/plugin/sunny_project/actions/release_notes_action.rb
156
158
  - lib/fastlane/plugin/sunny_project/actions/rename_assets_action.rb
159
+ - lib/fastlane/plugin/sunny_project/actions/sunny_build_runner.rb
160
+ - lib/fastlane/plugin/sunny_project/actions/sunny_build_web.rb
157
161
  - lib/fastlane/plugin/sunny_project/actions/sunny_release_action.rb
158
162
  - lib/fastlane/plugin/sunny_project/helper/plugin_options.rb
159
163
  - lib/fastlane/plugin/sunny_project/helper/sunny_project_helper.rb