fastlane-plugin-changelog_generator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +48 -0
- data/lib/fastlane/plugin/changelog_generator.rb +16 -0
- data/lib/fastlane/plugin/changelog_generator/actions/fetch_github_labels_action.rb +70 -0
- data/lib/fastlane/plugin/changelog_generator/actions/generate_changelog_action.rb +94 -0
- data/lib/fastlane/plugin/changelog_generator/actions/generate_release_changelog_action.rb +93 -0
- data/lib/fastlane/plugin/changelog_generator/actions/git_tags_action.rb +37 -0
- data/lib/fastlane/plugin/changelog_generator/helper/changelog_generator_fetcher.rb +39 -0
- data/lib/fastlane/plugin/changelog_generator/helper/changelog_generator_helper.rb +12 -0
- data/lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb +62 -0
- data/lib/fastlane/plugin/changelog_generator/helper/changelog_generator_render.rb +20 -0
- data/lib/fastlane/plugin/changelog_generator/version.rb +5 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 67daa454054c49d43152b86f2738ef1e5d52ec91
|
4
|
+
data.tar.gz: f8c16f08af744b4d7052c61ef56e7776929e6f55
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8e80c8bd71f77a33ef6e5b4441b3741c662877e11e1b910e0e4fc4c51bb18b8fbe55c983e180761754469921e6e734640a0211a578d3a15c4de777ea0a218675
|
7
|
+
data.tar.gz: 68a5ed0387357f6bbd8a745e89007111e8362b55f433b6bcb327b636b7c129923dd20d5fdd75f0eb54b4b6d5de7aa2644a49d9f43e126f59c54705f2497ab172
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Fernando Saragoca <fsaragoca@me.com>
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# changelog_generator plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-changelog_generator)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-changelog_generator`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin changelog_generator
|
11
|
+
```
|
12
|
+
|
13
|
+
## About changelog_generator
|
14
|
+
|
15
|
+
Changelog generation based on merged pull requests & tags.
|
16
|
+
|
17
|
+
## Example
|
18
|
+
|
19
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
20
|
+
|
21
|
+
## Run tests for this plugin
|
22
|
+
|
23
|
+
To run both the tests, and code style validation, run
|
24
|
+
|
25
|
+
```
|
26
|
+
rake
|
27
|
+
```
|
28
|
+
|
29
|
+
To automatically fix many of the styling issues, use
|
30
|
+
```
|
31
|
+
rubocop -a
|
32
|
+
```
|
33
|
+
|
34
|
+
## Issues and Feedback
|
35
|
+
|
36
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
37
|
+
|
38
|
+
## Troubleshooting
|
39
|
+
|
40
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
|
41
|
+
|
42
|
+
## Using `fastlane` Plugins
|
43
|
+
|
44
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
|
45
|
+
|
46
|
+
## About `fastlane`
|
47
|
+
|
48
|
+
`fastlane` is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/changelog_generator/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module ChangelogGenerator
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::ChangelogGenerator.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class FetchGithubLabelsAction < Action
|
4
|
+
module SharedValues
|
5
|
+
GENERATE_CHANGELOG_GITHUB_LABELS = :GENERATE_CHANGELOG_GITHUB_LABELS
|
6
|
+
GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS = :GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.run(params)
|
10
|
+
Actions.verify_gem!('octokit')
|
11
|
+
|
12
|
+
labels = lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_LABELS]
|
13
|
+
pull_requests = lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS]
|
14
|
+
if labels && pull_requests
|
15
|
+
UI.important "Skipping API call because labels & pull requests are cached"
|
16
|
+
return labels, pull_requests
|
17
|
+
end
|
18
|
+
|
19
|
+
api_token = params[:github_api_token]
|
20
|
+
base_branch = params[:base_branch]
|
21
|
+
project = params[:github_project]
|
22
|
+
|
23
|
+
labels, pull_requests = Helper::ChangelogGeneratorFetcher.fetch_labels(project,
|
24
|
+
base_branch,
|
25
|
+
api_token)
|
26
|
+
lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_LABELS] = labels
|
27
|
+
lane_context[SharedValues::GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS] = pull_requests
|
28
|
+
return labels, pull_requests
|
29
|
+
end
|
30
|
+
|
31
|
+
def output
|
32
|
+
[
|
33
|
+
['GENERATE_CHANGELOG_GITHUB_LABELS', 'Fetched GitHub labels'],
|
34
|
+
['GENERATE_CHANGELOG_GITHUB_PULL_REQUESTS', 'Fetched GitHub pull requests']
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.description
|
39
|
+
"Fetches GitHub for labels & merged pull requests"
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.authors
|
43
|
+
["Fernando Saragoca"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.return_value
|
47
|
+
"A tuple with an array of labels & an array of pull requests"
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.available_options
|
51
|
+
[
|
52
|
+
FastlaneCore::ConfigItem.new(key: :github_project,
|
53
|
+
env_name: 'GENERATE_CHANGELOG_GITHUB_PROJECT',
|
54
|
+
description: 'GitHub project name, including organization'),
|
55
|
+
FastlaneCore::ConfigItem.new(key: :github_api_token,
|
56
|
+
env_name: 'GENERATE_CHANGELOG_GITHUB_API_TOKEN',
|
57
|
+
description: 'API token to access GitHub API',
|
58
|
+
default_value: ENV["GITHUB_API_TOKEN"]),
|
59
|
+
FastlaneCore::ConfigItem.new(key: :base_branch,
|
60
|
+
env_name: 'GENERATE_CHANGELOG_BASE_BRANCH',
|
61
|
+
description: 'Base branch for pull requests')
|
62
|
+
]
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.is_supported?(platform)
|
66
|
+
true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class GenerateChangelogAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
labels, pull_requests = other_action.fetch_github_labels(github_project: params[:github_project],
|
6
|
+
base_branch: params[:base_branch],
|
7
|
+
github_api_token: params[:github_api_token])
|
8
|
+
|
9
|
+
tag_limit = params[:max_number_of_tags]
|
10
|
+
tags = params[:tags] || other_action.git_tags(limit: tag_limit)
|
11
|
+
releases = []
|
12
|
+
|
13
|
+
# Unreleased section
|
14
|
+
if params[:include_unreleased_section]
|
15
|
+
unreleased_section = Helper::ChangelogGeneratorRelease.new(labels, pull_requests, tags.first, nil)
|
16
|
+
releases << unreleased_section if unreleased_section.data.count > 0
|
17
|
+
end
|
18
|
+
|
19
|
+
# Between tags sections
|
20
|
+
tags.each_with_index do |tag, idx|
|
21
|
+
if idx != 0
|
22
|
+
previous_tag = tags[idx - 1]
|
23
|
+
releases << Helper::ChangelogGeneratorRelease.new(labels, pull_requests, previous_tag, tag)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Last section
|
28
|
+
if tags.count > 0 && params[:tags].nil? && (tag_limit.nil? || tags.count < tag_limit)
|
29
|
+
releases << Helper::ChangelogGeneratorRelease.new(labels, pull_requests, nil, tags.last)
|
30
|
+
end
|
31
|
+
|
32
|
+
Helper::ChangelogGeneratorRender.new(releases, labels, params).to_markdown
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.description
|
36
|
+
"Changelog generation based on merged pull requests & tags"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.authors
|
40
|
+
["Fernando Saragoca"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.return_value
|
44
|
+
"Generated changelog"
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.available_options
|
48
|
+
[
|
49
|
+
FastlaneCore::ConfigItem.new(key: :github_project,
|
50
|
+
env_name: 'GENERATE_CHANGELOG_GITHUB_PROJECT',
|
51
|
+
description: 'GitHub project name, including organization'),
|
52
|
+
FastlaneCore::ConfigItem.new(key: :github_api_token,
|
53
|
+
env_name: 'GENERATE_CHANGELOG_GITHUB_API_TOKEN',
|
54
|
+
description: 'API token to access GitHub API',
|
55
|
+
default_value: ENV["GITHUB_API_TOKEN"]),
|
56
|
+
FastlaneCore::ConfigItem.new(key: :base_branch,
|
57
|
+
env_name: 'GENERATE_CHANGELOG_BASE_BRANCH',
|
58
|
+
description: 'Base branch for pull requests'),
|
59
|
+
FastlaneCore::ConfigItem.new(key: :template,
|
60
|
+
env_name: 'GENERATE_CHANGELOG_TEMPLATE',
|
61
|
+
description: 'Template for generating changelog',
|
62
|
+
optional: true),
|
63
|
+
FastlaneCore::ConfigItem.new(key: :template_path,
|
64
|
+
env_name: 'GENERATE_CHANGELOG_TEMPLATE_PATH',
|
65
|
+
description: 'Contents of path will override `template` param',
|
66
|
+
optional: true),
|
67
|
+
FastlaneCore::ConfigItem.new(key: :tags,
|
68
|
+
env_name: 'GENERATE_CHANGELOG_TAGS',
|
69
|
+
description: 'Tags to generate changelog',
|
70
|
+
is_string: false,
|
71
|
+
optional: true),
|
72
|
+
FastlaneCore::ConfigItem.new(key: :max_number_of_tags,
|
73
|
+
env_name: 'GENERATE_CHANGELOG_MAX_NUMBER_OF_TAGS',
|
74
|
+
description: 'Number of tags to generate changelog when not filtering by tag',
|
75
|
+
is_string: false,
|
76
|
+
optional: true),
|
77
|
+
FastlaneCore::ConfigItem.new(key: :include_unreleased_section,
|
78
|
+
env_name: 'GENERATE_CHANGELOG_INCLUDE_UNRELEASED_SECTION',
|
79
|
+
description: 'Includes an unreleased section',
|
80
|
+
is_string: false,
|
81
|
+
optional: true),
|
82
|
+
FastlaneCore::ConfigItem.new(key: :output_path,
|
83
|
+
env_name: 'GENERATE_CHANGELOG_OUTPUT_PATH',
|
84
|
+
description: 'If set, will automatically write changelog to output path',
|
85
|
+
optional: true)
|
86
|
+
]
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.is_supported?(platform)
|
90
|
+
true
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class GenerateReleaseChangelogAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
tag_a = params[:tag_a] || prompt_tag("Please enter first tag: ")
|
6
|
+
tag_b = params[:tag_b]
|
7
|
+
if tag_b.nil? && params[:skip_tag_b].nil?
|
8
|
+
tag_b = prompt_tag("Please enter second tag: ", [tag_a], true)
|
9
|
+
end
|
10
|
+
|
11
|
+
labels, pull_requests = other_action.fetch_github_labels(github_project: params[:github_project],
|
12
|
+
base_branch: params[:base_branch],
|
13
|
+
github_api_token: params[:github_api_token])
|
14
|
+
|
15
|
+
release = Helper::ChangelogGeneratorRelease.new(labels, pull_requests, tag_b, tag_a)
|
16
|
+
Helper::ChangelogGeneratorRender.new([release], labels, params).to_markdown
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.prompt_tag(message = '', excluded_tags = [], allow_none = false)
|
20
|
+
no_tag_text = 'No tag'
|
21
|
+
|
22
|
+
available_tags = other_action.git_tags(limit: 10)
|
23
|
+
available_tags.reject! { |tag| excluded_tags.include?(tag) }
|
24
|
+
available_tags << no_tag_text if allow_none
|
25
|
+
|
26
|
+
if allow_none && available_tags.count == 1
|
27
|
+
UI.important("Skiping second tag because there are no tags available.")
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
|
31
|
+
tag = UI.select(message, available_tags)
|
32
|
+
tag = nil if tag == no_tag_text
|
33
|
+
tag
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.description
|
37
|
+
"Changelog generation based on merged pull requests & tags, filtered by one or two tags"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.authors
|
41
|
+
["Fernando Saragoca"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.return_value
|
45
|
+
"Generated changelog"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.available_options
|
49
|
+
[
|
50
|
+
FastlaneCore::ConfigItem.new(key: :github_project,
|
51
|
+
env_name: 'GENERATE_CHANGELOG_GITHUB_PROJECT',
|
52
|
+
description: 'GitHub project name, including organization'),
|
53
|
+
FastlaneCore::ConfigItem.new(key: :github_api_token,
|
54
|
+
env_name: 'GENERATE_CHANGELOG_GITHUB_API_TOKEN',
|
55
|
+
description: 'API token to access GitHub API',
|
56
|
+
default_value: ENV["GITHUB_API_TOKEN"]),
|
57
|
+
FastlaneCore::ConfigItem.new(key: :base_branch,
|
58
|
+
env_name: 'GENERATE_CHANGELOG_BASE_BRANCH',
|
59
|
+
description: 'Base branch for pull requests'),
|
60
|
+
FastlaneCore::ConfigItem.new(key: :template,
|
61
|
+
env_name: 'GENERATE_CHANGELOG_TEMPLATE',
|
62
|
+
description: 'Template for generating changelog',
|
63
|
+
optional: true),
|
64
|
+
FastlaneCore::ConfigItem.new(key: :template_path,
|
65
|
+
env_name: 'GENERATE_CHANGELOG_TEMPLATE_PATH',
|
66
|
+
description: 'Contents of path will override `template` param',
|
67
|
+
optional: true),
|
68
|
+
FastlaneCore::ConfigItem.new(key: :tag_a,
|
69
|
+
env_name: 'GENERATE_CHANGELOG_TAG_A',
|
70
|
+
description: 'Tag to filter pull requests',
|
71
|
+
optional: true),
|
72
|
+
FastlaneCore::ConfigItem.new(key: :tag_b,
|
73
|
+
env_name: 'GENERATE_CHANGELOG_TAG_B',
|
74
|
+
description: 'Tag to filter pull requests',
|
75
|
+
optional: true),
|
76
|
+
FastlaneCore::ConfigItem.new(key: :skip_tag_b,
|
77
|
+
env_name: 'GENERATE_CHANGELOG_SKIP_TAG_B',
|
78
|
+
description: 'Skip second tag',
|
79
|
+
is_string: false,
|
80
|
+
optional: true),
|
81
|
+
FastlaneCore::ConfigItem.new(key: :output_path,
|
82
|
+
env_name: 'GENERATE_CHANGELOG_OUTPUT_PATH',
|
83
|
+
description: 'If set, will automatically write changelog to output path',
|
84
|
+
optional: true)
|
85
|
+
]
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.is_supported?(platform)
|
89
|
+
true
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class GitTagsAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
tags = `git tag --sort=taggerdate`.split("\n").reverse
|
6
|
+
tags = tags.take(params[:limit]) if params[:limit]
|
7
|
+
tags
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.description
|
11
|
+
"Git tags sorted by taggerdate"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.authors
|
15
|
+
["Fernando Saragoca"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.return_value
|
19
|
+
"Array of git tags sorted by taggerdate"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.available_options
|
23
|
+
[
|
24
|
+
FastlaneCore::ConfigItem.new(key: :limit,
|
25
|
+
env_name: 'GIT_TAGS_LIMIT',
|
26
|
+
description: 'Limit number of tags to return',
|
27
|
+
is_string: false,
|
28
|
+
optional: true)
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.is_supported?(platform)
|
33
|
+
true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module Helper
|
5
|
+
class ChangelogGeneratorFetcher
|
6
|
+
def self.fetch_labels(project, base_branch, access_token)
|
7
|
+
Actions.verify_gem!('octokit')
|
8
|
+
|
9
|
+
Octokit.auto_paginate = true
|
10
|
+
|
11
|
+
issues_map = {}
|
12
|
+
Octokit.issues(project, state: 'closed', access_token: access_token).each do |issue|
|
13
|
+
issues_map[issue.number] = issue
|
14
|
+
end
|
15
|
+
|
16
|
+
# Fetch pull requests
|
17
|
+
pull_requests = Octokit.pull_requests(project, state: 'closed', base: base_branch, access_token: access_token)
|
18
|
+
|
19
|
+
# Remove pull requests not merged
|
20
|
+
pull_requests.reject! do |pr|
|
21
|
+
pr.merged_at.nil?
|
22
|
+
end
|
23
|
+
|
24
|
+
# Sort by merged_at
|
25
|
+
pull_requests.sort_by!(&:merged_at)
|
26
|
+
|
27
|
+
# Uniq labels
|
28
|
+
labels = issues_map.values.map(&:labels).flatten.uniq(&:id)
|
29
|
+
|
30
|
+
# Add labels to pull requests
|
31
|
+
pull_requests.each do |pr|
|
32
|
+
pr.label_ids = issues_map[pr.number].labels.map(&:id)
|
33
|
+
end
|
34
|
+
|
35
|
+
return labels, pull_requests
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Helper
|
3
|
+
class ChangelogGeneratorHelper
|
4
|
+
# class methods that you define here become available in your action
|
5
|
+
# as `Helper::ChangelogGeneratorHelper.your_method`
|
6
|
+
#
|
7
|
+
def self.show_message
|
8
|
+
UI.message("Hello from the changelog_generator plugin helper!")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Helper
|
3
|
+
class ChangelogGeneratorRelease
|
4
|
+
attr_accessor :data, :from_tag, :to_tag, :date
|
5
|
+
|
6
|
+
def initialize(labels, pull_requests, from_tag, to_tag)
|
7
|
+
from_date = date_for_commit_with_tag(from_tag)
|
8
|
+
to_date = date_for_commit_with_tag(to_tag)
|
9
|
+
|
10
|
+
# Ensure dates & tags are ascending
|
11
|
+
if from_date && to_date && from_date > to_date
|
12
|
+
tag = from_tag
|
13
|
+
from_tag = to_tag
|
14
|
+
to_tag = tag
|
15
|
+
|
16
|
+
date = from_date
|
17
|
+
from_date = to_date
|
18
|
+
to_date = date
|
19
|
+
end
|
20
|
+
|
21
|
+
@from_tag = from_tag
|
22
|
+
@to_tag = to_tag
|
23
|
+
@date = to_date
|
24
|
+
@data = {}
|
25
|
+
|
26
|
+
labels.each do |label|
|
27
|
+
filtered_pull_requests = pull_requests.select do |pr|
|
28
|
+
includes_label = pr.label_ids.include?(label.id)
|
29
|
+
in_date_range = pr.merged_at && (!from_date || pr.merged_at > from_date) && (!to_date || pr.merged_at < to_date)
|
30
|
+
includes_label && in_date_range
|
31
|
+
end
|
32
|
+
@data[label] = filtered_pull_requests if filtered_pull_requests.count > 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def display_title
|
37
|
+
if to_tag
|
38
|
+
"[#{to_tag}] - #{date.strftime('%Y-%m-%d')}"
|
39
|
+
else
|
40
|
+
"[Unreleased]"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def date_for_commit_with_tag(tag)
|
47
|
+
# Return nil if no tag is provided
|
48
|
+
return nil if tag.nil?
|
49
|
+
|
50
|
+
# Return Time.now if tag is not found (new tag)
|
51
|
+
return Time.now if `git tag | grep #{tag}`.strip.length == 0
|
52
|
+
|
53
|
+
commit_for_tag = `git rev-list -n 1 #{tag}`.strip
|
54
|
+
# Return Time.now if commit for tag not found (new tag)
|
55
|
+
return Time.now if commit_for_tag.length == 0
|
56
|
+
|
57
|
+
# Return parsed date from tag commit
|
58
|
+
Time.parse(`git show -s --format=%ci #{commit_for_tag}`.strip)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Helper
|
3
|
+
class ChangelogGeneratorRender
|
4
|
+
attr_accessor :releases, :labels, :params
|
5
|
+
|
6
|
+
def initialize(releases, labels, params)
|
7
|
+
@releases = releases
|
8
|
+
@labels = labels
|
9
|
+
@params = params
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_markdown
|
13
|
+
template = params[:template] || File.read(params[:template_path])
|
14
|
+
markdown = ERB.new(template, 0, '-').result(binding).strip.concat("\n")
|
15
|
+
File.write(params[:output_path], markdown) if params[:output_path]
|
16
|
+
markdown
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-changelog_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fernando Saragoca
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: octokit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '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: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
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: rubocop
|
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
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: fastlane
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.111.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.111.0
|
111
|
+
description:
|
112
|
+
email: fsaragoca@me.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- LICENSE
|
118
|
+
- README.md
|
119
|
+
- lib/fastlane/plugin/changelog_generator.rb
|
120
|
+
- lib/fastlane/plugin/changelog_generator/actions/fetch_github_labels_action.rb
|
121
|
+
- lib/fastlane/plugin/changelog_generator/actions/generate_changelog_action.rb
|
122
|
+
- lib/fastlane/plugin/changelog_generator/actions/generate_release_changelog_action.rb
|
123
|
+
- lib/fastlane/plugin/changelog_generator/actions/git_tags_action.rb
|
124
|
+
- lib/fastlane/plugin/changelog_generator/helper/changelog_generator_fetcher.rb
|
125
|
+
- lib/fastlane/plugin/changelog_generator/helper/changelog_generator_helper.rb
|
126
|
+
- lib/fastlane/plugin/changelog_generator/helper/changelog_generator_release.rb
|
127
|
+
- lib/fastlane/plugin/changelog_generator/helper/changelog_generator_render.rb
|
128
|
+
- lib/fastlane/plugin/changelog_generator/version.rb
|
129
|
+
homepage: https://github.com/fsaragoca/fastlane-plugin-changelog_generator
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.5.1
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Changelog generation based on merged pull requests & tags
|
153
|
+
test_files: []
|