rake_github 0.10.0.pre.3 → 0.10.0.pre.4

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: 3f8f733ef0720e2a7a0771f58bcb351f3ec82a869d85e3c435b9f6bf9d02f5b3
4
- data.tar.gz: 06b2bb2b409d16d1004683a2c0765a56fc1bf9b594fd130a4b3d9a0d577fe441
3
+ metadata.gz: d6c583a1d16365d2b2161b936af86004266163d119ecd7abe62f6a1ff40f4a98
4
+ data.tar.gz: '05228812b5b33fcf179fc34d02756a4a8d6fae455f2265fd17eea5c593820597'
5
5
  SHA512:
6
- metadata.gz: 530804e585f332642b5f83a17bb8384dc42baaba43563d5b4d7d28aa38bda78be4bd257d7a16e6aa38369bd15015faf7d9039a61fc7f78a17787c7da630ebb81
7
- data.tar.gz: c490ab14b2e2a4db44e2b7ad8d6fdb4ddabf25a224c5f07e35c1447d2d84d35c5019a69e7a842df662093afe23e0a0c526e92544b42eae4c99d1b112bc092d08
6
+ metadata.gz: a0d23f2f6b713cb0801714ad1a38ed8e332f2c8a82906c9a49210ef32b2075873f50026db5236142d1437cf63f5223d17fe6585c2a3120cc97f3547bfd09bc60
7
+ data.tar.gz: a61f397a68b631f56192c938833f1803958de3ac988d7b83608ebad25d83e95a046ea243c24d66145d0d84cd740d71bfeeaf25b6862182a30071b293e9a3bffa
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in rake_docker.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_github (0.10.0.pre.3)
4
+ rake_github (0.10.0.pre.4)
5
5
  colored2 (~> 3.1)
6
6
  octokit (~> 4.16)
7
7
  rake_factory (~> 0.23)
@@ -17,6 +17,7 @@ GEM
17
17
  tzinfo (~> 2.0)
18
18
  addressable (2.8.0)
19
19
  public_suffix (>= 2.0.2, < 5.0)
20
+ ast (2.4.2)
20
21
  colored2 (3.1.2)
21
22
  concurrent-ruby (1.1.9)
22
23
  diff-lcs (1.5.0)
@@ -60,7 +61,11 @@ GEM
60
61
  faraday (>= 0.9)
61
62
  sawyer (~> 0.8.0, >= 0.5.3)
62
63
  open4 (1.3.4)
64
+ parallel (1.22.1)
65
+ parser (3.1.1.0)
66
+ ast (~> 2.4.1)
63
67
  public_suffix (4.0.6)
68
+ rainbow (3.1.1)
64
69
  rake (13.0.6)
65
70
  rake_circle_ci (0.9.0)
66
71
  colored2 (~> 3.1)
@@ -77,6 +82,8 @@ GEM
77
82
  colored2 (~> 3.1)
78
83
  rake_factory (~> 0.23)
79
84
  sshkey (~> 2.0)
85
+ regexp_parser (2.2.1)
86
+ rexml (3.2.5)
80
87
  rspec (3.11.0)
81
88
  rspec-core (~> 3.11.0)
82
89
  rspec-expectations (~> 3.11.0)
@@ -90,6 +97,22 @@ GEM
90
97
  diff-lcs (>= 1.2.0, < 2.0)
91
98
  rspec-support (~> 3.11.0)
92
99
  rspec-support (3.11.0)
100
+ rubocop (1.26.1)
101
+ parallel (~> 1.10)
102
+ parser (>= 3.1.0.0)
103
+ rainbow (>= 2.2.2, < 4.0)
104
+ regexp_parser (>= 1.8, < 3.0)
105
+ rexml
106
+ rubocop-ast (>= 1.16.0, < 2.0)
107
+ ruby-progressbar (~> 1.7)
108
+ unicode-display_width (>= 1.4.0, < 3.0)
109
+ rubocop-ast (1.16.0)
110
+ parser (>= 3.1.1.0)
111
+ rubocop-rake (0.6.0)
112
+ rubocop (~> 1.0)
113
+ rubocop-rspec (2.9.0)
114
+ rubocop (~> 1.19)
115
+ ruby-progressbar (1.11.0)
93
116
  ruby2_keywords (0.0.5)
94
117
  ruby_gpg2 (0.8.0)
95
118
  lino (>= 1.5)
@@ -105,6 +128,7 @@ GEM
105
128
  sshkey (2.0.0)
106
129
  tzinfo (2.0.4)
107
130
  concurrent-ruby (~> 1.0)
131
+ unicode-display_width (2.1.0)
108
132
 
109
133
  PLATFORMS
110
134
  ruby
@@ -120,7 +144,10 @@ DEPENDENCIES
120
144
  rake_gpg
121
145
  rake_ssh
122
146
  rspec
147
+ rubocop
148
+ rubocop-rake
149
+ rubocop-rspec
123
150
  simplecov
124
151
 
125
152
  BUNDLED WITH
126
- 2.3.9
153
+ 2.3.11
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require 'rake_circle_ci'
3
5
  require 'rake_github'
@@ -5,17 +7,20 @@ require 'rake_ssh'
5
7
  require 'rake_gpg'
6
8
  require 'securerandom'
7
9
  require 'rspec/core/rake_task'
10
+ require 'rubocop/rake_task'
8
11
 
9
- task :default => :spec
10
-
11
- RSpec::Core::RakeTask.new(:spec)
12
+ task default: %i[
13
+ library:fix
14
+ test:unit
15
+ ]
12
16
 
13
17
  namespace :encryption do
14
18
  namespace :passphrase do
19
+ desc 'Generate encryption passphrase for CI GPG key'
15
20
  task :generate do
16
- File.open('config/secrets/ci/encryption.passphrase', 'w') do |f|
17
- f.write(SecureRandom.base64(36))
18
- end
21
+ FileUtils.mkdir_p('config/secrets/ci/')
22
+ File.write('config/secrets/ci/encryption.passphrase',
23
+ SecureRandom.base64(36))
19
24
  end
20
25
  end
21
26
  end
@@ -23,85 +28,102 @@ end
23
28
  namespace :keys do
24
29
  namespace :deploy do
25
30
  RakeSSH.define_key_tasks(
26
- path: 'config/secrets/ci/',
27
- comment: 'maintainers@infrablocks.io')
31
+ path: 'config/secrets/ci/',
32
+ comment: 'maintainers@infrablocks.io'
33
+ )
28
34
  end
29
35
 
30
36
  namespace :gpg do
31
37
  RakeGPG.define_generate_key_task(
32
- output_directory: 'config/secrets/ci',
33
- name_prefix: 'gpg',
34
- owner_name: 'InfraBlocks Maintainers',
35
- owner_email: 'maintainers@infrablocks.io',
36
- owner_comment: 'rake_github CI Key')
38
+ output_directory: 'config/secrets/ci',
39
+ name_prefix: 'gpg',
40
+ owner_name: 'InfraBlocks Maintainers',
41
+ owner_email: 'maintainers@infrablocks.io',
42
+ owner_comment: 'rake_github CI Key'
43
+ )
37
44
  end
38
45
  end
39
46
 
47
+ RuboCop::RakeTask.new
48
+
49
+ namespace :library do
50
+ desc 'Run all checks of the library'
51
+ task check: [:rubocop]
52
+
53
+ desc 'Attempt to automatically fix issues with the library'
54
+ task fix: [:'rubocop:auto_correct']
55
+ end
56
+
57
+ namespace :test do
58
+ RSpec::Core::RakeTask.new(:unit)
59
+ end
60
+
40
61
  RakeCircleCI.define_project_tasks(
41
- namespace: :circle_ci,
42
- project_slug: 'github/infrablocks/rake_github'
62
+ namespace: :circle_ci,
63
+ project_slug: 'github/infrablocks/rake_github'
43
64
  ) do |t|
44
65
  circle_ci_config =
45
- YAML.load_file('config/secrets/circle_ci/config.yaml')
66
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
46
67
 
47
- t.api_token = circle_ci_config["circle_ci_api_token"]
68
+ t.api_token = circle_ci_config['circle_ci_api_token']
48
69
  t.environment_variables = {
49
- ENCRYPTION_PASSPHRASE:
50
- File.read('config/secrets/ci/encryption.passphrase')
51
- .chomp
70
+ ENCRYPTION_PASSPHRASE:
71
+ File.read('config/secrets/ci/encryption.passphrase')
72
+ .chomp
52
73
  }
53
74
  t.checkout_keys = []
