gitlab-release-tools 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.
- checksums.yaml +7 -0
- data/.env.example +2 -0
- data/.env.gitlab +2 -0
- data/.gitignore +14 -0
- data/.rakeTasks +7 -0
- data/.rspec +3 -0
- data/.travis.yml +9 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +21 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/gitlab-release-tools +14 -0
- data/gitlab-release-tools.gemspec +42 -0
- data/lib/gitlab/release/api_client.rb +24 -0
- data/lib/gitlab/release/changelog/entries.rb +34 -0
- data/lib/gitlab/release/changelog/entry.rb +32 -0
- data/lib/gitlab/release/changelog/generator.rb +117 -0
- data/lib/gitlab/release/manager.rb +28 -0
- data/lib/gitlab/release/version.rb +5 -0
- metadata +151 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 20787d80dd2afc4ea5def81e040bf317891a2bfb5821c720b6998b97d0b1fc45
|
|
4
|
+
data.tar.gz: f858b5b180f4669929d2abc1f29c866929f6ffebdfc3ace9d329dc86f8cffb90
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 914e76075bd497179459a4358db51efc572d344ecf0e2ed2a62d2f41e88af04461a54eb76123f9bcc2ad150a8b45464fe938af340214a9ad6cdac90f4e0db574
|
|
7
|
+
data.tar.gz: ac452f8aee493b030cb8f642b55dba855c6714bd3c02e22d40354736d46f40dffbed8a4bb8065defa367758a58355332d959d8ab90f72316013468d6e94cd878
|
data/.env.example
ADDED
data/.env.gitlab
ADDED
data/.gitignore
ADDED
data/.rakeTasks
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
|
3
|
+
You are allowed to:
|
|
4
|
+
1. Remove rake task
|
|
5
|
+
2. Add existing rake tasks
|
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build gitlab-release-tools-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install gitlab-release-tools-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install gitlab-release-tools-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push gitlab-release-tools-0.1.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
gitlab-release-tools (0.1.0)
|
|
5
|
+
gitlab (~> 4.12.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.7.0)
|
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
12
|
+
crack (0.4.3)
|
|
13
|
+
safe_yaml (~> 1.0.0)
|
|
14
|
+
diff-lcs (1.3)
|
|
15
|
+
dotenv (2.7.5)
|
|
16
|
+
gitlab (4.12.0)
|
|
17
|
+
httparty (~> 0.14, >= 0.14.0)
|
|
18
|
+
terminal-table (~> 1.5, >= 1.5.1)
|
|
19
|
+
hashdiff (1.0.0)
|
|
20
|
+
httparty (0.17.1)
|
|
21
|
+
mime-types (~> 3.0)
|
|
22
|
+
multi_xml (>= 0.5.2)
|
|
23
|
+
mime-types (3.3)
|
|
24
|
+
mime-types-data (~> 3.2015)
|
|
25
|
+
mime-types-data (3.2019.1009)
|
|
26
|
+
multi_xml (0.6.0)
|
|
27
|
+
public_suffix (4.0.1)
|
|
28
|
+
rake (10.5.0)
|
|
29
|
+
rspec (3.8.0)
|
|
30
|
+
rspec-core (~> 3.8.0)
|
|
31
|
+
rspec-expectations (~> 3.8.0)
|
|
32
|
+
rspec-mocks (~> 3.8.0)
|
|
33
|
+
rspec-core (3.8.2)
|
|
34
|
+
rspec-support (~> 3.8.0)
|
|
35
|
+
rspec-expectations (3.8.5)
|
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
37
|
+
rspec-support (~> 3.8.0)
|
|
38
|
+
rspec-mocks (3.8.2)
|
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
40
|
+
rspec-support (~> 3.8.0)
|
|
41
|
+
rspec-support (3.8.3)
|
|
42
|
+
safe_yaml (1.0.5)
|
|
43
|
+
terminal-table (1.8.0)
|
|
44
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
45
|
+
unicode-display_width (1.6.0)
|
|
46
|
+
webmock (3.7.6)
|
|
47
|
+
addressable (>= 2.3.6)
|
|
48
|
+
crack (>= 0.3.2)
|
|
49
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
50
|
+
|
|
51
|
+
PLATFORMS
|
|
52
|
+
ruby
|
|
53
|
+
x64-mingw32
|
|
54
|
+
|
|
55
|
+
DEPENDENCIES
|
|
56
|
+
bundler (~> 2.0)
|
|
57
|
+
dotenv
|
|
58
|
+
gitlab-release-tools!
|
|
59
|
+
rake (~> 10.0)
|
|
60
|
+
rspec (~> 3.0)
|
|
61
|
+
webmock
|
|
62
|
+
|
|
63
|
+
BUNDLED WITH
|
|
64
|
+
2.0.2
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Andrea Del Fante
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# gitlab-release-tools
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
Add this line to your application's Gemfile:
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
gem 'gitlab-release-tools'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install gitlab-changelog-generator
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## Development
|
|
24
|
+
|
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
26
|
+
|
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
28
|
+
|
|
29
|
+
## Contributing
|
|
30
|
+
|
|
31
|
+
Bug reports and pull requests are welcome.
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "gitlab/changelog/generator"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "gitlab/release/changelog/generator"
|
|
4
|
+
require 'dotenv'
|
|
5
|
+
|
|
6
|
+
Dotenv.load('../.env')
|
|
7
|
+
|
|
8
|
+
endpoint = ENV["GITLAB_BASE_URL"]
|
|
9
|
+
private_token = ENV["PRIVATE_TOKEN"]
|
|
10
|
+
|
|
11
|
+
generator = Gitlab::Release::Changelog::Generator.new(endpoint, private_token)
|
|
12
|
+
|
|
13
|
+
changelog = generator.changelog("1.1", project_id: 50)
|
|
14
|
+
print(changelog)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "gitlab/release/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "gitlab-release-tools"
|
|
8
|
+
spec.version = Gitlab::Release::VERSION
|
|
9
|
+
spec.authors = ["Andrea Del Fante"]
|
|
10
|
+
spec.email = ["andreadelfante94@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Automation gitlab release tools made simple."
|
|
13
|
+
spec.description = "Automation gitlab release tools from MR and issues for your new versions."
|
|
14
|
+
spec.homepage = "https://github.com/andreadelfante/gitlab-release-tools"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
if spec.respond_to?(:metadata)
|
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/andreadelfante/gitlab-release-tools"
|
|
20
|
+
#spec.metadata["changelog_uri"] = ""
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
+
"public gem pushes."
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
30
|
+
end
|
|
31
|
+
spec.bindir = "exe"
|
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
33
|
+
spec.require_paths = ["lib"]
|
|
34
|
+
|
|
35
|
+
spec.add_runtime_dependency "gitlab", "~> 4.12.0"
|
|
36
|
+
|
|
37
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
40
|
+
spec.add_development_dependency "dotenv"
|
|
41
|
+
spec.add_development_dependency 'webmock'
|
|
42
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'gitlab'
|
|
2
|
+
|
|
3
|
+
module Gitlab
|
|
4
|
+
module Release
|
|
5
|
+
class ApiClient
|
|
6
|
+
# @param [String] endpoint API endpoint URL, default: ENV['GITLAB_API_ENDPOINT'] and falls back to ENV['CI_API_V4_URL']
|
|
7
|
+
# @param [String] private_token user's private token or OAuth2 access token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
|
|
8
|
+
def initialize(endpoint, private_token)
|
|
9
|
+
@client = Gitlab.client(
|
|
10
|
+
endpoint: endpoint,
|
|
11
|
+
private_token: private_token
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @param [String] version_name
|
|
16
|
+
# @return Array
|
|
17
|
+
protected def select_milestones(project_id, version_name)
|
|
18
|
+
@client.milestones(project_id).select do |milestone|
|
|
19
|
+
milestone.title.include?(version_name) || milestone.description.include?(version_name)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module Release
|
|
3
|
+
module Changelog
|
|
4
|
+
class Entries
|
|
5
|
+
def initialize
|
|
6
|
+
# @type [Array] elements
|
|
7
|
+
@elements = []
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# @param [Entry] element
|
|
11
|
+
def push(element)
|
|
12
|
+
@elements.push(element)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_s
|
|
16
|
+
@elements.map { |element| element.to_s }
|
|
17
|
+
.join("\n")
|
|
18
|
+
#.reject(&:empty?)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @param [String] path
|
|
22
|
+
# @param [TrueClass or FalseClass] appending default false
|
|
23
|
+
def write_on_file(path, appending = false)
|
|
24
|
+
# @type [String] changelog_string
|
|
25
|
+
changelog_string = to_s
|
|
26
|
+
|
|
27
|
+
File.open(path, appending ? "a" : "w+") do |file|
|
|
28
|
+
file.puts(changelog_string)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module Release
|
|
3
|
+
module Changelog
|
|
4
|
+
class Entry
|
|
5
|
+
attr_reader :title, :id
|
|
6
|
+
|
|
7
|
+
# @param [Integer] id
|
|
8
|
+
# @param [String] title
|
|
9
|
+
def initialize(id, title)
|
|
10
|
+
@id = id
|
|
11
|
+
@title = title
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_s
|
|
15
|
+
"[#{@id}] #{@title}"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class MergeRequest < Entry
|
|
20
|
+
def to_s
|
|
21
|
+
"- #{title} !#{id}"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class Issue < Entry
|
|
26
|
+
def to_s
|
|
27
|
+
"- #{title} ##{id}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require 'gitlab/release/api_client'
|
|
2
|
+
require 'gitlab/release/changelog/entries'
|
|
3
|
+
require 'gitlab/release/changelog/entry'
|
|
4
|
+
require 'gitlab/release/version'
|
|
5
|
+
|
|
6
|
+
module Gitlab
|
|
7
|
+
module Release
|
|
8
|
+
module Changelog
|
|
9
|
+
class Generator < ApiClient
|
|
10
|
+
# @param [String] endpoint API endpoint URL, default: ENV['GITLAB_API_ENDPOINT'] and falls back to ENV['CI_API_V4_URL']
|
|
11
|
+
# @param [String] private_token user's private token or OAuth2 access token, default: ENV['GITLAB_API_PRIVATE_TOKEN']
|
|
12
|
+
# @param [Integer] max_loop_mrs
|
|
13
|
+
# @param [Integer] max_loop_issues
|
|
14
|
+
def initialize(endpoint, private_token, max_loop_mrs = 1000, max_loop_issues = 1000)
|
|
15
|
+
@max_loops_merge_requests = max_loop_mrs
|
|
16
|
+
@max_loop_issues = max_loop_issues
|
|
17
|
+
super(endpoint, private_token)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @param [String] version_name required
|
|
21
|
+
# @param [String or Integer] project_id default ENV["CI_PROJECT_ID"]
|
|
22
|
+
# @param [TrueClass or FalseClass] include_mrs default true
|
|
23
|
+
# @param [TrueClass or FalseClass] include_issues default false
|
|
24
|
+
# @param [Array[String]] filtering_labels default []
|
|
25
|
+
# @param [Array[String]] filtering_mrs_labels default []
|
|
26
|
+
# @param [Array[String]] filtering_issues_labels default []
|
|
27
|
+
# @return [Entries]
|
|
28
|
+
def changelog(version_name, params = {})
|
|
29
|
+
project_id = params[:project_id] || ENV["CI_PROJECT_ID"]
|
|
30
|
+
include_mrs = params[:include_mrs] || true
|
|
31
|
+
include_issues = params[:include_issues] || false
|
|
32
|
+
filtering_mrs_labels = params[:filtering_mrs_labels] || params[:filtering_labels] || []
|
|
33
|
+
filtering_issue_labels = params[:filtering_issues_labels] || params[:filtering_labels] || []
|
|
34
|
+
|
|
35
|
+
entries = Entries.new
|
|
36
|
+
if include_mrs
|
|
37
|
+
changelog_from_merge_requests(entries,
|
|
38
|
+
project_id,
|
|
39
|
+
version_name,
|
|
40
|
+
filtering_mrs_labels)
|
|
41
|
+
end
|
|
42
|
+
if include_issues
|
|
43
|
+
changelog_from_issues(entries,
|
|
44
|
+
project_id,
|
|
45
|
+
version_name,
|
|
46
|
+
filtering_issue_labels)
|
|
47
|
+
end
|
|
48
|
+
entries
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# @param [Entries] entries
|
|
52
|
+
# @param [String or Integer] project_id
|
|
53
|
+
# @param [String] version_name
|
|
54
|
+
# @param Array[String] filtering_labels
|
|
55
|
+
private def changelog_from_merge_requests(entries, project_id, version_name, filtering_labels)
|
|
56
|
+
select_milestones(project_id, version_name).each do |milestone|
|
|
57
|
+
i = 1
|
|
58
|
+
all = false
|
|
59
|
+
|
|
60
|
+
while i < @max_loops_merge_requests and !all
|
|
61
|
+
merge_requests = @client.milestone_merge_requests(project_id, milestone.id, {page: i})
|
|
62
|
+
all = merge_requests.empty?
|
|
63
|
+
|
|
64
|
+
merge_requests.each do |mr|
|
|
65
|
+
if check_mr(mr, filtering_labels)
|
|
66
|
+
entries.push(MergeRequest.new(mr.iid, mr.title))
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
i += 1
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# @param [Gitlab::ObjectifiedHash] mr
|
|
76
|
+
# @param [Array[String]] filtering_labels
|
|
77
|
+
# @return [TrueClass or FalseClass]
|
|
78
|
+
private def check_mr(mr, filtering_labels)
|
|
79
|
+
mr.state == 'merged' and (filtering_labels - mr.labels).empty?
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# @param [Entries] entries
|
|
83
|
+
# @param [String or Integer] project_id
|
|
84
|
+
# @param [String] version_name
|
|
85
|
+
# @param [TrueClass or FalseClass] only_closed
|
|
86
|
+
# @param Array[String] filtering_labels
|
|
87
|
+
private def changelog_from_issues(entries, project_id, version_name, filtering_labels)
|
|
88
|
+
select_milestones(project_id, version_name).each do |milestone|
|
|
89
|
+
i = 1
|
|
90
|
+
all = false
|
|
91
|
+
|
|
92
|
+
while i < @max_loop_issues and !all
|
|
93
|
+
issues = @client.milestone_issues(project_id, milestone.id, {page: i})
|
|
94
|
+
all = issues.empty?
|
|
95
|
+
|
|
96
|
+
issues.each do |issue|
|
|
97
|
+
if check_issue(issue, filtering_labels)
|
|
98
|
+
entries.push(Issue.new(issue.id, issue.title))
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
i += 1
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# @param [Gitlab::ObjectifiedHash] issue
|
|
108
|
+
# @param [Array[String]] filtering_labels
|
|
109
|
+
# @return [TrueClass or FalseClass]
|
|
110
|
+
private def check_issue(issue, filtering_labels)
|
|
111
|
+
issue.state == 'closed' and (filtering_labels - issue.labels).empty?
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'gitlab/release/api_client'
|
|
2
|
+
|
|
3
|
+
module Gitlab
|
|
4
|
+
module Release
|
|
5
|
+
class Manager < ApiClient
|
|
6
|
+
# @param [String] tag_name
|
|
7
|
+
# @param [String] changelog
|
|
8
|
+
# @param [String or Integer] project_id default ENV["CI_PROJECT_ID"]
|
|
9
|
+
# @param [String] ref default ENV["CI_COMMIT_SHA"]
|
|
10
|
+
def define_tag(tag_name, changelog, params = {})
|
|
11
|
+
project_id = params[:project_id] || ENV["CI_PROJECT_ID"]
|
|
12
|
+
ref = params[:ref] || ENV["CI_COMMIT_SHA"]
|
|
13
|
+
|
|
14
|
+
@client.create_tag(project_id, tag_name, ref, '', changelog)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# @param [String] version_name
|
|
18
|
+
# @param [String or Integer] project_id default ENV["CI_PROJECT_ID"]
|
|
19
|
+
def close_milestones(version_name, params = {})
|
|
20
|
+
project_id = params[:project_id] || ENV["CI_PROJECT_ID"]
|
|
21
|
+
|
|
22
|
+
select_milestones(project_id, version_name).each do |milestone|
|
|
23
|
+
@client.edit_milestone(project_id, milestone.id, state_event: 'close')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: gitlab-release-tools
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrea Del Fante
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-11-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: gitlab
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 4.12.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 4.12.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '10.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '10.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rspec
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: dotenv
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: webmock
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: Automation gitlab release tools from MR and issues for your new versions.
|
|
98
|
+
email:
|
|
99
|
+
- andreadelfante94@gmail.com
|
|
100
|
+
executables:
|
|
101
|
+
- gitlab-release-tools
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".env.example"
|
|
106
|
+
- ".env.gitlab"
|
|
107
|
+
- ".gitignore"
|
|
108
|
+
- ".rakeTasks"
|
|
109
|
+
- ".rspec"
|
|
110
|
+
- ".travis.yml"
|
|
111
|
+
- Gemfile
|
|
112
|
+
- Gemfile.lock
|
|
113
|
+
- LICENSE
|
|
114
|
+
- README.md
|
|
115
|
+
- Rakefile
|
|
116
|
+
- bin/console
|
|
117
|
+
- bin/setup
|
|
118
|
+
- exe/gitlab-release-tools
|
|
119
|
+
- gitlab-release-tools.gemspec
|
|
120
|
+
- lib/gitlab/release/api_client.rb
|
|
121
|
+
- lib/gitlab/release/changelog/entries.rb
|
|
122
|
+
- lib/gitlab/release/changelog/entry.rb
|
|
123
|
+
- lib/gitlab/release/changelog/generator.rb
|
|
124
|
+
- lib/gitlab/release/manager.rb
|
|
125
|
+
- lib/gitlab/release/version.rb
|
|
126
|
+
homepage: https://github.com/andreadelfante/gitlab-release-tools
|
|
127
|
+
licenses:
|
|
128
|
+
- MIT
|
|
129
|
+
metadata:
|
|
130
|
+
homepage_uri: https://github.com/andreadelfante/gitlab-release-tools
|
|
131
|
+
source_code_uri: https://github.com/andreadelfante/gitlab-release-tools
|
|
132
|
+
post_install_message:
|
|
133
|
+
rdoc_options: []
|
|
134
|
+
require_paths:
|
|
135
|
+
- lib
|
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
|
+
requirements:
|
|
138
|
+
- - ">="
|
|
139
|
+
- !ruby/object:Gem::Version
|
|
140
|
+
version: '0'
|
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - ">="
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0'
|
|
146
|
+
requirements: []
|
|
147
|
+
rubygems_version: 3.0.6
|
|
148
|
+
signing_key:
|
|
149
|
+
specification_version: 4
|
|
150
|
+
summary: Automation gitlab release tools made simple.
|
|
151
|
+
test_files: []
|