fastlane-plugin-semantic_release 1.0.1 → 1.0.2

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: 74e7240446d4e3e3b57e47c9f13f5c9dca2dd3e79784a534eda9768e786fd92c
4
- data.tar.gz: 7012750d1542fe5e56a7182ac23d6c1561321ce5a4a3ef6f3b17868b048ec85f
3
+ metadata.gz: a0d36b85b2320a1df53dbf3763dfc1bc4fa9bdfad599f032ff2d5ea320c65328
4
+ data.tar.gz: 61e35082c7b62e22873b42ba21c9c16d3d3041c167357d9c2bcf3b679bd3bb6f
5
5
  SHA512:
6
- metadata.gz: b3b9a597a9a58ddb9b8e7ba8523d68f1d650d1b628c7652bdded8015f620360ecc949b97a4f584c20ef691cd5a0e4decd8aeddbccedc6385bff62350ef23de68
7
- data.tar.gz: 846eef67764067475d0be534d0343eddb5e310aac348aa240acace95871ec169ee021cf9ac635a5b50995b3b01e519e40568e09f9956a74f261dd9177bc09f2e
6
+ metadata.gz: 6b1c95f31840c0f65634472136d73e398317d9bc64edbaee5caefce6e4e6308edf15a8f78873c13384ff2d59b7ab7b48bf2786f279c81d2e8b708a3c35ace88b
7
+ data.tar.gz: c917d1ff56ddec4295823857a832c5c9f736049d60437e48ed5a4daa39bce5dba63e26007cffae0c9c1f2f6da8998430a24520af374aeb414a2c9b41f7967f35
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # semantic_release plugin
1
+ # semantic_release plugin for `fastlane`
2
2
 
3
- [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-semantic_release)
3
+ [![CircleCI](https://circleci.com/gh/xotahal/fastlane-plugin-semantic_release.svg?style=svg)](https://circleci.com/gh/xotahal/fastlane-plugin-semantic_release) [![License](https://img.shields.io/github/license/SiarheiFedartsou/fastlane-plugin-versioning.svg)](https://github.com/SiarheiFedartsou/fastlane-plugin-versioning/blob/master/LICENSE) [![Gem Version](https://badge.fury.io/rb/fastlane-plugin-semantic_release.svg)](https://badge.fury.io/rb/fastlane-plugin-semantic_release) [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-versioning)
4
4
 
5
5
  ## Getting Started
6
6
 
@@ -14,25 +14,42 @@ fastlane add_plugin semantic_release
14
14
 
15
15
  Automated version managment and generator of release notes.
16
16
 
17
- **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
17
+ Inspired by [semantic-release](https://github.com/semantic-release/semantic-release) for npm packages. Based on [conventional commits](https://www.conventionalcommits.org/).
18
18
 
19
- ## Example
20
19
 
21
- 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`.
22
20
 
23
- **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
21
+ ## Actions
24
22
 
25
- ## Run tests for this plugin
26
-
27
- To run both the tests, and code style validation, run
23
+ ### analyze_commits
24
+ - analyzes your git history
25
+ - finds last tag on current branch (for example ios/beta/1.3.2)
26
+ - parses the last version from tag (1.3.2)
27
+ - gets all commits since this tag
28
+ - analyzes subject of every single commit and increases version number if there is a need (check conventional commit rules)
29
+ - if next version number is higher then last version number it will recommend you to release this version
28
30
 
31
+ Please run `fastlane action analyze_commits` to see all documentation in your command line.
32
+ ```
33
+ isReleasable = analyze_commits(match: 'ios/beta*')
34
+ ```
35
+ It leave these variables in lane_context. You can get them by `lane_context[SharedValues::RELEASE_NEXT_VERSION]` - for example.
29
36
  ```
30
- rake
37
+ ['RELEASE_ANALYZED', 'True if commits were analyzed.'],
38
+ ['RELEASE_IS_NEXT_VERSION_HIGHER', 'True if next version is higher then last version'],
39
+ ['RELEASE_LAST_TAG_HASH', 'Hash of commit that is tagged as a last version'],
40
+ ['RELEASE_LAST_VERSION', 'Last version number - parsed from last tag.'],
41
+ ['RELEASE_NEXT_MAJOR_VERSION', 'Major number of the next version'],
42
+ ['RELEASE_NEXT_MINOR_VERSION', 'Minor number of the next version'],
43
+ ['RELEASE_NEXT_PATCH_VERSION', 'Patch number of the next version'],
44
+ ['RELEASE_NEXT_VERSION', 'Next version string in format (major.minor.patch)'],
31
45
  ```
46
+ ### conventional_changelog
47
+ - parses all commits since last version
48
+ - group those commits by their type (fix, feat, docs, refactor, chore, etc)
49
+ - and creates formated release notes either in markdown or in slack format
32
50
 
33
- To automatically fix many of the styling issues, use
34
51
  ```
35
- rubocop -a
52
+ notes = conventional_changelog(format: 'slack', title: 'Android Alpha')
36
53
  ```
37
54
 
38
55
  ## Issues and Feedback
@@ -50,3 +67,11 @@ For more information about how the `fastlane` plugin system works, check out the
50
67
  ## About _fastlane_
51
68
 
52
69
  _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).
70
+
71
+ ## Questions
72
+
73
+ If you need anything ping us on [twitter](http://bit.ly/t-xotahal).
74
+
75
+ | Jiri Otahal |
76
+ | ------------------------------------------------------------------------------------------------------------------------------------------ |
77
+ | [<img src="https://avatars3.githubusercontent.com/u/3531955?v=4" width="100px;" style="border-radius:50px"/>](http://bit.ly/t-xotahal) |
@@ -14,7 +14,6 @@ module Fastlane
14
14
  RELEASE_NEXT_VERSION = :RELEASE_NEXT_VERSION
15
15
  end
16
16
 
17
-
18
17
  class AnalyzeCommitsAction < Action
19
18
  def self.run(params)
20
19
  # Last version tag name
@@ -26,81 +25,81 @@ module Fastlane
26
25
  version = '0.0.0'
27
26
 
28
27
  begin
29
- #Try to find the tag
28
+ # Try to find the tag
30
29
  command = "git describe --tags --match=#{params[:match]}"
31
30
  tag = Actions.sh(command, log: false)
32
31
  rescue
33
32
  UI.message("Tag was not found for match pattern - #{params[:match]}")
34
33
  end
35
34
 
36
- if tag.empty? then
35
+ if tag.empty?
37
36
  UI.message("First commit of the branch is taken as a begining of next release")
38
37
  # If there is no tag found we taking the first commit of current branch
39
38
  hash = Actions.sh('git rev-list --max-parents=0 HEAD', log: false).chomp
40
39
  else
41
40
  # Tag's format is v2.3.4-5-g7685948
42
41
  # See git describe man page for more info
43
- tagName = tag.split('-')[0].strip()
44
- version = tagName.match(params[:tag_version_match])[0]
42
+ tag_name = tag.split('-')[0].strip
43
+ version = tag_name.match(params[:tag_version_match])[0]
45
44
  # Get a hash of last version tag
46
- command = "git rev-list -n 1 #{tagName}"
45
+ command = "git rev-list -n 1 #{tag_name}"
47
46
  hash = Actions.sh(command, log: false).chomp
48
47
 
49
- UI.message("Found a tag #{tagName} associated with version #{version}")
48
+ UI.message("Found a tag #{tag_name} associated with version #{version}")
50
49
  end
51
50
 
52
51
  # converts last version string to the int numbers
53
- nextMajor = (version.split('.')[0] || 0).to_i
54
- nextMinor = (version.split('.')[1] || 0).to_i
55
- nextPatch = (version.split('.')[2] || 0).to_i
52
+ next_major = (version.split('.')[0] || 0).to_i
53
+ next_minor = (version.split('.')[1] || 0).to_i
54
+ next_patch = (version.split('.')[2] || 0).to_i
56
55
 
57
56
  # Get commits log between last version and head
58
57
  commits = Helper::SemanticReleaseHelper.git_log('%s', hash)
59
- splitted = commits.split("\n");
58
+ splitted = commits.split("\n")
60
59
 
61
60
  UI.message("Found #{splitted.length} commits since last release")
62
61
  releases = params[:releases]
63
62
 
64
- for line in splitted
63
+ splitted.each do |line|
65
64
  # conventional commits are in format
66
65
  # type: subject (fix: app crash - for example)
67
66
  type = line.split(":")[0]
68
67
  release = releases[type.to_sym]
69
68
 
70
- if release == "patch" then
71
- nextPatch = nextPatch + 1
72
- elsif release == "minor" then
73
- nextMinor = nextMinor + 1
74
- nextPatch = 0
75
- elsif release == "major" then
76
- nextMajor = nextMajor + 1
77
- nextMinor = 0
78
- nextPatch = 0
69
+ if release == "patch"
70
+ next_patch += 1
71
+ elsif release == "minor"
72
+ next_minor += 1
73
+ next_patch = 0
74
+ elsif release == "major"
75
+ next_major += 1
76
+ next_minor = 0
77
+ next_patch = 0
79
78
  end
80
79
 
81
- nextVersion = "#{nextMajor}.#{nextMinor}.#{nextPatch}"
82
- UI.message("#{nextVersion}: #{line}")
80
+ next_version = "#{next_major}.#{next_minor}.#{next_patch}"
81
+ UI.message("#{next_version}: #{line}")
83
82
  end
84
83
 
85
- nextVersion = "#{nextMajor}.#{nextMinor}.#{nextPatch}"
84
+ next_version = "#{next_major}.#{next_minor}.#{next_patch}"
86
85
 
87
- isReleaseable = Helper::SemanticReleaseHelper.semver_gt(nextVersion, version)
86
+ is_releasable = Helper::SemanticReleaseHelper.semver_gt(next_version, version)
88
87
 
89
88
  Actions.lane_context[SharedValues::RELEASE_ANALYZED] = true
90
- Actions.lane_context[SharedValues::RELEASE_IS_NEXT_VERSION_HIGHER] = isReleaseable
89
+ Actions.lane_context[SharedValues::RELEASE_IS_NEXT_VERSION_HIGHER] = is_releasable
91
90
  # Last release analysis
92
91
  Actions.lane_context[SharedValues::RELEASE_LAST_TAG_HASH] = hash
93
92
  Actions.lane_context[SharedValues::RELEASE_LAST_VERSION] = version
94
93
  # Next release analysis
95
- Actions.lane_context[SharedValues::RELEASE_NEXT_MAJOR_VERSION] = nextMajor
96
- Actions.lane_context[SharedValues::RELEASE_NEXT_MINOR_VERSION] = nextMinor
97
- Actions.lane_context[SharedValues::RELEASE_NEXT_PATCH_VERSION] = nextPatch
98
- Actions.lane_context[SharedValues::RELEASE_NEXT_VERSION] = nextVersion
94
+ Actions.lane_context[SharedValues::RELEASE_NEXT_MAJOR_VERSION] = next_major
95
+ Actions.lane_context[SharedValues::RELEASE_NEXT_MINOR_VERSION] = next_minor
96
+ Actions.lane_context[SharedValues::RELEASE_NEXT_PATCH_VERSION] = next_patch
97
+ Actions.lane_context[SharedValues::RELEASE_NEXT_VERSION] = next_version
99
98
 
100
- successMessage = "Next version (#{nextVersion}) is higher than last version (#{version}). This version should be released."
101
- UI.success(successMessage) if isReleaseable
99
+ success_message = "Next version (#{next_version}) is higher than last version (#{version}). This version should be released."
100
+ UI.success(success_message) if is_releasable
102
101
 
103
- isReleaseable
102
+ is_releasable
104
103
  end
105
104
 
106
105
  #####################################################
@@ -124,20 +123,20 @@ module Fastlane
124
123
  key: :match,
125
124
  description: "Match parameter of git describe. See man page of git describe for more info",
126
125
  verify_block: proc do |value|
127
- UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless (value and not value.empty?)
126
+ UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless value && !value.empty?
128
127
  end
129
128
  ),
130
129
  FastlaneCore::ConfigItem.new(
131
130
  key: :releases,
132
131
  description: "Map types of commit to release (major, minor, patch)",
133
132
  default_value: { fix: "patch", feat: "minor" },
134
- type: Hash,
133
+ type: Hash
135
134
  ),
136
135
  FastlaneCore::ConfigItem.new(
137
136
  key: :tag_version_match,
138
137
  description: "To parse version number from tag name",
139
- default_value: '\d+\.\d+\.\d+',
140
- ),
138
+ default_value: '\d+\.\d+\.\d+'
139
+ )
141
140
  ]
142
141
  end
143
142
 
@@ -152,7 +151,7 @@ module Fastlane
152
151
  ['RELEASE_NEXT_MAJOR_VERSION', 'Major number of the next version'],
153
152
  ['RELEASE_NEXT_MINOR_VERSION', 'Minor number of the next version'],
154
153
  ['RELEASE_NEXT_PATCH_VERSION', 'Patch number of the next version'],
155
- ['RELEASE_NEXT_VERSION', 'Next version string in format (major.minor.patch)'],
154
+ ['RELEASE_NEXT_VERSION', 'Next version string in format (major.minor.patch)']
156
155
  ]
157
156
  end
158
157
 
@@ -13,31 +13,30 @@ module Fastlane
13
13
 
14
14
  # If analyze commits action was not run there will be no version in shared
15
15
  # values. We need to run the action to get next version number
16
- if !analyzed then
16
+ unless analyzed
17
17
  UI.user_error!("Release hasn't been analyzed yet. Run analyze_commits action first please.")
18
18
  # version = other_action.analyze_commits(match: params[:match])
19
19
  end
20
20
 
21
- lastTagHas = lane_context[SharedValues::RELEASE_LAST_TAG_HASH]
21
+ last_tag_hash = lane_context[SharedValues::RELEASE_LAST_TAG_HASH]
22
22
  version = lane_context[SharedValues::RELEASE_NEXT_VERSION]
23
23
 
24
24
  # Get commits log between last version and head
25
- commits = Helper::SemanticReleaseHelper.git_log('%s|%H|%h|%an|%at', lastTagHas)
26
- parsed = parseCommits(commits.split("\n"))
25
+ commits = Helper::SemanticReleaseHelper.git_log('%s|%H|%h|%an|%at', last_tag_hash)
26
+ parsed = parse_commits(commits.split("\n"))
27
27
 
28
+ commit_url = params[:commit_url]
28
29
 
29
- commitUrl = params[:commit_url]
30
-
31
- if params[:format] == 'markdown' then
32
- result = markdown(parsed, version, commitUrl, params)
30
+ if params[:format] == 'markdown'
31
+ result = markdown(parsed, version, commit_url, params)
33
32
  elsif params[:format] == 'slack'
34
- result = slack(parsed, version, commitUrl, params)
33
+ result = slack(parsed, version, commit_url, params)
35
34
  end
36
35
 
37
36
  result
38
37
  end
39
38
 
40
- def self.markdown(commits, version, commitUrl, params)
39
+ def self.markdown(commits, version, commit_url, params)
41
40
  sections = params[:sections]
42
41
 
43
42
  # Begining of release notes
@@ -45,96 +44,94 @@ module Fastlane
45
44
  result += "\n"
46
45
  result += "(#{Date.today})"
47
46
 
48
- for type in params[:order]
47
+ params[:order].each do |type|
49
48
  # write section only if there is at least one commit
50
- next if !commits.any? { |commit| commit[:type] == type }
49
+ next if commits.none? { |commit| commit[:type] == type }
51
50
 
52
51
  result += "\n\n"
53
52
  result += "### #{sections[type.to_sym]}"
54
53
  result += "\n"
55
54
 
56
- for commit in commits
57
- if commit[:type] == type then
58
- authorName = commit[:authorName]
59
- shortHash = commit[:shortHash]
60
- hash = commit[:hash]
61
- link = "#{commitUrl}/#{hash}"
55
+ commits.each do |commit|
56
+ next if commit[:type] != type
62
57
 
63
- result += "- #{commit[:subject]} ([#{shortHash}](#{link}))"
58
+ author_name = commit[:author_name]
59
+ short_hash = commit[:short_hash]
60
+ hash = commit[:hash]
61
+ link = "#{commit_url}/#{hash}"
64
62
 
65
- if params[:display_author] then
66
- result += "- #{authorName}"
67
- end
63
+ result += "- #{commit[:subject]} ([#{short_hash}](#{link}))"
68
64
 
69
- result += "\n"
65
+ if params[:display_author]
66
+ result += "- #{author_name}"
70
67
  end
68
+
69
+ result += "\n"
71
70
  end
72
71
  end
73
72
 
74
-
75
73
  result
76
74
  end
77
75
 
78
- def self.slack(commits, version, commitUrl, params)
76
+ def self.slack(commits, version, commit_url, params)
79
77
  sections = params[:sections]
80
78
 
81
79
  # Begining of release notes
82
80
  result = "*#{version} #{params[:title]}* (#{Date.today})"
83
81
  result += "\n"
84
82
 
85
- for type in params[:order]
83
+ params[:order].each do |type|
86
84
  # write section only if there is at least one commit
87
- next if !commits.any? { |commit| commit[:type] == type }
85
+ next if commits.none? { |commit| commit[:type] == type }
88
86
 
89
87
  result += "\n\n"
90
88
  result += "*#{sections[type.to_sym]}*"
91
89
  result += "\n"
92
90
 
93
- for commit in commits
94
- if commit[:type] == type then
95
- authorName = commit[:authorName]
96
- shortHash = commit[:shortHash]
97
- hash = commit[:hash]
98
- link = "#{commitUrl}/#{hash}"
91
+ commits.each do |commit|
92
+ next if commit[:type] != type
99
93
 
100
- result += "- #{commit[:subject]} (<#{link}|#{shortHash}>)"
94
+ author_name = commit[:author_name]
95
+ short_hash = commit[:short_hash]
96
+ hash = commit[:hash]
97
+ link = "#{commit_url}/#{hash}"
101
98
 
102
- if params[:display_author] then
103
- result += "- #{authorName}"
104
- end
99
+ result += "- #{commit[:subject]} (<#{link}|#{short_hash}>)"
105
100
 
106
- result += "\n"
101
+ if params[:display_author]
102
+ result += "- #{author_name}"
107
103
  end
104
+
105
+ result += "\n"
108
106
  end
109
107
  end
110
108
 
111
-
112
109
  result
113
110
  end
114
111
 
115
- def self.parseCommits(commits)
112
+ def self.parse_commits(commits)
116
113
  parsed = []
117
114
  # %s|%H|%h|%an|%at
118
- for line in commits
115
+ commits.each do |line|
119
116
  splitted = line.split("|")
120
117
 
121
- subjectSplitted = splitted[0].split(":")
118
+ subject_splitted = splitted[0].split(":")
122
119
 
123
- if subjectSplitted.length > 1 then
124
- type = subjectSplitted[0]
125
- subject = subjectSplitted[1]
120
+ if subject_splitted.length > 1
121
+ type = subject_splitted[0]
122
+ subject = subject_splitted[1]
126
123
  else
127
124
  type = 'no_type'
128
- subject = subjectSplitted[0]
125
+ subject = subject_splitted[0]
129
126
  end
130
127
 
131
128
  commit = {
132
- type: type.strip(),
133
- subject: subject.strip(),
129
+ type: type.strip,
130
+ subject: subject.strip,
134
131
  hash: splitted[1],
135
- shortHash: splitted[2],
136
- authorName: splitted[3],
137
- commitDate: splitted[4],
132
+ short_hash: splitted[2],
133
+ author_name: splitted[3],
134
+ commitDate: splitted[4]
138
135
  }
139
136
 
140
137
  parsed.push(commit)
@@ -143,7 +140,6 @@ module Fastlane
143
140
  parsed
144
141
  end
145
142
 
146
-
147
143
  #####################################################
148
144
  # @!group Documentation
149
145
  #####################################################
@@ -195,7 +191,7 @@ module Fastlane
195
191
  chore: "Building system",
196
192
  test: "Testing",
197
193
  docs: "Documentation",
198
- no_type: "Rest work",
194
+ no_type: "Rest work"
199
195
  },
200
196
  type: Hash,
201
197
  optional: true
@@ -206,14 +202,14 @@ module Fastlane
206
202
  default_value: false,
207
203
  type: Boolean,
208
204
  optional: true
209
- ),
205
+ )
210
206
  ]
211
207
  end
212
208
 
213
209
  def self.output
214
210
  # Define the shared values you are going to provide
215
211
  # Example
216
- [ ]
212
+ []
217
213
  end
218
214
 
219
215
  def self.return_value
@@ -12,23 +12,24 @@ module Fastlane
12
12
  command = "git log --pretty='#{pretty}' --reverse #{start}..HEAD"
13
13
  Actions.sh(command, log: false).chomp
14
14
  end
15
+
15
16
  def self.semver_gt(first, second)
16
- firstMajor = (first.split('.')[0] || 0).to_i
17
- firstMinor = (first.split('.')[1] || 0).to_i
18
- firstPatch = (first.split('.')[2] || 0).to_i
17
+ first_major = (first.split('.')[0] || 0).to_i
18
+ first_minor = (first.split('.')[1] || 0).to_i
19
+ first_patch = (first.split('.')[2] || 0).to_i
19
20
 
20
- secondMajor = (second.split('.')[0] || 0).to_i
21
- secondMinor = (second.split('.')[1] || 0).to_i
22
- secondPatch = (second.split('.')[2] || 0).to_i
21
+ second_major = (second.split('.')[0] || 0).to_i
22
+ second_minor = (second.split('.')[1] || 0).to_i
23
+ second_patch = (second.split('.')[2] || 0).to_i
23
24
 
24
25
  # Check if next version is higher then last version
25
- if firstMajor > secondMajor then
26
+ if first_major > second_major
26
27
  return true
27
- elsif firstMajor == secondMajor then
28
- if firstMinor > secondMinor then
28
+ elsif first_major == second_major
29
+ if first_minor > second_minor
29
30
  return true
30
- elsif firstMinor == secondMinor then
31
- if firstPatch > secondPatch then
31
+ elsif first_minor == second_minor
32
+ if first_patch > second_patch
32
33
  return true
33
34
  end
34
35
  end
@@ -36,8 +37,9 @@ module Fastlane
36
37
 
37
38
  return false
38
39
  end
40
+
39
41
  def self.semver_lt(first, second)
40
- return !semver_gt(first,second)
42
+ return !semver_gt(first, second)
41
43
  end
42
44
  end
43
45
  end
@@ -1,5 +1 @@
1
- module Fastlane
2
- module SemanticRelease
3
- VERSION = "1.0.1"
4
- end
5
- end
1
+ module Fastlane module SemanticRelease VERSION="1.0.2" 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.0.1
4
+ version: 1.0.2
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-03-17 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry