devops_helper 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de680446ea31db8037dc619b1eef1fad1936a57afdcdd9495cd35a411a61f7a4
4
- data.tar.gz: 244a9bb9f7b792a8af1b3ca2df4f7a7b7a111686dac4626306568ef10a01c9b8
3
+ metadata.gz: 62df2d95274ed5039e7e48c2500cdb3a500beb0a1b7c3fac181e143f35e9ae44
4
+ data.tar.gz: 31d8db6c498055121b882bffa91c08f6a9d60440a99076a65d140d5fe7bbe481
5
5
  SHA512:
6
- metadata.gz: d61ba38f0de3919d554e3a036dd773487d89119372ce5d3e0bf612cae2df160d3a21d2df4cef2bee9e4e68c8304111e5aaa6f10f03943aa3b988b395eb64571d
7
- data.tar.gz: 5eeb5192dcd6d694bb3a1d7d82fc2a0fa6abb56e2cc72f037c0f9201092452ba46133473d78883db03db9789e306e81f41b0afe6e611f666b842f379fd0a2401
6
+ metadata.gz: 4940cd9590907cb0b370276c1b634e1ab04ad36e6d13cc538cb88ff10ec38a530681c490f2aa432ddf7f4a8d3d16c09673384d8d6f72051e91a27a73c3fa5e10
7
+ data.tar.gz: 150797e3d38041a5060de5661289b2c66670be36b7ce422e54512dcd42193061ad82e204e16b1bb7bb558e3a97b5f58e3bc48de1c17da268736b1a274752ab78
data/README.md CHANGED
@@ -1,8 +1,15 @@
1
1
  # DevopsHelper
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/devops_helper`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ DevOpsHelper is meant to standardize the workflow, specificially gem release, in simplified and easy to use Rake task.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Basically the typical workflow are:
6
+ 1. Check in source code
7
+ 2. Edit version.rb
8
+ 3. Build the gem
9
+ 4. Add to git and tag the release
10
+ 5. Push gem file to rubygems
11
+
12
+ Sure there can have more such as integration with Continous Integration automated test etc. However that's my basic workflow as of now.
6
13
 
7
14
  ## Installation
8
15
 
@@ -20,9 +27,20 @@ Or install it yourself as:
20
27
 
21
28
  $ gem install devops_helper
22
29
 
30
+ This is a set or Rake task haven't found automated way to include into the project Rakefile. Therefore manual intervention is required.
31
+
32
+ In order to complete the installation, need to add the following into the project Rakefile
33
+
34
+ ```ruby
35
+ require 'devops_helper'
36
+ ```
23
37
  ## Usage
24
38
 
25
- TODO: Write usage instructions here
39
+ It runs as typical Rake task:
40
+
41
+ $ rake devops:gem_release
42
+
43
+ Then follow the prompt until it is done.
26
44
 
27
45
  ## Development
28
46
 
@@ -32,7 +50,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
50
 
33
51
  ## Contributing
34
52
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/devops_helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/devops_helper/blob/master/CODE_OF_CONDUCT.md).
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/devops_helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/chrisliaw/devops_helper/blob/master/CODE_OF_CONDUCT.md).
36
54
 
37
55
 
38
56
  ## License
@@ -41,4 +59,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
59
 
42
60
  ## Code of Conduct
43
61
 
44
- Everyone interacting in the DevopsHelper project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/devops_helper/blob/master/CODE_OF_CONDUCT.md).
62
+ Everyone interacting in the DevopsHelper project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/chrisliaw/devops_helper/blob/master/CODE_OF_CONDUCT.md).
@@ -14,6 +14,28 @@ module DevopsHelper
14
14
  execute_build_task(t)
15
15
  end
16
16
 
17
+ def publish_gem(version, opts = { },&block)
18
+ # find the package
19
+ root = opts[:root] || Dir.getwd
20
+ foundGem = Dir.glob("**/*-#{version}.gem")
21
+ if foundGem.length == 0
22
+ raise DevopsHelper::Error, "No built gem found."
23
+ elsif foundGem.length > 1
24
+ if block
25
+ targetGem = block.call(:multiple_built_gems, foundGem)
26
+ else
27
+ raise DevopsHelper::Error, "Multiple versions of gem found : #{foundGem}. Please provide a block for selection"
28
+ end
29
+ else
30
+ targetGem = foundGem.first
31
+ end
32
+
33
+ cmd = "cd #{root} && gem push #{targetGem}"
34
+ DevopsHelper::Global.instance.logger.tdebug :gem_rake_helper, "Command to publish gem : #{cmd}"
35
+ `#{cmd}`
36
+ [$?, targetGem]
37
+ end
38
+
17
39
  private
18
40
  def find_build_task
19
41
  task = nil
@@ -43,6 +43,7 @@ namespace :devops do
43
43
  rh = DevopsHelper::GemReleaseHelper.new
44
44
  spec = rh.find_gemspec(wd)
45
45
 
46
+ # find version file
46
47
  vf = rh.find_gem_version_file(wd)
47
48
  if vf.length > 1
48
49
  # more then one. User has to select
@@ -72,13 +73,14 @@ namespace :devops do
72
73
  STDOUT.puts "Gem version file rewritten"
73
74
 
74
75
  if vh.is_workspace?
75
- # commit changes
76
+ # commit changes of the new version file before tagging
76
77
  vh.add(svf)
77
78
  vh.commit("Automated commit by DevOps Helper during release process", { files: [svf] })
78
79
  end
79
80
 
80
81
  end
81
82
 
83
+ # tagging start here. Any new changes has to be done before this stage
82
84
  if vh.is_workspace?
83
85
  begin
84
86
  tagSrc = tp.yes?("Tag the source code for this release? ")
@@ -92,14 +94,44 @@ namespace :devops do
92
94
  exit(1)
93
95
  end
94
96
  end
97
+ # done tagging source code
95
98
 
99
+ # build the gem
96
100
  res = rh.build_gem
97
101
  STDOUT.puts "Gem '#{gs.name}' built"
102
+ # gem built
98
103
 
99
104
  vs.register_version(gs.name, targetVersion)
100
105
  vs.save(wd)
101
106
  STDOUT.puts "Version '#{targetVersion}' registered"
102
107
 
108
+ # push gem? Optional anyway
109
+ pub = tp.yes?("Do you want to publish the generated Gem file? ")
110
+ if pub
111
+ res, gemFile = rh.publish_gem(targetVersion) do |ops, vers|
112
+ case ops
113
+ when :multiple_built_gems
114
+ sel = vers
115
+ sel << "Quit"
116
+ selGem = tp.select("There are multiple Gems with the same version number found. Please select one of the following to publish: ", sel)
117
+ if selGem == "Quit"
118
+ STDOUT.puts "No built gem shall be published."
119
+ else
120
+ selGem
121
+ end
122
+ end
123
+ end
124
+
125
+ if not res.success?
126
+ STDERR.puts "Failed to publish the Gem."
127
+ else
128
+ STDOUT.puts "Gem '#{gemFile}' published"
129
+ end
130
+ else
131
+ STDOUT.puts "Gem will not be published. Please manually publish the gem."
132
+ end
133
+ # end push gem
134
+
103
135
  elsif is_empty?(spec)
104
136
  STDERR.puts "gemspec file not found at '#{wd}'"
105
137
  exit(2)
@@ -1,3 +1,3 @@
1
1
  module DevopsHelper
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devops_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-21 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toolrack
@@ -111,7 +111,7 @@ homepage: https://github.com/chrisliaw/devops_helper
111
111
  licenses:
112
112
  - MIT
113
113
  metadata: {}
114
- post_install_message:
114
+ post_install_message:
115
115
  rdoc_options: []
116
116
  require_paths:
117
117
  - lib
@@ -126,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.1.4
130
- signing_key:
129
+ rubygems_version: 3.1.2
130
+ signing_key:
131
131
  specification_version: 4
132
132
  summary: DevOps Helper to assist in DevOps operation
133
133
  test_files: []