54
75
  t.ssh_keys = [
55
- {
56
- hostname: "github.com",
57
- private_key: File.read('config/secrets/ci/ssh.private')
58
- }
76
+ {
77
+ hostname: 'github.com',
78
+ private_key: File.read('config/secrets/ci/ssh.private')
79
+ }
59
80
  ]
60
81
  end
61
82
 
62
83
  RakeGithub.define_repository_tasks(
63
- namespace: :github,
64
- repository: 'infrablocks/rake_github',
84
+ namespace: :github,
85
+ repository: 'infrablocks/rake_github'
65
86
  ) do |t, args|
66
87
  github_config =
67
- YAML.load_file('config/secrets/github/config.yaml')
88
+ YAML.load_file('config/secrets/github/config.yaml')
68
89
 
69
- t.access_token = github_config["github_personal_access_token"]
90
+ t.access_token = github_config['github_personal_access_token']
70
91
  t.deploy_keys = [
71
- {
72
- title: 'CircleCI',
73
- public_key: File.read('config/secrets/ci/ssh.public')
74
- }
92
+ {
93
+ title: 'CircleCI',
94
+ public_key: File.read('config/secrets/ci/ssh.public')
95
+ }
75
96
  ]
76
97
  t.branch_name = args.branch_name
77
98
  t.commit_message = args.commit_message
78
99
  end
79
100
 
80
101
  namespace :pipeline do
