fastlane-plugin-semantic_release 1.1.8 → 1.5.1

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: c1ae75301af55462a4562ca754bb60105e9946a4e5900cd700072cc2ee291269
4
- data.tar.gz: 2c13cedf37198623568b475fb6cecf1f597119989f57811c22861689ac846c30
3
+ metadata.gz: 9a1dd33a05c2a6864d2a60b13cb2fc1b6bae08e1549075bc5355b67c4e023e4c
4
+ data.tar.gz: a8c22242d8d8304f211da2ef3229505926763468856a223d9543cd545b6e3cdf
5
5
  SHA512:
6
- metadata.gz: c37e53c9830f14b7573b207a5efc90a26f2e03a9315bbd1386ff20014e499e355c0bd9d98d31a7e176c91103d5a9359736f20c20cff142849532d270ac22a116
7
- data.tar.gz: e38aa4f0067a1f84399bc5c05b2bd48782abdf73fa367d83cea1c39a44e87a00140d9babafc73d5252a219593dd0b35eadb9ae3f72648c361fc69c9d5ed1cd2f
6
+ metadata.gz: '0009044f8a040373ea1bf0601a8a3b38ad5e6269b0c78daded0c2b2a78eada4667e906e37d47f7f54711615c620fd7c16ccce4b3e8db50b27a440bc0163ac60f'
7
+ data.tar.gz: 342c0423b25bfe6ff9e0aa4dd3ae7a7fedbfc5bcd7c23aa16faacd5abcb045e8cd8b75a3ba8e2dd92c14c0508aad559a6fdd8d280cb84525c211f7e171a3b0e1
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Getting Started
6
6
 
7
- ```bash
7
+ ```
8
8
  fastlane add_plugin semantic_release
9
9
  ```
10
10
 
@@ -18,19 +18,30 @@ Automated version managment and generator of release notes. Inspired by [semanti
18
18
 
19
19
  ## Available Actions
20
20
 
21
- ### conventional_changelog
21
+ ### `conventional_changelog`
22
22
 
23
23
  - parses all commits since last version
24
- - group those commits by their type (fix, feat, docs, refactor, chore, etc)
24
+ - groups those commits by their type (fix, feat, docs, refactor, chore, etc)
25
25
  - and creates formated release notes either in markdown or in slack format
26
26
 
27
+ Available parameters:
28
+
29
+ - `format: 'slack|markdown|plain'` (defaults to `markdown`). This formats the changelog for the destination you need. If you're using this for TestFlight changelogs, we suggest using the `plain` option
30
+ - `title: 'My Title'` - is appended to the release notes title, "1.1.8 My Title (YYYY-MM-DD)"
31
+ - `display_title: true|false` (defaults to true) - allows you to hide the entire first line of the changelog
32
+ - `display_links: true|false` (defaults to true) - allows you to hide links to commits from your changelog
33
+ - `commit_url: 'https://github.com/username/repository/commit'` - prepended to the commit ID to build usable links
34
+ - View other options by searching for `available_options` in `conventional_changelog.rb`
35
+
36
+ Example:
37
+
27
38
  ```
28
39
  notes = conventional_changelog(format: 'slack', title: 'Android Alpha')
29
40
  ```
30
41
 
31
42
  <img src="https://raw.githubusercontent.com/xotahal/fastlane-plugin-semantic_release/master/docs/Changelog.png" />
32
43
 
33
- ### analyze_commits
44
+ ### `analyze_commits`
34
45
 
35
46
  - analyzes your git history
36
47
  - finds last tag on current branch (for example ios/beta/1.3.2)
@@ -38,11 +49,13 @@ notes = conventional_changelog(format: 'slack', title: 'Android Alpha')
38
49
  - gets all commits since this tag
39
50
  - analyzes subject of every single commit and increases version number if there is a need (check conventional commit rules)
40
51
  - if next version number is higher then last version number it will recommend you to release this version
52
+
41
53
  ```
42
54
  isReleasable = analyze_commits(match: 'ios/beta*')
43
55
  ```
44
56
 
45
- It provides these variables in lane_context.
57
+ It provides these variables in `lane_context`.
58
+
46
59
  ```
47
60
  ['RELEASE_ANALYZED', 'True if commits were analyzed.'],
48
61
  ['RELEASE_IS_NEXT_VERSION_HIGHER', 'True if next version is higher then last version'],
@@ -53,12 +66,18 @@ It provides these variables in lane_context.
53
66
  ['RELEASE_NEXT_PATCH_VERSION', 'Patch number of the next version'],
54
67
  ['RELEASE_NEXT_VERSION', 'Next version string in format (major.minor.patch)'],
55
68
  ```
56
- `next_version = lane_context[SharedValues::RELEASE_NEXT_VERSION]`
57
69
 
70
+ And you can access these like this:
71
+
72
+ `next_version = lane_context[SharedValues::RELEASE_NEXT_VERSION]`
58
73
 
59
74
  <img src="https://raw.githubusercontent.com/xotahal/fastlane-plugin-semantic_release/master/docs/Analyze.png" />
60
75
 
61
- ### Questions
76
+ ## Tests
77
+
78
+ To run the test suite (contained in `./spec`), call `bundle exec rake`
79
+
80
+ ## Questions
62
81
 
63
82
  If you need anything ping us on [twitter](http://bit.ly/t-xotahal).
64
83
 
@@ -31,147 +31,138 @@ module Fastlane
31
31
  parsed = parse_commits(commits)
32
32
 
33
33
  commit_url = params[:commit_url]
34
+ format = params[:format]
34
35
 
35
- if params[:format] == 'markdown'
36
- result = markdown(parsed, version, commit_url, params)
37
- elsif params[:format] == 'slack'
38
- result = slack(parsed, version, commit_url, params)
39
- end
36
+ result = note_builder(format, parsed, version, commit_url, params)
40
37
 
41
38
  result
42
39
  end
43
40
 
44
- def self.markdown(commits, version, commit_url, params)
41
+ def self.note_builder(format, commits, version, commit_url, params)
45
42
  sections = params[:sections]
46
43
 
47
- title = version
48
- title += " #{params[:title]}" if params[:title]
44
+ result = ""
49
45
 
50
46
  # Begining of release notes
51
- result = "# #{title} (#{Date.today})"
52
- result += "\n"
47
+ if params[:display_title] == true
48
+ title = version
49
+ title += " #{params[:title]}" if params[:title]
50
+ title += " (#{Date.today})"
51
+
52
+ result = style_text(title, format, "title").to_s
53
+ result += "\n\n"
54
+ end
53
55
 
54
56
  params[:order].each do |type|
55
57
  # write section only if there is at least one commit
56
58
  next if commits.none? { |commit| commit[:type] == type }
57
59
 
58
- result += "\n\n"
59
- result += "### #{sections[type.to_sym]}"
60
+ result += style_text(sections[type.to_sym], format, "heading").to_s
60
61
  result += "\n"
61
62
 
62
63
  commits.each do |commit|
63
64
  next if commit[:type] != type || commit[:is_merge]
64
65
 
65
- author_name = commit[:author_name]
66
- short_hash = commit[:short_hash]
67
- hash = commit[:hash]
68
- link = "#{commit_url}/#{hash}"
69
-
70
66
  result += "-"
71
67
 
72
68
  unless commit[:scope].nil?
73
- result += " **#{commit[:scope]}:**"
69
+ formatted_text = style_text("#{commit[:scope]}:", format, "bold").to_s
70
+ result += " #{formatted_text}"
74
71
  end
75
72
 
76
- result += " #{commit[:subject]} ([#{short_hash}](#{link}))"
73
+ result += " #{commit[:subject]}"
77
74
 
78
- if params[:display_author]
79
- result += "- #{author_name}"
75
+ if params[:display_links] == true
76
+ styled_link = build_commit_link(commit, commit_url, format).to_s
77
+ result += " (#{styled_link})"
80
78
  end
81
79
 
82
- result += "\n"
83
- end
84
- end
85
-
86
- if commits.any? { |commit| commit[:is_breaking_change] == true }
87
- result += "\n\n"
88
- result += "### BREAKING CHANGES"
89
- result += "\n"
90
-
91
- commits.each do |commit|
92
- next unless commit[:is_breaking_change]
93
-
94
- author_name = commit[:author_name]
95
- short_hash = commit[:short_hash]
96
- hash = commit[:hash]
97
- link = "#{commit_url}/#{hash}"
98
-
99
- result += "- #{commit[:breaking_change]} ([#{short_hash}](#{link}))"
100
-
101
80
  if params[:display_author]
102
- result += "- #{author_name}"
81
+ result += " - #{commit[:author_name]}"
103
82
  end
104
83
 
105
84
  result += "\n"
106
85
  end
86
+ result += "\n"
107
87
  end
108
88
 
109
- result
110
- end
111
-
112
- def self.slack(commits, version, commit_url, params)
113
- sections = params[:sections]
114
-
115
- # Begining of release notes
116
- result = "*#{version} #{params[:title]}* (#{Date.today})"
117
- result += "\n"
118
-
119
- params[:order].each do |type|
120
- # write section only if there is at least one commit
121
- next if commits.none? { |commit| commit[:type] == type }
122
-
123
- result += "\n\n"
124
- result += "*#{sections[type.to_sym]}*"
89
+ if commits.any? { |commit| commit[:is_breaking_change] == true }
90
+ result += style_text("BREAKING CHANGES", format, "heading").to_s
125
91
  result += "\n"
126
92
 
127
93
  commits.each do |commit|
128
- next if commit[:type] != type || commit[:is_merge]
129
-
130
- author_name = commit[:author_name]
131
- short_hash = commit[:short_hash]
132
- hash = commit[:hash]
133
- link = "#{commit_url}/#{hash}"
134
-
135
- result += "-"
94
+ next unless commit[:is_breaking_change]
95
+ result += "- #{commit[:breaking_change]}" # This is the only unique part of this loop
136
96
 
137
- unless commit[:scope].nil?
138
- result += " *#{commit[:scope]}:*"
97
+ if params[:display_links] == true
98
+ styled_link = build_commit_link(commit, commit_url, format).to_s
99
+ result += " (#{styled_link})"
139
100
  end
140
101
 
141
- result += " #{commit[:subject]} (<#{link}|#{short_hash}>)"
142
-
143
102
  if params[:display_author]
144
- result += "- #{author_name}"
103
+ result += " - #{commit[:author_name]}"
145
104
  end
146
105
 
147
106
  result += "\n"
148
107
  end
149
- end
150
108
 
151
- if commits.any? { |commit| commit[:is_breaking_change] == true }
152
- result += "\n\n"
153
- result += "*BREAKING CHANGES*"
154
109
  result += "\n"
110
+ end
155
111
 
156
- commits.each do |commit|
157
- next unless commit[:is_breaking_change]
158
-
159
- author_name = commit[:author_name]
160
- short_hash = commit[:short_hash]
161
- hash = commit[:hash]
162
- link = "#{commit_url}/#{hash}"
163
-
164
- result += "- #{commit[:breaking_change]} (<#{link}|#{short_hash}>)"
112
+ # Trim any trailing newlines
113
+ result = result.rstrip!
165
114
 
166
- if params[:display_author]
167
- result += "- #{author_name}"
168
- end
115
+ result
116
+ end
169
117
 
170
- result += "\n"
118
+ def self.style_text(text, format, style)
119
+ # formats the text according to the style we're looking to use
120
+
121
+ # Skips all styling
122
+ case style
123
+ when "title"
124
+ if format == "markdown"
125
+ "# #{text}"
126
+ elsif format == "slack"
127
+ "*#{text}*"
128
+ else
129
+ text
130
+ end
131
+ when "heading"
132
+ if format == "markdown"
133
+ "### #{text}"
134
+ elsif format == "slack"
135
+ "*#{text}*"
136
+ else
137
+ "#{text}:"
171
138
  end
139
+ when "bold"
140
+ if format == "markdown"
141
+ "**#{text}**"
142
+ elsif format == "slack"
143
+ "*#{text}*"
144
+ else
145
+ text
146
+ end
147
+ else
148
+ text # catchall, shouldn't be needed
172
149
  end
150
+ end
173
151
 
174
- result
152
+ def self.build_commit_link(commit, commit_url, format)
153
+ # formats the link according to the output format we need
154
+ short_hash = commit[:short_hash]
155
+ hash = commit[:hash]
156
+ url = "#{commit_url}/#{hash}"
157
+
158
+ case format
159
+ when "slack"
160
+ "<#{url}|#{short_hash}>"
161
+ when "markdown"
162
+ "[#{short_hash}](#{url})"
163
+ else
164
+ url
165
+ end
175
166
  end
176
167
 
177
168
  def self.parse_commits(commits)
@@ -215,7 +206,7 @@ module Fastlane
215
206
  [
216
207
  FastlaneCore::ConfigItem.new(
217
208
  key: :format,
218
- description: "You can use either markdown or slack",
209
+ description: "You can use either markdown, slack or plain",
219
210
  default_value: "markdown",
220
211
  optional: true
221
212
  ),
@@ -258,6 +249,20 @@ module Fastlane
258
249
  default_value: false,
259
250
  type: Boolean,
260
251
  optional: true
252
+ ),
253
+ FastlaneCore::ConfigItem.new(
254
+ key: :display_title,
255
+ description: "Whether you want to hide the title/header with the version details at the top of the changelog",
256
+ default_value: true,
257
+ type: Boolean,
258
+ optional: true
259
+ ),
260
+ FastlaneCore::ConfigItem.new(
261
+ key: :display_links,
262
+ description: "Whether you want to display the links to commit IDs",
263
+ default_value: true,
264
+ type: Boolean,
265
+ optional: true
261
266
  )
262
267
  ]
263
268
  end
@@ -1 +1 @@
1
- module Fastlane module SemanticRelease VERSION = "1.1.8" end end
1
+ module Fastlane module SemanticRelease VERSION = "1.5.1" end end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-semantic_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiří Otáhal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-09 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry