pantograph 0.1.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.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +1 -0
  3. data/LICENSE +21 -0
  4. data/README.md +197 -0
  5. data/bin/bin-proxy +19 -0
  6. data/bin/pantograph +23 -0
  7. data/pantograph/README.md +11 -0
  8. data/pantograph/lib/assets/ActionDetails.md.erb +106 -0
  9. data/pantograph/lib/assets/Actions.md.erb +43 -0
  10. data/pantograph/lib/assets/DefaultPantfileTemplate +20 -0
  11. data/pantograph/lib/assets/completions/completion.bash +23 -0
  12. data/pantograph/lib/assets/completions/completion.fish +39 -0
  13. data/pantograph/lib/assets/completions/completion.sh +12 -0
  14. data/pantograph/lib/assets/completions/completion.zsh +23 -0
  15. data/pantograph/lib/assets/custom_action_template.rb +80 -0
  16. data/pantograph/lib/assets/report_template.xml.erb +15 -0
  17. data/pantograph/lib/pantograph/action.rb +194 -0
  18. data/pantograph/lib/pantograph/action_collector.rb +35 -0
  19. data/pantograph/lib/pantograph/actions/README.md +3 -0
  20. data/pantograph/lib/pantograph/actions/actions_helper.rb +166 -0
  21. data/pantograph/lib/pantograph/actions/add_extra_platforms.rb +45 -0
  22. data/pantograph/lib/pantograph/actions/artifactory.rb +157 -0
  23. data/pantograph/lib/pantograph/actions/bundle_install.rb +156 -0
  24. data/pantograph/lib/pantograph/actions/changelog_from_git_commits.rb +197 -0
  25. data/pantograph/lib/pantograph/actions/clipboard.rb +52 -0
  26. data/pantograph/lib/pantograph/actions/cloc.rb +89 -0
  27. data/pantograph/lib/pantograph/actions/create_pull_request.rb +190 -0
  28. data/pantograph/lib/pantograph/actions/danger.rb +131 -0
  29. data/pantograph/lib/pantograph/actions/debug.rb +32 -0
  30. data/pantograph/lib/pantograph/actions/default_platform.rb +47 -0
  31. data/pantograph/lib/pantograph/actions/download.rb +76 -0
  32. data/pantograph/lib/pantograph/actions/echo.rb +14 -0
  33. data/pantograph/lib/pantograph/actions/ensure_bundle_exec.rb +59 -0
  34. data/pantograph/lib/pantograph/actions/ensure_env_vars.rb +58 -0
  35. data/pantograph/lib/pantograph/actions/ensure_git_branch.rb +69 -0
  36. data/pantograph/lib/pantograph/actions/ensure_git_status_clean.rb +81 -0
  37. data/pantograph/lib/pantograph/actions/erb.rb +88 -0
  38. data/pantograph/lib/pantograph/actions/get_build_number_repository.rb +120 -0
  39. data/pantograph/lib/pantograph/actions/get_github_release.rb +163 -0
  40. data/pantograph/lib/pantograph/actions/git_add.rb +93 -0
  41. data/pantograph/lib/pantograph/actions/git_branch.rb +58 -0
  42. data/pantograph/lib/pantograph/actions/git_commit.rb +80 -0
  43. data/pantograph/lib/pantograph/actions/git_pull.rb +53 -0
  44. data/pantograph/lib/pantograph/actions/git_submodule_update.rb +52 -0
  45. data/pantograph/lib/pantograph/actions/git_tag_exists.rb +74 -0
  46. data/pantograph/lib/pantograph/actions/github_api.rb +262 -0
  47. data/pantograph/lib/pantograph/actions/gradle.rb +278 -0
  48. data/pantograph/lib/pantograph/actions/import.rb +49 -0
  49. data/pantograph/lib/pantograph/actions/import_from_git.rb +71 -0
  50. data/pantograph/lib/pantograph/actions/is_ci.rb +51 -0
  51. data/pantograph/lib/pantograph/actions/jira.rb +115 -0
  52. data/pantograph/lib/pantograph/actions/lane_context.rb +60 -0
  53. data/pantograph/lib/pantograph/actions/last_git_commit.rb +58 -0
  54. data/pantograph/lib/pantograph/actions/last_git_tag.rb +51 -0
  55. data/pantograph/lib/pantograph/actions/make_changelog_from_jenkins.rb +81 -0
  56. data/pantograph/lib/pantograph/actions/min_pantograph_version.rb +57 -0
  57. data/pantograph/lib/pantograph/actions/nexus_upload.rb +230 -0
  58. data/pantograph/lib/pantograph/actions/notification.rb +75 -0
  59. data/pantograph/lib/pantograph/actions/number_of_commits.rb +75 -0
  60. data/pantograph/lib/pantograph/actions/opt_out_usage.rb +40 -0
  61. data/pantograph/lib/pantograph/actions/pantograph_version.rb +15 -0
  62. data/pantograph/lib/pantograph/actions/println.rb +14 -0
  63. data/pantograph/lib/pantograph/actions/prompt.rb +119 -0
  64. data/pantograph/lib/pantograph/actions/push_git_tags.rb +76 -0
  65. data/pantograph/lib/pantograph/actions/push_to_git_remote.rb +127 -0
  66. data/pantograph/lib/pantograph/actions/puts.rb +68 -0
  67. data/pantograph/lib/pantograph/actions/reset_git_repo.rb +121 -0
  68. data/pantograph/lib/pantograph/actions/rocket.rb +83 -0
  69. data/pantograph/lib/pantograph/actions/rsync.rb +74 -0
  70. data/pantograph/lib/pantograph/actions/ruby_version.rb +56 -0
  71. data/pantograph/lib/pantograph/actions/say.rb +56 -0
  72. data/pantograph/lib/pantograph/actions/scp.rb +114 -0
  73. data/pantograph/lib/pantograph/actions/set_github_release.rb +274 -0
  74. data/pantograph/lib/pantograph/actions/sh.rb +71 -0
  75. data/pantograph/lib/pantograph/actions/skip_docs.rb +52 -0
  76. data/pantograph/lib/pantograph/actions/slack.rb +288 -0
  77. data/pantograph/lib/pantograph/actions/sonar.rb +156 -0
  78. data/pantograph/lib/pantograph/actions/ssh.rb +162 -0
  79. data/pantograph/lib/pantograph/actions/twitter.rb +89 -0
  80. data/pantograph/lib/pantograph/actions/update_pantograph.rb +177 -0
  81. data/pantograph/lib/pantograph/actions/zip.rb +120 -0
  82. data/pantograph/lib/pantograph/auto_complete.rb +82 -0
  83. data/pantograph/lib/pantograph/boolean.rb +5 -0
  84. data/pantograph/lib/pantograph/cli_tools_distributor.rb +183 -0
  85. data/pantograph/lib/pantograph/command_line_handler.rb +43 -0
  86. data/pantograph/lib/pantograph/commands_generator.rb +344 -0
  87. data/pantograph/lib/pantograph/configuration_helper.rb +26 -0
  88. data/pantograph/lib/pantograph/core_ext/bundler_monkey_patch.rb +14 -0
  89. data/pantograph/lib/pantograph/documentation/actions_list.rb +214 -0
  90. data/pantograph/lib/pantograph/documentation/docs_generator.rb +95 -0
  91. data/pantograph/lib/pantograph/documentation/markdown_docs_generator.rb +221 -0
  92. data/pantograph/lib/pantograph/environment_printer.rb +282 -0
  93. data/pantograph/lib/pantograph/erb_template_helper.rb +30 -0
  94. data/pantograph/lib/pantograph/features.rb +4 -0
  95. data/pantograph/lib/pantograph/helper/README.md +29 -0
  96. data/pantograph/lib/pantograph/helper/dotenv_helper.rb +50 -0
  97. data/pantograph/lib/pantograph/helper/gem_helper.rb +26 -0
  98. data/pantograph/lib/pantograph/helper/git_helper.rb +135 -0
  99. data/pantograph/lib/pantograph/helper/gradle_helper.rb +62 -0
  100. data/pantograph/lib/pantograph/helper/sh_helper.rb +134 -0
  101. data/pantograph/lib/pantograph/junit_generator.rb +27 -0
  102. data/pantograph/lib/pantograph/lane.rb +97 -0
  103. data/pantograph/lib/pantograph/lane_list.rb +77 -0
  104. data/pantograph/lib/pantograph/lane_manager.rb +140 -0
  105. data/pantograph/lib/pantograph/lane_manager_base.rb +92 -0
  106. data/pantograph/lib/pantograph/markdown_table_formatter.rb +62 -0
  107. data/pantograph/lib/pantograph/new_action.rb +47 -0
  108. data/pantograph/lib/pantograph/one_off.rb +45 -0
  109. data/pantograph/lib/pantograph/other_action.rb +29 -0
  110. data/pantograph/lib/pantograph/pant_file.rb +377 -0
  111. data/pantograph/lib/pantograph/pantograph_require.rb +75 -0
  112. data/pantograph/lib/pantograph/plugins/plugin_fetcher.rb +55 -0
  113. data/pantograph/lib/pantograph/plugins/plugin_generator.rb +86 -0
  114. data/pantograph/lib/pantograph/plugins/plugin_generator_ui.rb +19 -0
  115. data/pantograph/lib/pantograph/plugins/plugin_info.rb +49 -0
  116. data/pantograph/lib/pantograph/plugins/plugin_info_collector.rb +159 -0
  117. data/pantograph/lib/pantograph/plugins/plugin_manager.rb +387 -0
  118. data/pantograph/lib/pantograph/plugins/plugin_search.rb +46 -0
  119. data/pantograph/lib/pantograph/plugins/plugin_update_manager.rb +70 -0
  120. data/pantograph/lib/pantograph/plugins/plugins.rb +12 -0
  121. data/pantograph/lib/pantograph/plugins/template/%gem_name%.gemspec.erb +35 -0
  122. data/pantograph/lib/pantograph/plugins/template/.circleci/config.yml +43 -0
  123. data/pantograph/lib/pantograph/plugins/template/.gitignore +12 -0
  124. data/pantograph/lib/pantograph/plugins/template/.rspec +5 -0
  125. data/pantograph/lib/pantograph/plugins/template/.rubocop.yml +179 -0
  126. data/pantograph/lib/pantograph/plugins/template/.travis.yml +4 -0
  127. data/pantograph/lib/pantograph/plugins/template/Gemfile +6 -0
  128. data/pantograph/lib/pantograph/plugins/template/LICENSE.erb +21 -0
  129. data/pantograph/lib/pantograph/plugins/template/README.md.erb +52 -0
  130. data/pantograph/lib/pantograph/plugins/template/Rakefile +9 -0
  131. data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/actions/%plugin_name%_action.rb.erb +47 -0
  132. data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/helper/%plugin_name%_helper.rb.erb +16 -0
  133. data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/version.rb.erb +5 -0
  134. data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%.rb.erb +16 -0
  135. data/pantograph/lib/pantograph/plugins/template/pantograph/Pantfile.erb +3 -0
  136. data/pantograph/lib/pantograph/plugins/template/pantograph/Pluginfile.erb +1 -0
  137. data/pantograph/lib/pantograph/plugins/template/spec/%plugin_name%_action_spec.rb.erb +9 -0
  138. data/pantograph/lib/pantograph/plugins/template/spec/spec_helper.rb.erb +15 -0
  139. data/pantograph/lib/pantograph/runner.rb +371 -0
  140. data/pantograph/lib/pantograph/server/action_command.rb +61 -0
  141. data/pantograph/lib/pantograph/server/action_command_return.rb +14 -0
  142. data/pantograph/lib/pantograph/server/command_executor.rb +7 -0
  143. data/pantograph/lib/pantograph/server/command_parser.rb +36 -0
  144. data/pantograph/lib/pantograph/server/control_command.rb +23 -0
  145. data/pantograph/lib/pantograph/server/json_return_value_processor.rb +72 -0
  146. data/pantograph/lib/pantograph/server/socket_server.rb +232 -0
  147. data/pantograph/lib/pantograph/server/socket_server_action_command_executor.rb +101 -0
  148. data/pantograph/lib/pantograph/setup/setup.rb +290 -0
  149. data/pantograph/lib/pantograph/setup/setup_android.rb +64 -0
  150. data/pantograph/lib/pantograph/setup/setup_ios.rb +412 -0
  151. data/pantograph/lib/pantograph/shells.rb +6 -0
  152. data/pantograph/lib/pantograph/supported_platforms.rb +28 -0
  153. data/pantograph/lib/pantograph/tools.rb +10 -0
  154. data/pantograph/lib/pantograph/version.rb +5 -0
  155. data/pantograph/lib/pantograph.rb +51 -0
  156. data/pantograph_core/README.md +79 -0
  157. data/pantograph_core/lib/assets/XMLTemplate.xml.erb +12 -0
  158. data/pantograph_core/lib/pantograph_core/analytics/action_completion_context.rb +34 -0
  159. data/pantograph_core/lib/pantograph_core/analytics/action_launch_context.rb +38 -0
  160. data/pantograph_core/lib/pantograph_core/analytics/analytics_event_builder.rb +23 -0
  161. data/pantograph_core/lib/pantograph_core/analytics/analytics_ingester_client.rb +54 -0
  162. data/pantograph_core/lib/pantograph_core/analytics/analytics_session.rb +71 -0
  163. data/pantograph_core/lib/pantograph_core/cert_checker.rb +116 -0
  164. data/pantograph_core/lib/pantograph_core/command_executor.rb +99 -0
  165. data/pantograph_core/lib/pantograph_core/configuration/commander_generator.rb +103 -0
  166. data/pantograph_core/lib/pantograph_core/configuration/config_item.rb +314 -0
  167. data/pantograph_core/lib/pantograph_core/configuration/configuration.rb +332 -0
  168. data/pantograph_core/lib/pantograph_core/configuration/configuration_file.rb +182 -0
  169. data/pantograph_core/lib/pantograph_core/core_ext/shellwords.rb +63 -0
  170. data/pantograph_core/lib/pantograph_core/core_ext/string.rb +17 -0
  171. data/pantograph_core/lib/pantograph_core/env.rb +9 -0
  172. data/pantograph_core/lib/pantograph_core/feature/feature.rb +51 -0
  173. data/pantograph_core/lib/pantograph_core/features.rb +4 -0
  174. data/pantograph_core/lib/pantograph_core/globals.rb +27 -0
  175. data/pantograph_core/lib/pantograph_core/helper.rb +409 -0
  176. data/pantograph_core/lib/pantograph_core/keychain_importer.rb +74 -0
  177. data/pantograph_core/lib/pantograph_core/languages.rb +14 -0
  178. data/pantograph_core/lib/pantograph_core/module.rb +29 -0
  179. data/pantograph_core/lib/pantograph_core/pantograph_folder.rb +39 -0
  180. data/pantograph_core/lib/pantograph_core/pantograph_pty.rb +57 -0
  181. data/pantograph_core/lib/pantograph_core/pkg_file_analyser.rb +44 -0
  182. data/pantograph_core/lib/pantograph_core/print_table.rb +131 -0
  183. data/pantograph_core/lib/pantograph_core/string_filters.rb +51 -0
  184. data/pantograph_core/lib/pantograph_core/swag.rb +85 -0
  185. data/pantograph_core/lib/pantograph_core/tag_version.rb +31 -0
  186. data/pantograph_core/lib/pantograph_core/test_parser.rb +107 -0
  187. data/pantograph_core/lib/pantograph_core/ui/disable_colors.rb +17 -0
  188. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_common_error.rb +19 -0
  189. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_crash.rb +11 -0
  190. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_error.rb +25 -0
  191. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_exception.rb +19 -0
  192. data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_shell_error.rb +11 -0
  193. data/pantograph_core/lib/pantograph_core/ui/errors.rb +1 -0
  194. data/pantograph_core/lib/pantograph_core/ui/github_issue_inspector_reporter.rb +62 -0
  195. data/pantograph_core/lib/pantograph_core/ui/implementations/shell.rb +159 -0
  196. data/pantograph_core/lib/pantograph_core/ui/interface.rb +205 -0
  197. data/pantograph_core/lib/pantograph_core/ui/pantograph_runner.rb +276 -0
  198. data/pantograph_core/lib/pantograph_core/ui/ui.rb +26 -0
  199. data/pantograph_core/lib/pantograph_core/update_checker/changelog.rb +37 -0
  200. data/pantograph_core/lib/pantograph_core/update_checker/update_checker.rb +107 -0
  201. data/pantograph_core/lib/pantograph_core.rb +45 -0
  202. metadata +987 -0
@@ -0,0 +1,56 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ end
5
+
6
+ class RubyVersionAction < Action
7
+ def self.run(params)
8
+ params = nil unless params.kind_of?(Array)
9
+ value = (params || []).first
10
+ defined_version = Gem::Version.new(value) if value
11
+
12
+ UI.user_error!("Please pass minimum ruby version as parameter to ruby_version") unless defined_version
13
+
14
+ if Gem::Version.new(RUBY_VERSION) < defined_version
15
+ error_message = "The Pantfile requires a ruby version of >= #{defined_version}. You are on #{RUBY_VERSION}."
16
+ UI.user_error!(error_message)
17
+ end
18
+
19
+ UI.message("Your ruby version #{RUBY_VERSION} matches the minimum requirement of #{defined_version} ✅")
20
+ end
21
+
22
+ def self.step_text
23
+ "Verifying Ruby version"
24
+ end
25
+
26
+ def self.author
27
+ "sebastianvarela"
28
+ end
29
+
30
+ def self.description
31
+ "Verifies the minimum ruby version required"
32
+ end
33
+
34
+ def self.example_code
35
+ [
36
+ 'ruby_version("2.4.0")'
37
+ ]
38
+ end
39
+
40
+ def self.details
41
+ [
42
+ "Add this to your `Pantfile` to require a certain version of _ruby_.",
43
+ "Put it at the top of your `Pantfile to ensure that _pantograph_ is executed appropriately."
44
+ ].join("\n")
45
+ end
46
+
47
+ def self.category
48
+ :misc
49
+ end
50
+
51
+ def self.is_supported?(platform)
52
+ true
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ module Pantograph
2
+ module Actions
3
+ class SayAction < Action
4
+ def self.run(params)
5
+ text = params[:text]
6
+ text = text.join(' ') if text.kind_of?(Array)
7
+ text = text.tr("'", '"')
8
+
9
+ if params[:mute]
10
+ UI.message(text)
11
+ return text
12
+ else
13
+ Actions.sh("say '#{text}'")
14
+ end
15
+ end
16
+
17
+ def self.description
18
+ "This action speaks the given text out loud"
19
+ end
20
+
21
+ def self.available_options
22
+ [
23
+ PantographCore::ConfigItem.new(key: :text,
24
+ description: 'Text to be spoken out loud (as string or array of strings)',
25
+ optional: false,
26
+ is_string: false),
27
+ PantographCore::ConfigItem.new(key: :mute,
28
+ env_name: "SAY_MUTE",
29
+ description: 'If say should be muted with text printed out',
30
+ optional: false,
31
+ is_string: false,
32
+ type: Boolean,
33
+ default_value: false)
34
+ ]
35
+ end
36
+
37
+ def self.is_supported?(platform)
38
+ true
39
+ end
40
+
41
+ def self.author
42
+ "KrauseFx"
43
+ end
44
+
45
+ def self.example_code
46
+ [
47
+ 'say("I can speak")'
48
+ ]
49
+ end
50
+
51
+ def self.category
52
+ :misc
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,114 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ end
5
+
6
+ class ScpAction < Action
7
+ def self.run(params)
8
+ Actions.verify_gem!('net-scp')
9
+ require "net/scp"
10
+ ret = nil
11
+ Net::SCP.start(params[:host], params[:username], { port: params[:port].to_i, password: params[:password] }) do |scp|
12
+ if params[:upload]
13
+ scp.upload!(params[:upload][:src], params[:upload][:dst], recursive: true)
14
+ UI.message(['[SCP COMMAND]', "Successfully Uploaded", params[:upload][:src], params[:upload][:dst]].join(': '))
15
+ end
16
+ if params[:download]
17
+
18
+ t_ret = scp.download!(params[:download][:src], params[:download][:dst], recursive: true)
19
+ UI.message(['[SCP COMMAND]', "Successfully Downloaded", params[:download][:src], params[:download][:dst]].join(': '))
20
+ unless params[:download][:dst]
21
+ ret = t_ret
22
+ end
23
+ end
24
+ end
25
+ ret
26
+ end
27
+
28
+ #####################################################
29
+ # @!group Documentation
30
+ #####################################################
31
+
32
+ def self.description
33
+ "Transfer files via SCP"
34
+ end
35
+
36
+ def self.available_options
37
+ [
38
+ PantographCore::ConfigItem.new(key: :username,
39
+ short_option: "-u",
40
+ env_name: "FL_SSH_USERNAME",
41
+ description: "Username",
42
+ is_string: true),
43
+ PantographCore::ConfigItem.new(key: :password,
44
+ short_option: "-p",
45
+ env_name: "FL_SSH_PASSWORD",
46
+ description: "Password",
47
+ sensitive: true,
48
+ optional: true,
49
+ is_string: true),
50
+ PantographCore::ConfigItem.new(key: :host,
51
+ short_option: "-H",
52
+ env_name: "FL_SSH_HOST",
53
+ description: "Hostname",
54
+ is_string: true),
55
+ PantographCore::ConfigItem.new(key: :port,
56
+ short_option: "-P",
57
+ env_name: "FL_SSH_PORT",
58
+ description: "Port",
59
+ optional: true,
60
+ default_value: "22",
61
+ is_string: true),
62
+ PantographCore::ConfigItem.new(key: :upload,
63
+ short_option: "-U",
64
+ env_name: "FL_SCP_UPLOAD",
65
+ description: "Upload",
66
+ optional: true,
67
+ is_string: false,
68
+ type: Hash),
69
+ PantographCore::ConfigItem.new(key: :download,
70
+ short_option: "-D",
71
+ env_name: "FL_SCP_DOWNLOAD",
72
+ description: "Download",
73
+ optional: true,
74
+ is_string: false,
75
+ type: Hash)
76
+
77
+ ]
78
+ end
79
+
80
+ def self.authors
81
+ ["hjanuschka"]
82
+ end
83
+
84
+ def self.is_supported?(platform)
85
+ true
86
+ end
87
+
88
+ def self.example_code
89
+ [
90
+ 'scp(
91
+ host: "dev.januschka.com",
92
+ username: "root",
93
+ upload: {
94
+ src: "/root/dir1",
95
+ dst: "/tmp/new_dir"
96
+ }
97
+ )',
98
+ 'scp(
99
+ host: "dev.januschka.com",
100
+ username: "root",
101
+ download: {
102
+ src: "/root/dir1",
103
+ dst: "/tmp/new_dir"
104
+ }
105
+ )'
106
+ ]
107
+ end
108
+
109
+ def self.category
110
+ :misc
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,274 @@
1
+ module Pantograph
2
+ module Actions
3
+ module SharedValues
4
+ SET_GITHUB_RELEASE_HTML_LINK = :SET_GITHUB_RELEASE_HTML_LINK
5
+ SET_GITHUB_RELEASE_RELEASE_ID = :SET_GITHUB_RELEASE_RELEASE_ID
6
+ SET_GITHUB_RELEASE_JSON = :SET_GITHUB_RELEASE_JSON
7
+ end
8
+
9
+ class SetGithubReleaseAction < Action
10
+ def self.run(params)
11
+ UI.important("Creating release of #{params[:repository_name]} on tag \"#{params[:tag_name]}\" with name \"#{params[:name]}\".")
12
+ UI.important("Will also upload assets #{params[:upload_assets]}.") if params[:upload_assets]
13
+
14
+ repo_name = params[:repository_name]
15
+ api_token = params[:api_token]
16
+ server_url = params[:server_url]
17
+ tag_name = params[:tag_name]
18
+
19
+ payload = {
20
+ 'tag_name' => params[:tag_name],
21
+ 'name' => params[:name],
22
+ 'body' => params[:description],
23
+ 'draft' => !!params[:is_draft],
24
+ 'prerelease' => !!params[:is_prerelease]
25
+ }
26
+ payload['target_commitish'] = params[:commitish] if params[:commitish]
27
+
28
+ GithubApiAction.run(
29
+ server_url: server_url,
30
+ api_token: api_token,
31
+ http_method: 'POST',
32
+ path: "repos/#{repo_name}/releases",
33
+ body: payload,
34
+ error_handlers: {
35
+ 422 => proc do |result|
36
+ UI.error(result[:body])
37
+ UI.error("Release on tag #{tag_name} already exists!")
38
+ return nil
39
+ end,
40
+ 404 => proc do |result|
41
+ UI.error(result[:body])
42
+ UI.user_error!("Repository #{repo_name} cannot be found, please double check its name and that you provided a valid API token (GITHUB_API_TOKEN)")
43
+ end,
44
+ 401 => proc do |result|
45
+ UI.error(result[:body])
46
+ UI.user_error!("You are not authorized to access #{repo_name}, please make sure you provided a valid API token (GITHUB_API_TOKEN)")
47
+ end,
48
+ '*' => proc do |result|
49
+ UI.error("GitHub responded with #{result[:status]}:#{result[:body]}")
50
+ return nil
51
+ end
52
+ }
53
+ ) do |result|
54
+ json = result[:json]
55
+ html_url = json['html_url']
56
+ release_id = json['id']
57
+
58
+ UI.success("Successfully created release at tag \"#{tag_name}\" on GitHub")
59
+ UI.important("See release at \"#{html_url}\"")
60
+
61
+ Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_HTML_LINK] = html_url
62
+ Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_RELEASE_ID] = release_id
63
+ Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_JSON] = json
64
+
65
+ assets = params[:upload_assets]
66
+ if assets && assets.count > 0
67
+ # upload assets
68
+ self.upload_assets(assets, json['upload_url'], api_token)
69
+
70
+ # fetch the release again, so that it contains the uploaded assets
71
+ GithubApiAction.run(
72
+ server_url: server_url,
73
+ api_token: api_token,
74
+ http_method: 'GET',
75
+ path: "repos/#{repo_name}/releases/#{release_id}",
76
+ error_handlers: {
77
+ '*' => proc do |get_result|
78
+ UI.error("GitHub responded with #{get_result[:status]}:#{get_result[:body]}")
79
+ UI.user_error!("Failed to fetch the newly created release, but it *has been created* successfully.")
80
+ end
81
+ }
82
+ ) do |get_result|
83
+ Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_JSON] = get_result[:json]
84
+ UI.success("Successfully uploaded assets #{assets} to release \"#{html_url}\"")
85
+ return get_result[:json]
86
+ end
87
+ else
88
+ return json || result[:body]
89
+ end
90
+ end
91
+ end
92
+
93
+ def self.upload_assets(assets, upload_url_template, api_token)
94
+ assets.each do |asset|
95
+ self.upload(asset, upload_url_template, api_token)
96
+ end
97
+ end
98
+
99
+ def self.upload(asset_path, upload_url_template, api_token)
100
+ # if it's a directory, zip it first in a temp directory, because we can only upload binary files
101
+ absolute_path = File.absolute_path(asset_path)
102
+
103
+ # check that the asset even exists
104
+ UI.user_error!("Asset #{absolute_path} doesn't exist") unless File.exist?(absolute_path)
105
+
106
+ if File.directory?(absolute_path)
107
+ Dir.mktmpdir do |dir|
108
+ tmpzip = File.join(dir, File.basename(absolute_path) + '.zip')
109
+ sh("cd \"#{File.dirname(absolute_path)}\"; zip -r --symlinks \"#{tmpzip}\" \"#{File.basename(absolute_path)}\" 2>&1 >/dev/null")
110
+ self.upload_file(tmpzip, upload_url_template, api_token)
111
+ end
112
+ else
113
+ self.upload_file(absolute_path, upload_url_template, api_token)
114
+ end
115
+ end
116
+
117
+ def self.upload_file(file, url_template, api_token)
118
+ require 'addressable/template'
119
+ file_name = File.basename(file)
120
+ expanded_url = Addressable::Template.new(url_template).expand(name: file_name).to_s
121
+ headers = { 'Content-Type' => 'application/zip' } # works for all binary files
122
+ UI.important("Uploading #{file_name}")
123
+ GithubApiAction.run(
124
+ api_token: api_token,
125
+ http_method: 'POST',
126
+ headers: headers,
127
+ url: expanded_url,
128
+ raw_body: File.read(file),
129
+ error_handlers: {
130
+ '*' => proc do |result|
131
+ UI.error("GitHub responded with #{result[:status]}:#{result[:body]}")
132
+ UI.user_error!("Failed to upload asset #{file_name} to GitHub.")
133
+ end
134
+ }
135
+ ) do |result|
136
+ UI.success("Successfully uploaded #{file_name}.")
137
+ end
138
+ end
139
+
140
+ #####################################################
141
+ # @!group Documentation
142
+ #####################################################
143
+
144
+ def self.description
145
+ "This will create a new release on GitHub and upload assets for it"
146
+ end
147
+
148
+ def self.details
149
+ [
150
+ "Creates a new release on GitHub. You must provide your GitHub Personal token (get one from [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new)), the repository name and tag name. By default, that's `master`.",
151
+ "If the tag doesn't exist, one will be created on the commit or branch passed in as commitish.",
152
+ "Out parameters provide the release's id, which can be used for later editing and the release HTML link to GitHub. You can also specify a list of assets to be uploaded to the release with the `:upload_assets` parameter."
153
+ ].join("\n")
154
+ end
155
+
156
+ def self.available_options
157
+ [
158
+ PantographCore::ConfigItem.new(key: :repository_name,
159
+ env_name: "FL_SET_GITHUB_RELEASE_REPOSITORY_NAME",
160
+ description: "The path to your repo, e.g. 'pantograph/pantograph'",
161
+ verify_block: proc do |value|
162
+ UI.user_error!("Please only pass the path, e.g. 'pantograph/pantograph'") if value.include?("github.com")
163
+ UI.user_error!("Please only pass the path, e.g. 'pantograph/pantograph'") if value.split('/').count != 2
164
+ end),
165
+ PantographCore::ConfigItem.new(key: :server_url,
166
+ env_name: "FL_GITHUB_RELEASE_SERVER_URL",
167
+ description: "The server url. e.g. 'https://your.internal.github.host/api/v3' (Default: 'https://api.github.com')",
168
+ default_value: "https://api.github.com",
169
+ optional: true,
170
+ verify_block: proc do |value|
171
+ UI.user_error!("Please include the protocol in the server url, e.g. https://your.github.server/api/v3") unless value.include?("//")
172
+ end),
173
+ PantographCore::ConfigItem.new(key: :api_token,
174
+ env_name: "FL_GITHUB_RELEASE_API_TOKEN",
175
+ description: "Personal API Token for GitHub - generate one at https://github.com/settings/tokens",
176
+ sensitive: true,
177
+ code_gen_sensitive: true,
178
+ is_string: true,
179
+ default_value: ENV["GITHUB_API_TOKEN"],
180
+ default_value_dynamic: true,
181
+ optional: false),
182
+ PantographCore::ConfigItem.new(key: :tag_name,
183
+ env_name: "FL_SET_GITHUB_RELEASE_TAG_NAME",
184
+ description: "Pass in the tag name",
185
+ is_string: true,
186
+ optional: false),
187
+ PantographCore::ConfigItem.new(key: :name,
188
+ env_name: "FL_SET_GITHUB_RELEASE_NAME",
189
+ description: "Name of this release",
190
+ is_string: true,
191
+ optional: true),
192
+ PantographCore::ConfigItem.new(key: :commitish,
193
+ env_name: "FL_SET_GITHUB_RELEASE_COMMITISH",
194
+ description: "Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master)",
195
+ is_string: true,
196
+ optional: true),
197
+ PantographCore::ConfigItem.new(key: :description,
198
+ env_name: "FL_SET_GITHUB_RELEASE_DESCRIPTION",
199
+ description: "Description of this release",
200
+ is_string: true,
201
+ optional: true,
202
+ default_value: Actions.lane_context[SharedValues::FL_CHANGELOG],
203
+ default_value_dynamic: true),
204
+ PantographCore::ConfigItem.new(key: :is_draft,
205
+ env_name: "FL_SET_GITHUB_RELEASE_IS_DRAFT",
206
+ description: "Whether the release should be marked as draft",
207
+ optional: true,
208
+ default_value: false,
209
+ is_string: false),
210
+ PantographCore::ConfigItem.new(key: :is_prerelease,
211
+ env_name: "FL_SET_GITHUB_RELEASE_IS_PRERELEASE",
212
+ description: "Whether the release should be marked as prerelease",
213
+ optional: true,
214
+ default_value: false,
215
+ is_string: false),
216
+ PantographCore::ConfigItem.new(key: :upload_assets,
217
+ env_name: "FL_SET_GITHUB_RELEASE_UPLOAD_ASSETS",
218
+ description: "Path to assets to be uploaded with the release",
219
+ optional: true,
220
+ is_string: false,
221
+ type: Array,
222
+ verify_block: proc do |value|
223
+ UI.user_error!("upload_assets must be an Array of paths to assets") unless value.kind_of?(Array)
224
+ end)
225
+ ]
226
+ end
227
+
228
+ def self.output
229
+ [
230
+ ['SET_GITHUB_RELEASE_HTML_LINK', 'Link to your created release'],
231
+ ['SET_GITHUB_RELEASE_RELEASE_ID', 'Release id (useful for subsequent editing)'],
232
+ ['SET_GITHUB_RELEASE_JSON', 'The whole release JSON object']
233
+ ]
234
+ end
235
+
236
+ def self.return_value
237
+ [
238
+ "A hash containing all relevant information of this release",
239
+ "Access things like 'html_url', 'tag_name', 'name', 'body'"
240
+ ].join("\n")
241
+ end
242
+
243
+ def self.return_type
244
+ :hash_of_strings
245
+ end
246
+
247
+ def self.authors
248
+ ["czechboy0", "tommeier"]
249
+ end
250
+
251
+ def self.is_supported?(platform)
252
+ true
253
+ end
254
+
255
+ def self.example_code
256
+ [
257
+ 'github_release = set_github_release(
258
+ repository_name: "pantograph/pantograph",
259
+ api_token: ENV["GITHUB_TOKEN"],
260
+ name: "Super New actions",
261
+ tag_name: "v1.22.0",
262
+ description: (File.read("changelog") rescue "No changelog provided"),
263
+ commitish: "master",
264
+ upload_assets: ["example_integration.ipa", "./pkg/built.gem"]
265
+ )'
266
+ ]
267
+ end
268
+
269
+ def self.category
270
+ :source_control
271
+ end
272
+ end
273
+ end
274
+ end
@@ -0,0 +1,71 @@
1
+ module Pantograph
2
+ module Actions
3
+ class ShAction < Action
4
+ def self.run(params)
5
+ # this is implemented in the sh_helper.rb
6
+ end
7
+
8
+ #####################################################
9
+ # @!group Documentation
10
+ #####################################################
11
+
12
+ def self.description
13
+ "Runs a shell command"
14
+ end
15
+
16
+ def self.details
17
+ [
18
+ "Allows running an arbitrary shell command.",
19
+ "Be aware of a specific behavior of `sh` action with regard to the working directory. For details, refer to [Advanced](https://docs.pantograph.tools/advanced/#directory-behavior)."
20
+ ].join("\n")
21
+ end
22
+
23
+ def self.available_options
24
+ [
25
+ PantographCore::ConfigItem.new(key: :command,
26
+ description: 'Shell command to be executed',
27
+ optional: false,
28
+ is_string: true),
29
+ PantographCore::ConfigItem.new(key: :log,
30
+ description: 'Determines whether pantograph should print out the executed command itself and output of the executed command. If command line option --troubleshoot is used, then it overrides this option to true',
31
+ optional: true,
32
+ is_string: false,
33
+ default_value: true),
34
+ PantographCore::ConfigItem.new(key: :error_callback,
35
+ description: 'A callback invoked with the command output if there is a non-zero exit status',
36
+ optional: true,
37
+ is_string: false,
38
+ type: :string_callback,
39
+ default_value: nil)
40
+ ]
41
+ end
42
+
43
+ def self.return_value
44
+ 'Outputs the string and executes it. When running in tests, it returns the actual command instead of executing it'
45
+ end
46
+
47
+ def self.return_type
48
+ :string
49
+ end
50
+
51
+ def self.authors
52
+ ["KrauseFx"]
53
+ end
54
+
55
+ def self.is_supported?(platform)
56
+ true
57
+ end
58
+
59
+ def self.example_code
60
+ [
61
+ 'sh("ls")',
62
+ 'sh("git", "commit", "-m", "My message")'
63
+ ]
64
+ end
65
+
66
+ def self.category
67
+ :misc
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,52 @@
1
+ module Pantograph
2
+ module Actions
3
+ class SkipDocsAction < Action
4
+ def self.run(params)
5
+ ENV["PANTOGRAPH_SKIP_DOCS"] = "1"
6
+ end
7
+
8
+ def self.step_text
9
+ nil
10
+ end
11
+
12
+ #####################################################
13
+ # @!group Documentation
14
+ #####################################################
15
+
16
+ def self.description
17
+ "Skip the creation of the pantograph/README.md file when running pantograph"
18
+ end
19
+
20
+ def self.available_options
21
+ end
22
+
23
+ def self.output
24
+ end
25
+
26
+ def self.return_value
27
+ end
28
+
29
+ def self.details
30
+ "Tell _pantograph_ to not automatically create a `pantograph/README.md` when running _pantograph_. You can always trigger the creation of this file manually by running `pantograph docs`."
31
+ end
32
+
33
+ def self.authors
34
+ ["KrauseFx"]
35
+ end
36
+
37
+ def self.is_supported?(platform)
38
+ true
39
+ end
40
+
41
+ def self.example_code
42
+ [
43
+ 'skip_docs'
44
+ ]
45
+ end
46
+
47
+ def self.category
48
+ :misc
49
+ end
50
+ end
51
+ end
52
+ end