81
- task :prepare => [
82
- :'circle_ci:project:follow',
83
- :'circle_ci:env_vars:ensure',
84
- :'circle_ci:checkout_keys:ensure',
85
- :'circle_ci:ssh_keys:ensure',
86
- :'github:deploy_keys:ensure'
102
+ desc 'Prepare CircleCI Pipeline'
103
+ task prepare: %i[
104
+ circle_ci:project:follow
105
+ circle_ci:env_vars:ensure
106
+ circle_ci:checkout_keys:ensure
107
+ circle_ci:ssh_keys:ensure
108
+ github:deploy_keys:ensure
87
109
  ]
88
110
  end
89
111
 
90
112
  namespace :version do
91
- desc "Bump version for specified type (pre, major, minor, patch)"
113
+ desc 'Bump version for specified type (pre, major, minor, patch)'
92
114
  task :bump, [:type] do |_, args|
93
115
  bump_version_for(args.type)
94
116
  end
95
117
  end
96
118
 
97
- desc "Release gem"
119
+ desc 'Release gem'
98
120
  task :release do
99
- sh "gem release --tag --push"
121
+ sh 'gem release --tag --push'
100
122
  end
101
123
 
102
124
  def bump_version_for(version_type)
103
- sh "gem bump --version #{version_type} " +
104
- "&& bundle install " +
105
- "&& export LAST_MESSAGE=\"$(git log -1 --pretty=%B)\" " +
106
- "&& git commit -a --amend -m \"${LAST_MESSAGE} [ci skip]\""
125
+ sh "gem bump --version #{version_type} " \
126
+ '&& bundle install ' \
127
+ '&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
128
+ '&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
107
129
  end
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "rake_github"
4
+ require 'bundler/setup'
5
+ require 'rake_github'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "rake_github"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
 
3
5
  require_relative '../tasks'
@@ -16,17 +18,17 @@ module RakeGithub
16
18
  parameter :ensure_task_name, default: :ensure
17
19
 
18
20
  task Tasks::DeployKeys::Provision,
19
- name: RakeFactory::DynamicValue.new { |ts|
20
- ts.provision_task_name
21
- }
21
+ name: RakeFactory::DynamicValue.new { |ts|
22
+ ts.provision_task_name
23
+ }
22
24
  task Tasks::DeployKeys::Destroy,
23
- name: RakeFactory::DynamicValue.new { |ts|
24
- ts.destroy_task_name
25
- }
25
+ name: RakeFactory::DynamicValue.new { |ts|
26
+ ts.destroy_task_name
27
+ }
26
28
  task Tasks::DeployKeys::Ensure,
27
- name: RakeFactory::DynamicValue.new { |ts|
28
- ts.ensure_task_name
29
- }
29
+ name: RakeFactory::DynamicValue.new { |ts|
30
+ ts.ensure_task_name
31
+ }
30
32
  end
31
33
  end
32
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
 
3
5
  require_relative '../tasks'
@@ -19,52 +21,54 @@ module RakeGithub
19
21
  parameter :commit_message, default: ''
20
22
 
21
23
  task Tasks::DeployKeys::Provision,
22
- name: RakeFactory::DynamicValue.new { |ts|
23
- ts.deploy_keys_provision_task_name
24
- }
24
+ name: RakeFactory::DynamicValue.new { |ts|
25
+ ts.deploy_keys_provision_task_name
26
+ }
25
27
  task Tasks::DeployKeys::Destroy,
26
- name: RakeFactory::DynamicValue.new { |ts|
27
- ts.deploy_keys_destroy_task_name
28
- }
28
+ name: RakeFactory::DynamicValue.new { |ts|
29
+ ts.deploy_keys_destroy_task_name
30
+ }
29
31
  task Tasks::DeployKeys::Ensure,
30
- name: RakeFactory::DynamicValue.new { |ts|
31
- ts.deploy_keys_ensure_task_name
32
- },
33
- provision_task_name: RakeFactory::DynamicValue.new { |ts|
34
- ts.deploy_keys_provision_task_name
35
- },
36
- destroy_task_name: RakeFactory::DynamicValue.new { |ts|
37
- ts.deploy_keys_destroy_task_name
38
- }
32
+ name: RakeFactory::DynamicValue.new { |ts|
33
+ ts.deploy_keys_ensure_task_name
34
+ },
35
+ provision_task_name: RakeFactory::DynamicValue.new { |ts|
36
+ ts.deploy_keys_provision_task_name
37
+ },
38
+ destroy_task_name: RakeFactory::DynamicValue.new { |ts|
39
+ ts.deploy_keys_destroy_task_name
40
+ }
39
41
  task Tasks::PullRequests::Merge,
40
- argument_names: [:branch_name, :commit_message],
41
- branch_name: RakeFactory::DynamicValue.new { |ts|
42
- ts.branch_name
43
- },
44
- commit_message: RakeFactory::DynamicValue.new { |ts|
45
- ts.commit_message
46
- }
42
+ argument_names: %i[branch_name commit_message],
43
+ branch_name: RakeFactory::DynamicValue.new { |ts|
44
+ ts.branch_name
45
+ },
46
+ commit_message: RakeFactory::DynamicValue.new { |ts|
47
+ ts.commit_message
48
+ }
47
49
 
48
50
  def define_on(application)
49
51
  around_define(application) do
50
52
  self.class.tasks.each do |task_definition|
51
- ns = case task_definition.klass.to_s
52
- when /DeployKeys/
53
- deploy_keys_namespace
54
- when /PullRequests/
55
- :pull_requests
56
- else
57
- nil
58
- end
53
+ namespace = resolve_namespace(task_definition)
59
54
 
60
- application.in_namespace(ns) do
55
+ application.in_namespace(namespace) do
61
56
  task_definition
62
- .for_task_set(self)
63
- .define_on(application)
57
+ .for_task_set(self)
58
+ .define_on(application)
64
59
  end
65
60
  end
66
61
  end
67
62
  end
63
+
64
+ private
65
+
66
+ def resolve_namespace(task_definition)
67
+ case task_definition.klass.to_s
68
+ when /DeployKeys/ then deploy_keys_namespace
69
+ when /PullRequests/ then :pull_requests
70
+ end
71
+ end
68
72
  end
69
73
  end
70
74
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'task_sets/deploy_keys'
2
4
  require_relative 'task_sets/repository'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'octokit'
3
5
 
@@ -6,9 +8,9 @@ module RakeGithub
6
8
  module DeployKeys
7
9
  class Destroy < RakeFactory::Task
8
10
  default_name :destroy
9
- default_description(RakeFactory::DynamicValue.new { |t|
11
+ default_description(RakeFactory::DynamicValue.new do |t|
10
12
  "Destroys deploy keys from the #{t.repository} repository"
11
- })
13
+ end)
12
14
 
13
15
  parameter :repository, required: true
14
16
  parameter :access_token, required: true
@@ -17,17 +19,17 @@ module RakeGithub
17
19
  action do |t|
18
20
  client = Octokit::Client.new(access_token: access_token)
19
21
 
20
- puts "Removing specified deploy keys from the " +
21
- "'#{t.repository}' repository... "
22
+ $stdout.puts 'Removing specified deploy keys from the ' \
23
+ "'#{t.repository}' repository... "
22
24
  all_deploy_keys = client.list_deploy_keys(t.repository)
23
25
  t.deploy_keys.each do |deploy_key|
24
- print "Removing '#{deploy_key[:title]}' key... "
26
+ $stdout.print "Removing '#{deploy_key[:title]}' key... "
25
27
  matching_deploy_key =
26
- all_deploy_keys.find { |k| k[:title] == deploy_key[:title] }
28
+ all_deploy_keys.find { |k| k[:title] == deploy_key[:title] }
27
29
  if matching_deploy_key
28
30
  client.remove_deploy_key(t.repository, matching_deploy_key[:id])
29
31
  end
30
- puts "Done."
32
+ $stdout.puts 'Done.'
31
33
  end
32
34
  end
33
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
 
3
5
  module RakeGithub
@@ -5,10 +7,10 @@ module RakeGithub
5
7
  module DeployKeys
6
8
  class Ensure < RakeFactory::Task
7
9
  default_name :ensure
8
- default_description(RakeFactory::DynamicValue.new { |t|
9
- "Ensure deploy keys are configured on the " +
10
- "#{t.repository} repository"
11
- })
10
+ default_description(RakeFactory::DynamicValue.new do |t|
11
+ 'Ensure deploy keys are configured on the ' \
12
+ "#{t.repository} repository"
13
+ end)
12
14
 
13
15
  parameter :repository, required: true
14
16
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'octokit'
3
5
 
@@ -6,9 +8,9 @@ module RakeGithub
6
8
  module DeployKeys
7
9
  class Provision < RakeFactory::Task
8
10
  default_name :provision
9
- default_description(RakeFactory::DynamicValue.new { |t|
11
+ default_description(RakeFactory::DynamicValue.new do |t|
10
12
  "Provision deploy keys to the #{t.repository} repository"
11
- })
13
+ end)
12
14
 
13
15
  parameter :repository, required: true
14
16
  parameter :access_token, required: true
@@ -17,16 +19,17 @@ module RakeGithub
17
19
  action do |t|
18
20
  client = Octokit::Client.new(access_token: access_token)
19
21
 
20
- puts "Adding specified deploy keys to the " +
21
- "'#{t.repository}' repository... "
22
+ $stdout.puts 'Adding specified deploy keys to the ' \
23
+ "'#{t.repository}' repository... "
22
24
  t.deploy_keys.each do |deploy_key|
23
- print "Adding '#{deploy_key[:title]}'... "
25
+ $stdout.print "Adding '#{deploy_key[:title]}'... "
24
26
  client.add_deploy_key(
25
- t.repository,
26
- deploy_key[:title],
27
- deploy_key[:public_key],
28
- read_only: !!deploy_key[:read_only])
29
- puts "Done."
27
+ t.repository,
28
+ deploy_key[:title],
29
+ deploy_key[:public_key],
30
+ read_only: !deploy_key[:read_only].nil?
31
+ )
32
+ $stdout.puts 'Done.'
30
33
  end
31
34
  end
32
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'deploy_keys/provision'
2
4
  require_relative 'deploy_keys/destroy'
3
5
  require_relative 'deploy_keys/ensure'
@@ -8,28 +8,29 @@ module RakeGithub
8
8
  module PullRequests
9
9
  class Merge < RakeFactory::Task
10
10
  default_description(RakeFactory::DynamicValue.new do |t|
11
- "Merges pull request on the specified branch in the #{t.repository} repository"
11
+ 'Merges pull request on the specified branch in the '\
12
+ "#{t.repository} repository"
12
13
  end)
13
14
 
15
+ default_argument_names %i[branch_name commit_message]
16
+
14
17
  parameter :repository, required: true
15
18
  parameter :access_token, required: true
16
19
  parameter :branch_name, required: true
17
- parameter :commit_message, default: ''
18
-
19
- action do |t|
20
- github_client = Octokit::Client.new(access_token: access_token)
20
+ parameter :commit_message, default: '%s'
21
21
 
22
- open_prs = github_client.pull_requests(t.repository)
22
+ action do |t, _args|
23
+ client = Octokit::Client.new(access_token: access_token)
23
24
 
24
- current_pr = open_prs
25
- .find { |pr| pr[:head][:ref] == t.branch_name }
25
+ open_prs = client.pull_requests(t.repository)
26
+ current_pr = open_prs.find { |pr| pr[:head][:ref] == t.branch_name }
26
27
 
27
- raise NoPullRequestError.new t.branch_name if current_pr.nil?
28
+ raise NoPullRequestError, t.branch_name if current_pr.nil?
28
29
 
29
- github_client.merge_pull_request(
30
+ client.merge_pull_request(
30
31
  t.repository,
31
32
  current_pr[:number],
32
- format(t.commit_message % current_pr[:title])
33
+ format(t.commit_message, current_pr[:title])
33
34
  )
34
35
  end
35
36
  end
@@ -39,11 +40,13 @@ end
39
40
 
40
41
  class NoPullRequestError < StandardError
41
42
  attr_reader :branch_name
43
+
42
44
  def initialize(branch_name)
45
+ super()
43
46
  @branch_name = branch_name
44
47
  end
45
48
 
46
49
  def message
47
- "No pull request associated with branch %s" % branch_name
50
+ format('No pull request associated with branch %s', branch_name)
48
51
  end
49
- end
52
+ end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'pull_requests/merge'
@@ -22,51 +22,70 @@ module RakeGithub
22
22
  parameter :discussion_category_name
23
23
  parameter :assets, default: []
24
24
 
25
- action do |t|
25
+ action do |task|
26
26
  client = Octokit::Client.new(access_token: access_token)
27
27
 
28
- release_options = {
29
- draft: t.draft,
30
- prerelease: t.prerelease
31
- }
32
- if t.target_commitish
33
- release_options[:target_commitish] = t.target_commitish
34
- end
35
- if t.release_name
36
- release_options[:release_name] = t.release_name
37
- end
38
- if t.body
39
- release_options[:body] = t.body
28
+ log_creating_release(task)
29
+ release = create_release(client, task)
30
+
31
+ task.assets.each do |asset|
32
+ log_uploading_asset(task, asset)
33
+ upload_asset(client, release, asset)
40
34
  end
41
- if t.discussion_category_name
42
- release_options[:discussion_category_name] =
43
- t.discussion_category_name
35
+ end
36
+
37
+ private
38
+
39
+ def log_creating_release(task)
40
+ $stdout.puts(
41
+ 'Creating release' \
42
+ "#{task.release_name ? " '#{task.release_name}'" : ''} " \
43
+ "with tag '#{task.tag_name}' " \
44
+ "on '#{task.repository}' repository..."
45
+ )
46
+ end
47
+
48
+ def log_uploading_asset(task, asset)
49
+ if asset.is_a?(String)
50
+ $stdout
51
+ .puts("Uploading asset '#{asset}' to release with tag "\
52
+ "'#{task.tag_name}'...")
53
+ else
54
+ $stdout
55
+ .puts("Uploading asset '#{asset[:path]}'" \
56
+ "#{asset[:name] ? " with name '#{asset[:name]}'" : ''} " \
57
+ "to release with tag '#{task.tag_name}'...")
44
58
  end
59
+ end
45
60
 
46
- puts 'Creating release' \
47
- "#{t.release_name ? " '#{t.release_name}'" : ''} " \
48
- "with tag '#{t.tag_name}' " \
49
- "on '#{t.repository}' repository..."
50
- release = client.create_release(
51
- t.repository,
52
- t.tag_name,
53
- release_options
61
+ def create_release(client, task)
62
+ client.create_release(
63
+ task.repository,
64
+ task.tag_name,
65
+ release_options(task)
54
66
  )
67
+ end
55
68
 
56
- t.assets.each do |asset|
57
- if asset.is_a?(String)
58
- puts "Uploading asset '#{asset}' to release with tag '#{t.tag_name}'..."
59
- client.upload_asset(release.url, asset)
60
- else
61
- puts(
62
- "Uploading asset '#{asset[:path]}'" +
63
- "#{asset[:name] ? " with name '#{asset[:name]}'" : ''} " +
64
- "to release with tag '#{t.tag_name}'...")
65
- client.upload_asset(
66
- release.url, asset[:path], { name: asset[:name] })
67
- end
69
+ def upload_asset(client, release, asset)
70
+ if asset.is_a?(String)
71
+ client.upload_asset(release.url, asset)
72
+ else
73
+ client.upload_asset(
74
+ release.url, asset[:path], { name: asset[:name] }
75
+ )
68
76
  end
69
77
  end
78
+
79
+ def release_options(task)
80
+ {
81
+ body: task.body,
82
+ draft: task.draft,
83
+ prerelease: task.prerelease,
84
+ target_commitish: task.target_commitish,
85
+ release_name: task.release_name,
86
+ discussion_category_name: task.discussion_category_name
87
+ }.compact
88
+ end
70
89
  end
71
90
  end
72
91
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'releases/create'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'tasks/deploy_keys'
2
4
  require_relative 'tasks/releases'
3
5
  require_relative 'tasks/pull_requests'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RakeGithub
2
- VERSION = '0.10.0.pre.3'
4
+ VERSION = '0.10.0.pre.4'
3
5
  end
data/lib/rake_github.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_github/version'
2
4
  require 'rake_github/tasks'
3
5
  require 'rake_github/task_sets'
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'rake_github/version'
6
+
7
+ files = %w[
8
+ bin
9
+ lib
10
+ CODE_OF_CONDUCT.md
11
+ rake_github.gemspec
12
+ Gemfile
13
+ LICENSE.txt
14
+ Rakefile
15
+ README.md
16
+ ]
17
+
18
+ Gem::Specification.new do |spec|
19
+ spec.name = 'rake_github'
20
+ spec.version = RakeGithub::VERSION
21
+ spec.authors = ['InfraBlocks Maintainers']
22
+ spec.email = ['maintainers@infrablocks.io']
23
+
24
+ spec.summary = 'Rake tasks for managing Github repositories.'
25
+ spec.description = 'Allows managing repository deploy keys.'
26
+ spec.homepage = 'https://github.com/infrablocks/rake_github'
27
+ spec.license = 'MIT'
28
+
29
+ spec.files = `git ls-files -z`.split("\x0").select do |f|
30
+ f.match(/^(#{files.map { |g| Regexp.escape(g) }.join('|')})/)
31
+ end
32
+ spec.bindir = 'exe'
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ['lib']
35
+
36
+ spec.required_ruby_version = '>= 2.7'
37
+
38
+ spec.add_dependency 'colored2', '~> 3.1'
39
+ spec.add_dependency 'octokit', '~> 4.16'
40
+ spec.add_dependency 'rake_factory', '~> 0.23'
41
+ spec.add_dependency 'sshkey', '~> 2.0'
42
+
43
+ spec.add_development_dependency 'activesupport'
44
+ spec.add_development_dependency 'bundler'
45
+ spec.add_development_dependency 'gem-release'
46
+ spec.add_development_dependency 'memfs'
47
+ spec.add_development_dependency 'rake'
48
+ spec.add_development_dependency 'rake_circle_ci'
49
+ spec.add_development_dependency 'rake_github'
50
+ spec.add_development_dependency 'rake_gpg'
51
+ spec.add_development_dependency 'rake_ssh'
52
+ spec.add_development_dependency 'rspec'
53
+ spec.add_development_dependency 'rubocop'
54
+ spec.add_development_dependency 'rubocop-rake'
55
+ spec.add_development_dependency 'rubocop-rspec'
56
+ spec.add_development_dependency 'simplecov'
57
+
58
+ spec.metadata['rubygems_mfa_required'] = 'false'
59
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0.pre.3
4
+ version: 0.10.0.pre.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-21 00:00:00.000000000 Z
11
+ date: 2022-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -206,6 +206,48 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: rubocop
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: rubocop-rake
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rubocop-rspec
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: '0'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ">="
249
+ - !ruby/object:Gem::Version
250
+ version: '0'
209
251
  - !ruby/object:Gem::Dependency
210
252
  name: simplecov
211
253
  requirement: !ruby/object:Gem::Requirement
@@ -249,10 +291,12 @@ files:
249
291
  - lib/rake_github/tasks/releases.rb
250
292
  - lib/rake_github/tasks/releases/create.rb
251
293
  - lib/rake_github/version.rb
294
+ - rake_github.gemspec
252
295
  homepage: https://github.com/infrablocks/rake_github
253
296
  licenses:
254
297
  - MIT
255
- metadata: {}
298
+ metadata:
299
+ rubygems_mfa_required: 'false'
256
300
  post_install_message:
257
301
  rdoc_options: []
258
302
  require_paths: