releasinator 0.4.0 → 0.4.1

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
  SHA1:
3
- metadata.gz: 16d22b79347de442120d0265334c95b5733e8618
4
- data.tar.gz: d10c35acd08786cb5051804896872ec9b11ae69c
3
+ metadata.gz: 13f6f9c34a097f3dcb68bd15c8df1501f190a482
4
+ data.tar.gz: 6860c893ba8ddf2efe8d1011473afe3309f42e5f
5
5
  SHA512:
6
- metadata.gz: 877206063b2c70b6ea450ccf2b5952599bf6ae99979deece46664f7383676f414665b13665c39a2f8446d4ddc971d379add10b795d867fdc60f376440d4147d5
7
- data.tar.gz: f1ba1a850d323a704a90f018c52e3c4aae812171387da3adf99d554243903050b6668b49ea84761f627233e07a631fe30237fd3f5213a9e3bab849be538ad686
6
+ metadata.gz: 91891918d99e27b46e1c88d0de701d3d90f312a356c9c910d5d04fda7260efdca1331ae2d1d096406a74e82f392160a6ffd11e127a1984bd614f42d37b6d567e
7
+ data.tar.gz: bc6aca918ee4cf5a4c5265f706f53a92c8a3910b315198ddfe8b973b8df654d1953b0dad2ab986dd9cfa8b1199be08f2eae436a645c6af2ecaa49f5e963aa36c
data/.releasinator.rb CHANGED
@@ -56,14 +56,6 @@ def publish_to_package_manager(version)
56
56
  end
57
57
  end
58
58
 
59
- def say_hello(version)
60
- puts "hello #{version}"
61
- end
62
-
63
- configatron.post_push_methods = [
64
- method(:say_hello)
65
- ]
66
-
67
59
  # The method that publishes the sdk to the package manager. Required.
68
60
  configatron.publish_to_package_manager_method = method(:publish_to_package_manager)
69
61
 
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  Releasinator release notes
2
2
  ==========================
3
3
 
4
+ 0.4.1
5
+ -----
6
+ * `release_to_github` will now create a new release (instead of a draft).
7
+ * Freeze some options after loading to avoid accidental overwrite.
4
8
 
5
9
  0.4.0
6
10
  -----
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- releasinator (0.4.0)
4
+ releasinator (0.4.1)
5
5
  colorize (~> 0.7)
6
6
  configatron (~> 4.5)
7
7
  json (~> 1.8)
data/LICENSE CHANGED
@@ -1,156 +1,23 @@
1
- Apache License
1
+ All files are released under the MIT License:
2
2
 
3
- Version 2.0, January 2004
3
+ The MIT License (MIT)
4
4
 
5
- http://www.apache.org/licenses/
5
+ Copyright (c) 2013-2016 PayPal Holdings, Inc.
6
6
 
7
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
8
13
 
9
- 1. Definitions.
10
-
11
- "License" shall mean the terms and conditions for use, reproduction, and
12
- distribution as defined by Sections 1 through 9 of this document.
13
-
14
- "Licensor" shall mean the copyright owner or entity authorized by the copyright
15
- owner that is granting the License.
16
-
17
- "Legal Entity" shall mean the union of the acting entity and all other entities
18
- that control, are controlled by, or are under common control with that entity.
19
- For the purposes of this definition, "control" means (i) the power, direct or
20
- indirect, to cause the direction or management of such entity, whether by
21
- contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity exercising
25
- permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications, including
28
- but not limited to software source code, documentation source, and
29
- configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical transformation or
32
- translation of a Source form, including but not limited to compiled object
33
- code, generated documentation, and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or Object form,
36
- made available under the License, as indicated by a copyright notice that is
37
- included in or attached to the work (an example is provided in the Appendix
38
- below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object form, that
41
- is based on (or derived from) the Work and for which the editorial revisions,
42
- annotations, elaborations, or other modifications represent, as a whole, an
43
- original work of authorship. For the purposes of this License, Derivative
44
- Works shall not include works that remain separable from, or merely link (or
45
- bind by name) to the interfaces of, the Work and Derivative Works thereof.
46
-
47
- "Contribution" shall mean any work of authorship, including the original
48
- version of the Work and any modifications or additions to that Work or
49
- Derivative Works thereof, that is intentionally submitted to Licensor for
50
- inclusion in the Work by the copyright owner or by an individual or Legal
51
- Entity authorized to submit on behalf of the copyright owner. For the purposes
52
- of this definition, "submitted" means any form of electronic, verbal, or
53
- written communication sent to the Licensor or its representatives, including
54
- but not limited to communication on electronic mailing lists, source code
55
- control systems, and issue tracking systems that are managed by, or on behalf
56
- of, the Licensor for the purpose of discussing and improving the Work, but
57
- excluding communication that is conspicuously marked or otherwise designated in
58
- writing by the copyright owner as "Not a Contribution."
59
-
60
- "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
61
- of whom a Contribution has been received by Licensor and subsequently
62
- incorporated within the Work.
63
-
64
- 2. Grant of Copyright License. Subject to the terms and conditions of this
65
- License, each Contributor hereby grants to You a perpetual, worldwide, non-
66
- exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce,
67
- prepare Derivative Works of, publicly display, publicly perform, sublicense,
68
- and distribute the Work and such Derivative Works in Source or Object form.
69
-
70
- 3. Grant of Patent License. Subject to the terms and conditions of this
71
- License, each Contributor hereby grants to You a perpetual, worldwide, non-
72
- exclusive, no-charge, royalty-free, irrevocable (except as stated in this
73
- section) patent license to make, have made, use, offer to sell, sell, import,
74
- and otherwise transfer the Work, where such license applies only to those
75
- patent claims licensable by such Contributor that are necessarily infringed by
76
- their Contribution(s) alone or by combination of their Contribution(s) with the
77
- Work to which such Contribution(s) was submitted. If You institute patent
78
- litigation against any entity (including a cross-claim or counterclaim in a
79
- lawsuit) alleging that the Work or a Contribution incorporated within the Work
80
- constitutes direct or contributory patent infringement, then any patent
81
- licenses granted to You under this License for that Work shall terminate as of
82
- the date such litigation is filed.
83
-
84
- 4. Redistribution. You may reproduce and distribute copies of the Work or
85
- Derivative Works thereof in any medium, with or without modifications, and in
86
- Source or Object form, provided that You meet the following conditions:
87
-
88
- You must give any other recipients of the Work or Derivative Works a copy of
89
- this License; and You must cause any modified files to carry prominent notices
90
- stating that You changed the files; and You must retain, in the Source form of
91
- any Derivative Works that You distribute, all copyright, patent, trademark, and
92
- attribution notices from the Source form of the Work, excluding those notices
93
- that do not pertain to any part of the Derivative Works; and If the Work
94
- includes a "NOTICE" text file as part of its distribution, then any Derivative
95
- Works that You distribute must include a readable copy of the attribution
96
- notices contained within such NOTICE file, excluding those notices that do not
97
- pertain to any part of the Derivative Works, in at least one of the following
98
- places: within a NOTICE text file distributed as part of the Derivative Works;
99
- within the Source form or documentation, if provided along with the Derivative
100
- Works; or, within a display generated by the Derivative Works, if and wherever
101
- such third-party notices normally appear. The contents of the NOTICE file are
102
- for informational purposes only and do not modify the License. You may add Your
103
- own attribution notices within Derivative Works that You distribute, alongside
104
- or as an addendum to the NOTICE text from the Work, provided that such
105
- additional attribution notices cannot be construed as modifying the License.
106
-
107
- You may add Your own copyright statement to Your modifications and may provide
108
- additional or different license terms and conditions for use, reproduction, or
109
- distribution of Your modifications, or for any such Derivative Works as a
110
- whole, provided Your use, reproduction, and distribution of the Work otherwise
111
- complies with the conditions stated in this License.
112
-
113
- 5. Submission of Contributions. Unless You explicitly state otherwise, any
114
- Contribution intentionally submitted for inclusion in the Work by You to the
115
- Licensor shall be under the terms and conditions of this License, without any
116
- additional terms or conditions. Notwithstanding the above, nothing herein shall
117
- supersede or modify the terms of any separate license agreement you may have
118
- executed with Licensor regarding such Contributions.
119
-
120
- 6. Trademarks. This License does not grant permission to use the trade names,
121
- trademarks, service marks, or product names of the Licensor, except as required
122
- for reasonable and customary use in describing the origin of the Work and
123
- reproducing the content of the NOTICE file.
124
-
125
- 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
126
- writing, Licensor provides the Work (and each Contributor provides its
127
- Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
128
- KIND, either express or implied, including, without limitation, any warranties
129
- or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
130
- PARTICULAR PURPOSE. You are solely responsible for determining the
131
- appropriateness of using or redistributing the Work and assume any risks
132
- associated with Your exercise of permissions under this License.
133
-
134
- 8. Limitation of Liability. In no event and under no legal theory, whether in
135
- tort (including negligence), contract, or otherwise, unless required by
136
- applicable law (such as deliberate and grossly negligent acts) or agreed to in
137
- writing, shall any Contributor be liable to You for damages, including any
138
- direct, indirect, special, incidental, or consequential damages of any
139
- character arising as a result of this License or out of the use or inability
140
- to use the Work (including but not limited to damages for loss of goodwill,
141
- work stoppage, computer failure or malfunction, or any and all other commercial
142
- damages or losses), even if such Contributor has been advised of the
143
- possibility of such damages.
144
-
145
- 9. Accepting Warranty or Additional Liability. While redistributing the Work or
146
- Derivative Works thereof, You may choose to offer, and charge a fee for,
147
- acceptance of support, warranty, indemnity, or other liability obligations
148
- and/or rights consistent with this License. However, in accepting such
149
- obligations, You may act only on Your own behalf and on Your sole
150
- responsibility, not on behalf of any other Contributor, and only if You agree
151
- to indemnify, defend, and hold each Contributor harmless for any liability
152
- incurred by, or claims asserted against, such Contributor by reason of your
153
- accepting any such warranty or additional liability.
154
-
155
- END OF TERMS AND CONDITIONS
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
156
16
 
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
data/README.md CHANGED
@@ -10,21 +10,13 @@ When automating an SDK release process, many teams and languages have different
10
10
 
11
11
  The releasinator corrects this by enforcing standard must-have release files, being configurable where necessary, and reducing the ramp-up hurdle.
12
12
 
13
- ## Making it work
14
-
15
- ### Install
16
-
17
- 1. Clone this repo
18
- 2. Run `bundle install` from terminal. It should download dependencies.
19
-
20
- ### Setup
21
-
22
- 1. Set the environment variable `GITHUB_TOKEN` with a [generated personal access token](https://github.com/settings/tokens) with `repo` scope.
13
+ ## Getting started
23
14
 
24
15
  ### Usage
25
16
 
26
- 1. Add releasinator dependency to `Gemfile` or `.gemspec`
27
- 2. add a `Rakefile` with the following contents:
17
+ 1. Install ruby & rubygems.
18
+ 1. Add releasinator dependency to `Gemfile` or `.gemspec`.
19
+ 2. Add or append a `Rakefile` with the following contents:
28
20
 
29
21
  ```ruby
30
22
  spec = Gem::Specification.find_by_name 'releasinator'
@@ -83,10 +75,33 @@ release
83
75
 
84
76
  ```
85
77
 
78
+ ### Config
79
+
80
+ A default config file is created when running any releasinator rake task for the first time. This file includes placeholders for all the mandatory config items. Below is the full list of config options.
81
+
82
+ #### Required `.releasinator.rb` config options:
83
+
84
+ 1. `configatron.product_name`: The name of the sdk for usage in various commit statements.
85
+ 2. `configatron.prerelease_checklist_items`: List of items to confirm from the person releasing.
86
+ 3. `configatron.build_method`: The command that builds the sdk.
87
+ 4. `configatron.publish_to_package_manager_method`: The method that publishes the sdk to the package manager.
88
+ 5. `configatron.wait_for_package_manager_method`: The method that waits for the package manager to be done.
89
+ 6. `configatron.release_to_github`: True if publishing the root repo to GitHub.
90
+
91
+ #### Optional `.releasinator.rb` config options:
92
+
93
+ 1. `configatron.use_git_flow`: True if the root repo's git branching strategy follows git flow (develop/release/master).
94
+ 2. `configatron.base_docs_dir`: The directory where all distributed docs are found. If not specified, the default is `.`.
95
+ 3. `configatron.custom_validation_methods`: List of methods that are run as a step within `validate:all`.
96
+ 4. `configatron.downstream_repos`: List of downstream repos to push updates to. Please see documentation on the `DownstreamRepo` class.
97
+ 5. `configatron.doc_build_method`: The method that builds the docs.
98
+ 6. `configatron.doc_target_dir`: The directory where to run all git commands when publishing the docs. If not specified, the default is `.`. Generally useful if the docs are only applicable on a downstream release, rather than on the source itself.
99
+ 7. `configatron.doc_files_to_copy`: List of CopyFile objects for copying built docs into a targeted location. Please see documentation on the `CopyFile` class.
100
+
86
101
 
87
102
  ## Conventions
88
103
 
89
- The releasinator enforces certain conventions. If a filename doesn't exactly match the convention, it is renamed to match, and automatically committed. The conventions are documented below:
104
+ The releasinator enforces certain conventions. If a filename closely matches the convention, it is renamed and automatically committed. The conventions are documented below:
90
105
 
91
106
  1. `README.md`
92
107
  2. `LICENSE`: See [here](http://stackoverflow.com/questions/5678462/should-i-provide-a-license-txt-or-copying-txt-file-in-my-project) for a relevant StackOverflow post on this discussion. This project has chosen to exclude the `.txt` extension to match other popular projects, and GitHub defaults.
@@ -116,7 +131,7 @@ The releasinator enforces certain conventions. If a filename doesn't exactly ma
116
131
  1. ✓ Validate all files are committed to git (`git ls-files --others --exclude-standard`).
117
132
  1. ✓ Validate user has valid access_tokens as environment variables for all repos (public & enterprise). Public github requires `GITHUB_TOKEN`, while enterprise tokens add a modified version of their domain as a prefix. For example, github.example.com requires `GITHUB_EXAMPLE_COM_GITHUB_TOKEN`.
118
133
  1. ✓ Validate user has permissions to push to repo, and downstream repos.
119
- 1. ✓ Validate anything as defined by the configuration. Examples:
134
+ 1. ✓ Validate anything as defined by the config. Examples:
120
135
  * Compiling with the right version of the platform.
121
136
  * Upstream library dependencies are the latest available.
122
137
 
data/lib/config_hash.rb CHANGED
@@ -46,5 +46,14 @@ module Releasinator
46
46
  false
47
47
  end
48
48
 
49
+ def base_dir
50
+ return self[:base_docs_dir] if self.has_key?(:base_docs_dir)
51
+ '.'
52
+ end
53
+
54
+ def doc_target_dir
55
+ return self[:doc_target_dir] if self.has_key?(:doc_target_dir)
56
+ '.'
57
+ end
49
58
  end
50
59
  end
data/lib/copy_file.rb CHANGED
@@ -2,9 +2,12 @@ module Releasinator
2
2
  class CopyFile
3
3
  attr_reader :source_file, :target_name, :target_dir
4
4
  def initialize(source_file, target_name, target_dir)
5
- @source_file = source_file
6
- @target_name = target_name
7
- @target_dir = target_dir
5
+ @source_file = source_file # The source file or directory name, including directory.
6
+ @source_file.freeze
7
+ @target_name = target_name # The target file or directory name, excluding directory.
8
+ @target_name.freeze
9
+ @target_dir = target_dir # The target directory name.
10
+ @target_dir.freeze
8
11
  end
9
12
  end
10
13
  end
@@ -3,7 +3,9 @@ module Releasinator
3
3
  attr_reader :version, :changelog
4
4
  def initialize(version, changelog)
5
5
  @version = version
6
+ @version.freeze
6
7
  @changelog = changelog
8
+ @changelog.freeze
7
9
  end
8
10
  end
9
11
  end
@@ -4,7 +4,7 @@ DEFAULT_CONFIG = %(configatron.product_name = "test product"
4
4
  configatron.prerelease_checklist_items = [
5
5
  ]
6
6
 
7
- # The directory where all distributed docs are. Default is '.'
7
+ # The directory where all distributed docs are. If not specified, the default is `.`.
8
8
  # configatron.base_docs_dir = '.'
9
9
 
10
10
  def build_method
@@ -25,9 +25,9 @@ configatron.publish_to_package_manager_method = method(:publish_to_package_manag
25
25
  def wait_for_package_manager(version)
26
26
  end
27
27
 
28
- # The method that waits for the package manager to be done. Required
28
+ # The method that waits for the package manager to be done. Required.
29
29
  configatron.wait_for_package_manager_method = method(:wait_for_package_manager)
30
30
 
31
- # Whether to publish the root repo to GitHub. Required.
31
+ # True if publishing the root repo to GitHub. Required.
32
32
  configatron.release_to_github = true
33
33
  )
data/lib/downstream.rb CHANGED
@@ -24,13 +24,13 @@ module Releasinator
24
24
  end
25
25
 
26
26
  def reset(args)
27
- if @releasinator_config.has_key?(:downstream_repos)
27
+ if @releasinator_config.has_key?(:downstream_repos)
28
28
  get_downstream_repos(args[:downstream_repo_index]).each do |downstream_repo, index|
29
29
  puts "resetting downstream_repo[#{index}]: #{downstream_repo.url}" if @releasinator_config[:verbose]
30
30
  Dir.mkdir(DOWNSTREAM_REPOS) unless File.exist?(DOWNSTREAM_REPOS)
31
31
  Dir.chdir(DOWNSTREAM_REPOS) do
32
32
  CommandProcessor.command("git clone --origin origin #{downstream_repo.url} #{downstream_repo.name}") unless File.exist?(downstream_repo.name)
33
-
33
+
34
34
  Dir.chdir(downstream_repo.name) do
35
35
  GitUtil.reset_repo(downstream_repo.branch)
36
36
 
@@ -53,7 +53,7 @@ module Releasinator
53
53
  puts "preparing downstream_repo[#{index}]: #{downstream_repo.url}" if @releasinator_config[:verbose]
54
54
 
55
55
  root_dir = Dir.pwd.strip
56
- copy_from_dir = root_dir + "/" + get_base_dir()
56
+ copy_from_dir = root_dir + "/" + @releasinator_config.base_dir
57
57
 
58
58
  Dir.chdir(DOWNSTREAM_REPOS) do
59
59
  Dir.chdir(downstream_repo.name) do
@@ -158,7 +158,7 @@ module Releasinator
158
158
  else
159
159
  GitUtil.push_branch("master")
160
160
  GitUtil.push_tag(@current_release.version)
161
- Publisher.new(@releasinator_config).publish_draft(downstream_repo.url, @current_release) unless ! downstream_repo.release_to_github
161
+ Publisher.new(@releasinator_config).publish(downstream_repo.url, @current_release) unless ! downstream_repo.release_to_github
162
162
  end
163
163
  end
164
164
  end
@@ -198,4 +198,4 @@ module Releasinator
198
198
  repos_to_iterate_over
199
199
  end
200
200
  end
201
- end
201
+ end
@@ -2,17 +2,20 @@ module Releasinator
2
2
  class DownstreamRepo
3
3
  attr_reader :name, :url, :branch, :options
4
4
  def initialize(name, url, branch, options={})
5
- @name = name
6
- @url = url
7
- @branch = branch
8
- @options = options
9
- # options are:
10
- # :new_branch_name (if set, ignores :release_to_github)
11
- # :release_to_github
12
- # :files_to_copy
13
- # :full_file_sync
14
- # :post_copy_methods
15
- # :build_methods
5
+ @name = name # The desired name of the repo. This is only used for the directory in the `downstream_repos` folder.
6
+ @name.freeze
7
+ @url = url # The GitHub repo location.
8
+ @url.freeze
9
+ @branch = branch # The git branch on which to base new changes.
10
+ @branch.freeze
11
+ @options = options # hash of any of the following options:
12
+ @options.freeze
13
+ # :new_branch_name # The name of the new branch to create. If this is set, :release_to_github is ignored.
14
+ # :release_to_github # True if publishing the root repo to GitHub.
15
+ # :files_to_copy # List of CopyFile objects for copying files into downstream. Please see documentation on the `CopyFile` class.
16
+ # :full_file_sync # True if the downstream repo should just be a straight copy of source. Setting this to true removes all files before replacing them all with those specified in base_docs_dir.
17
+ # :post_copy_methods # List of methods to run immediately after copying all files.
18
+ # :build_methods # List of methods to run immediately after copying files. Useful to test whether the new downstream changes now compile.
16
19
  end
17
20
 
18
21
  def full_file_sync
data/lib/github_repo.rb CHANGED
@@ -25,6 +25,11 @@ module Releasinator
25
25
  @repo = slash_split.last.split(".git").first
26
26
  end
27
27
 
28
+ @url.freeze
29
+ @org.freeze
30
+ @repo.freeze
31
+ @domain.freeze
32
+
28
33
  if @domain == "github.com"
29
34
  check_token("GITHUB_TOKEN")
30
35
  @client = Octokit::Client.new(:access_token => ENV["GITHUB_TOKEN"])
data/lib/publisher.rb CHANGED
@@ -9,7 +9,7 @@ module Releasinator
9
9
  @config = config
10
10
  end
11
11
 
12
- def publish_draft(repo_url, release)
12
+ def publish(repo_url, release)
13
13
  github_repo = GitHubRepo.new(repo_url)
14
14
 
15
15
  begin
@@ -17,9 +17,7 @@ module Releasinator
17
17
  github_release = github_repo.client.create_release "#{github_repo.org}/#{github_repo.repo}",
18
18
  release.version,
19
19
  :name => release.version,
20
- :body => release.changelog,
21
- :draft => true,
22
- :prerelease => false
20
+ :body => release.changelog
23
21
  puts github_release.inspect if @config[:trace]
24
22
  rescue => error
25
23
  #This will fail if the user does not have push permissions.
@@ -1,3 +1,3 @@
1
1
  module Releasinator
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -16,28 +16,24 @@ include Releasinator
16
16
 
17
17
  DOWNSTREAM_REPOS = "downstream_repos"
18
18
 
19
- def get_base_dir
20
- if @releasinator_config.has_key?(:base_docs_dir)
21
- @releasinator_config[:base_docs_dir]
22
- else
23
- '.'
24
- end
25
- end
26
-
27
19
  desc "read and validate the config, adding one if not found"
28
20
  task :config do
29
21
  @releasinator_config = ConfigHash.new(verbose == true, Rake.application.options.trace == true)
22
+ @releasinator_config.freeze
30
23
  @validator = Validator.new(@releasinator_config)
24
+ @validator.freeze
31
25
  @validator.validate_config
32
26
  end
33
27
 
34
28
  namespace :validate do
35
29
  desc "validate the presence, formatting, and semver sequence of CHANGELOG.md"
36
30
  task :changelog => :config do
37
- @current_release = @validator.validate_changelog(get_base_dir(), DOWNSTREAM_REPOS)
31
+ @current_release = @validator.validate_changelog(DOWNSTREAM_REPOS)
32
+ @current_release.freeze
38
33
  @downstream = Downstream.new(@releasinator_config, @validator, @current_release)
34
+ @downstream.freeze
39
35
  end
40
-
36
+
41
37
  desc "validate that git is the correct version"
42
38
  task :releasinator_version => :config do
43
39
  @validator.validate_releasinator_version
@@ -66,31 +62,31 @@ namespace :validate do
66
62
 
67
63
  desc "validate the presence of README.md, renaming a similar file if found"
68
64
  task :readme => :config do
69
- @validator.validate_exist(".", "README.md", DOWNSTREAM_REPOS)
70
- @validator.validate_exist(get_base_dir(), ".gitignore", DOWNSTREAM_REPOS) if '.' != get_base_dir()
65
+ @validator.validate_exist('.', "README.md", DOWNSTREAM_REPOS)
66
+ @validator.validate_exist(@releasinator_config.base_dir, "README.md", DOWNSTREAM_REPOS) if '.' != @releasinator_config.base_dir
71
67
  end
72
68
 
73
69
  desc "validate the presence of LICENSE, renaming a similar file if found - also validates that its referenced from README.md"
74
70
  task :license => :config do
75
- @validator.validate_exist(get_base_dir(), "LICENSE", DOWNSTREAM_REPOS)
76
- @validator.validate_referenced_in_readme(get_base_dir(), "LICENSE")
71
+ @validator.validate_exist(@releasinator_config.base_dir, "LICENSE", DOWNSTREAM_REPOS)
72
+ @validator.validate_referenced_in_readme("LICENSE")
77
73
  end
78
74
 
79
75
  desc "validate the presence of CONTRIBUTING.md, renaming a similar file if found - also validates that its referenced from README.md"
80
76
  task :contributing => :config do
81
- @validator.validate_exist(get_base_dir(), "CONTRIBUTING.md", DOWNSTREAM_REPOS)
82
- @validator.validate_referenced_in_readme(get_base_dir(), "CONTRIBUTING.md")
77
+ @validator.validate_exist(@releasinator_config.base_dir, "CONTRIBUTING.md", DOWNSTREAM_REPOS)
78
+ @validator.validate_referenced_in_readme("CONTRIBUTING.md")
83
79
  end
84
80
 
85
81
  desc "validate the presence of .github/ISSUE_TEMPLATE.md"
86
82
  task :issue_template => :config do
87
- @validator.validate_exist(get_base_dir(), ".github/ISSUE_TEMPLATE.md", DOWNSTREAM_REPOS)
83
+ @validator.validate_exist(@releasinator_config.base_dir, ".github/ISSUE_TEMPLATE.md", DOWNSTREAM_REPOS)
88
84
  end
89
85
 
90
86
  desc "validate the presence of .gitignore, adding any appropriate releasinator lines if necessary"
91
87
  task :gitignore => :config do
92
88
  @validator.validate_exist('.', ".gitignore", DOWNSTREAM_REPOS)
93
- @validator.validate_exist(get_base_dir(), ".gitignore", DOWNSTREAM_REPOS) if '.' != get_base_dir()
89
+ @validator.validate_exist(@releasinator_config.base_dir, ".gitignore", DOWNSTREAM_REPOS) if '.' != @releasinator_config.base_dir
94
90
  if @releasinator_config.has_key?(:downstream_repos)
95
91
  @validator.validate_gitignore_contents("#{DOWNSTREAM_REPOS}/")
96
92
  end
@@ -124,8 +120,8 @@ namespace :validate do
124
120
  end
125
121
 
126
122
  desc "validate all"
127
- task :all =>
128
- [
123
+ task :all =>
124
+ [
129
125
  :paths,
130
126
  :git_version,
131
127
  :gitignore,
@@ -165,7 +161,7 @@ namespace :local do
165
161
  end
166
162
 
167
163
  desc "tag the local repo"
168
- task :tag => [:config, :"validate:changelog"] do
164
+ task :tag => [:config, :"validate:changelog"] do
169
165
  GitUtil.tag(@current_release.version, @current_release.changelog)
170
166
  end
171
167
 
@@ -206,7 +202,9 @@ namespace :local do
206
202
  end
207
203
  GitUtil.push_tag(@current_release.version)
208
204
  if @releasinator_config[:release_to_github]
209
- Publisher.new(@releasinator_config).publish_draft(GitUtil.repo_url, @current_release)
205
+ # TODO - check that the tag exists
206
+ CommandProcessor.command("sleep 5")
207
+ Publisher.new(@releasinator_config).publish(GitUtil.repo_url, @current_release)
210
208
  end
211
209
 
212
210
  if @releasinator_config.has_key? :post_push_methods
@@ -296,10 +294,7 @@ namespace :docs do
296
294
  if @releasinator_config.has_key?(:doc_files_to_copy)
297
295
  root_dir = Dir.pwd.strip
298
296
 
299
- doc_target_dir = "."
300
- doc_target_dir = @releasinator_config[:doc_target_dir] if @releasinator_config.has_key?(:doc_target_dir)
301
-
302
- Dir.chdir(doc_target_dir) do
297
+ Dir.chdir(@releasinator_config.doc_target_dir) do
303
298
  current_branch = GitUtil.get_current_branch()
304
299
 
305
300
  GitUtil.init_gh_pages()
@@ -323,14 +318,11 @@ namespace :docs do
323
318
  desc "push gh-pages branch"
324
319
  task :push => [:config] do
325
320
  if @releasinator_config.has_key?(:doc_build_method)
326
- doc_target_dir = "."
327
- doc_target_dir = @releasinator_config[:doc_target_dir] if @releasinator_config.has_key?(:doc_target_dir)
328
-
329
- Dir.chdir(doc_target_dir) do
321
+ Dir.chdir(@releasinator_config.doc_target_dir) do
330
322
  current_branch = GitUtil.get_current_branch()
331
323
  CommandProcessor.command("git checkout gh-pages")
332
324
  GitUtil.push_branch("gh-pages")
333
- # switch back to previous branch
325
+ # switch back to previous branch
334
326
  CommandProcessor.command("git checkout #{current_branch}")
335
327
  end
336
328
  Printer.success("Docs pushed.")
data/lib/validator.rb CHANGED
@@ -54,11 +54,11 @@ module Releasinator
54
54
  end
55
55
  end
56
56
 
57
- def validate_changelog(base_dir, downstream_dir)
58
- validate_base_dir base_dir
59
- validate_exist(base_dir, "CHANGELOG.md", downstream_dir, ["release_notes.md"])
57
+ def validate_changelog(downstream_dir)
58
+ validate_base_dir
59
+ validate_exist(@releasinator_config.base_dir, "CHANGELOG.md", downstream_dir, ["release_notes.md"])
60
60
 
61
- changelog_contents = get_changelog_contents(base_dir)
61
+ changelog_contents = get_changelog_contents
62
62
  ValidatorChangelog.new(@releasinator_config).validate_changelog_contents(changelog_contents)
63
63
  end
64
64
 
@@ -166,27 +166,31 @@ module Releasinator
166
166
  false
167
167
  end
168
168
 
169
- def validate_referenced_in_readme(base_dir, filename)
170
- validate_base_dir base_dir
171
- Dir.chdir(base_dir) do
169
+ def validate_referenced_in_readme(filename)
170
+ validate_base_dir
171
+ Dir.chdir(@releasinator_config.base_dir) do
172
172
  File.open("README.md", "r") do |f|
173
173
  f.each_line do |line|
174
174
  if line.include? "(#{filename})"
175
- Printer.success("#{filename} referenced in #{base_dir}/README.md")
175
+ Printer.success("#{filename} referenced in #{@releasinator_config.base_dir}/README.md")
176
176
  return
177
177
  end
178
178
  end
179
179
  end
180
180
  end
181
- Printer.fail("Please link to the #{filename} file somewhere in #{base_dir}/README.md.")
181
+ Printer.fail("Please link to the #{filename} file somewhere in #{@releasinator_config.base_dir}/README.md.")
182
182
  abort()
183
183
  end
184
184
 
185
- def validate_exist(base_dir, expected_file_name, downstream_dir, alternate_names=[])
186
- validate_base_dir base_dir
187
- Dir.chdir(base_dir) do
185
+ def validate_exist(dir, expected_file_name, downstream_dir, alternate_names=[])
186
+ if !File.exist? dir
187
+ Printer.fail("Directory #{dir} not found.")
188
+ abort()
189
+ end
190
+
191
+ Dir.chdir(dir) do
188
192
  if !File.exist?(expected_file_name)
189
- puts "#{base_dir}/#{expected_file_name} not found. Searching for similar files.".yellow
193
+ puts "#{dir}/#{expected_file_name} not found. Searching for similar files.".yellow
190
194
 
191
195
  # search for files that are somewhat similar to the file being searched, ignoring case
192
196
  filename_prefix = expected_file_name[0,5]
@@ -194,23 +198,23 @@ module Releasinator
194
198
  num_similar_files = similar_files.split.count
195
199
  puts similar_files
196
200
  if num_similar_files == 1
197
- Printer.check_proceed("Found a single similar file: #{similar_files}. Do you want to rename this to the expected #{expected_file_name}?","Please place #{base_dir}/#{expected_file_name}")
201
+ Printer.check_proceed("Found a single similar file: #{similar_files}. Do you want to rename this to the expected #{expected_file_name}?","Please place #{dir}/#{expected_file_name}")
198
202
  rename_file(similar_files, expected_file_name)
199
203
  elsif num_similar_files > 1
200
204
  Printer.fail("Found more than 1 file similar to #{expected_file_name}. Please rename one, and optionally remove the others to not confuse users.")
201
205
  abort()
202
206
  elsif !rename_alternate_name(expected_file_name, alternate_names)
203
- Printer.fail("Please place #{base_dir}/#{expected_file_name}.")
207
+ Printer.fail("Please place #{dir}/#{expected_file_name}.")
204
208
  abort()
205
209
  end
206
210
  end
207
- Printer.success("#{base_dir}/#{expected_file_name} found.")
211
+ Printer.success("#{dir}/#{expected_file_name} found.")
208
212
  end
209
213
  end
210
214
 
211
- def validate_base_dir(base_dir)
212
- if !File.exist? base_dir
213
- Printer.fail("Directory specified by base_docs_dir '#{base_dir}' not found. Please fix the config, or add this directory.")
215
+ def validate_base_dir()
216
+ if !File.exist? @releasinator_config.base_dir
217
+ Printer.fail("Directory specified by base_docs_dir '#{@releasinator_config.base_dir}' not found. Please fix the config, or add this directory.")
214
218
  abort()
215
219
  end
216
220
  end
@@ -371,9 +375,9 @@ module Releasinator
371
375
  false
372
376
  end
373
377
 
374
- def get_changelog_contents(base_dir)
375
- validate_base_dir base_dir
376
- Dir.chdir(base_dir) do
378
+ def get_changelog_contents()
379
+ validate_base_dir
380
+ Dir.chdir(@releasinator_config.base_dir) do
377
381
  open('CHANGELOG.md').read
378
382
  end
379
383
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releasinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PayPal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler