fastlane-plugin-changelog 0.1.0 → 0.2.0

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: 403f4a4eb9682c5266b064684cee9bd8229d6fa8
4
- data.tar.gz: 791cb83f660b2d973251645b8ce15864d270f7e4
3
+ metadata.gz: b883277c01f1eb86a19ccf42c0259d8f547db604
4
+ data.tar.gz: 3ef67394585bda5bbe554d797affec33f42d27a0
5
5
  SHA512:
6
- metadata.gz: 0648cc5b024200347b5e152c0eddbcd9acb72e4f6f0c981ac8d8e69bb867ce02a9ddeab78bff6364019779d2fb1fdf74befed8497be608b9eeeb8f92e958eb0b
7
- data.tar.gz: c72e5212b39488c5a2742f5436045557a12507e0900016ff5cb9cd36823d4fe5f607ef2451761507ac70c076291ba2c434a4a1436508adcf55daf1ec4f37543c
6
+ metadata.gz: a6ae79e34c359159db1ea95313f60e4fcffaa5ee39fb209a3908ad60ebd9555c7fcb3d356c6c13f6dc09a50859eb717df7f571dd78d2a0792f8c02e952713fec
7
+ data.tar.gz: fa57810df72f423449d943ee7222192eb8062befa558e16455a3dc3aa9eb53a6b3e25b9d15b726eaa8e4c1d6d2ff90e9af225fdeccd9aa4abb284f67cace7e3e
data/README.md CHANGED
@@ -12,24 +12,25 @@ fastlane add_plugin changelog
12
12
 
13
13
  ## About changelog
14
14
 
15
- This plugin is inspired and based on [Keep a CHANGELOG](http://keepachangelog.com/) project. [Keep a CHANGELOG](http://keepachangelog.com/) proposes a standardised format for keeping change log of your project repository in CHANGELOG.md file. This file contains a curated, chronologically ordered list of notable changes for each version of a project in human readable format.
15
+ This plugin is inspired by and based on [Keep a CHANGELOG](http://keepachangelog.com/) project. [Keep a CHANGELOG](http://keepachangelog.com/) proposes a standardised format for keeping change log of your project repository in `CHANGELOG.md` file. This file contains a curated, chronologically ordered list of notable changes for each version of a project in human readable format.
16
16
 
17
- Since [Keep a CHANGELOG](http://keepachangelog.com/) project proposes a well-defined structure with _sections_ (e.g.: `[Unreleased]`, `0.3.0]`) and _subsections_ (`Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`) it opens up an opportunity to automate reading from/writing to CHANGELOG.md with [`fastlane`](https://fastlane.tools).
17
+ Since [Keep a CHANGELOG](http://keepachangelog.com/) project proposes a well-defined structure with _sections_ (e.g.: `[Unreleased]`, `0.3.0]`) and _subsections_ (`Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`) it opens up an opportunity to automate reading from/writing to `CHANGELOG.md` with [`fastlane`](https://fastlane.tools).
18
18
 
19
19
  ## Getting started
20
20
  1. `cd` to your project folder
21
21
  2. `touch CHANGELOG.md`
22
- 3. open CHANGELOG.md in your favourite text editor
23
- 4. paste the following: `## [Unreleased]`
22
+ 3. open `CHANGELOG.md` in your favourite text editor
23
+ 4. paste in proposed structure from [What’s a change log?](http://keepachangelog.com/)
24
24
 
25
25
  ## Actions
26
+ `fastlane-plugin-changelog` consists of 3 actions enabling you to manipulate `CHANGELOG.md` from [`fastlane`](https://fastlane.tools).
26
27
 
27
28
  ### read_changelog
28
29
 
29
30
  Reads the content of a section from your project's `CHANGELOG.md` file. `CHANGELOG.md` must follow structure proposed by [Keep a CHANGELOG](http://keepachangelog.com/) project.
30
31
 
31
32
  ``` ruby
32
- read_changelog # Reads the "Unreleased" section from CHANGELOG.md in your project's folder
33
+ read_changelog # Reads the Unreleased section from CHANGELOG.md in your project's folder
33
34
  ```
34
35
 
35
36
  ``` ruby
@@ -41,20 +42,38 @@ read_changelog(
41
42
  ```
42
43
 
43
44
  Use the output of this action in conjunction with for example [`pilot`](https://github.com/fastlane/fastlane/tree/master/pilot#uploading-builds) to upload your change log to TestFlight or with [`github_release`](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md#github-releases) to create a new release on Github.
44
-
45
- ### write_changelog
46
- *Coming soon*
47
45
 
46
+ ### update_changelog
47
+ Updates section identifier of your project's `CHANGELOG.md` file.
48
+ ``` ruby
49
+ update_changelog(
50
+ section_identifier: "[Build 123]", # Specify what section to update
51
+ updated_section_identifier: "Build 321" # Specify new section identifier
52
+ )
53
+ ```
54
+
55
+ ### stamp_changelog
56
+ Stamps the _Unreleased_ (see [How can I minimize the effort required?](http://keepachangelog.com/)) section with provided identifier in your project `CHANGELOG.md` file.
57
+ Additionally, you can provide git tag associated with this section. `stamp_changelog` will then create a link to diff between this and previous section's tag on Github. This will enable you to quickly get to [comparison between two tags](https://help.github.com/articles/comparing-commits-across-time/).
58
+ ``` ruby
59
+ stamp_changelog(
60
+ section_identifier: "Build XYZ", # Specify identifier to stamp the Unreleased section with
61
+ git_tag: "bXYZ" # Specify reference to git tag associated with this section
62
+ )
63
+ ```
48
64
 
49
65
  ## Example
50
- As a developer you have to **remember to keep your CHANGELOG.md up-to-date** with whatever features, bug fixes etc. your repo contains and let [`fastlane`](https://fastlane.tools) to do the rest.
66
+ As a developer you have to **remember to keep your CHANGELOG.md up-to-date** with whatever features, bug fixes etc. your repo contains and let [`fastlane`](https://fastlane.tools) do the rest.
51
67
 
52
68
  ``` ruby
53
69
  lane :beta do
54
- gym
55
- changelog = read_changelog
56
- pilot(changelog: changelog)
57
- # write_changelog
70
+ build_number = get_build_number # Get build number
71
+ gym # Compile
72
+
73
+ changelog = read_changelog # Read changelog
74
+ pilot(changelog: changelog) # Send binary and changelog to TestFlight
75
+
76
+ stamp_changelog(section_identifier: "Build #{build_number}") # Stamp Unreleased section with newly released build number
58
77
  end
59
78
  ```
60
79
 
@@ -5,13 +5,12 @@ module Fastlane
5
5
  end
6
6
 
7
7
  class ReadChangelogAction < Action
8
-
9
- def self.run(params)
10
- changelog_path = params[:changelog_path] unless (params[:changelog_path].to_s.empty?)
11
- UI.error("CHANGELOG.md at path '#{changelog_path}' does not exist") unless (File.exist?(changelog_path))
8
+ def self.run(params)
9
+ changelog_path = params[:changelog_path] unless params[:changelog_path].to_s.empty?
10
+ UI.error("CHANGELOG.md at path '#{changelog_path}' does not exist") unless File.exist?(changelog_path)
12
11
 
13
- section_identifier = params[:section_identifier] unless (params[:section_identifier].to_s.empty?)
14
- escaped_section_identifier = section_identifier[/\[(.*?)\]/,1]
12
+ section_identifier = params[:section_identifier] unless params[:section_identifier].to_s.empty?
13
+ escaped_section_identifier = section_identifier[/\[(.*?)\]/, 1]
15
14
 
16
15
  excluded_markdown_elements = params[:excluded_markdown_elements]
17
16
 
@@ -21,27 +20,25 @@ module Fastlane
21
20
  found_section = false
22
21
  File.open(changelog_path, "r") do |file|
23
22
  file.each_line do |line|
24
-
25
23
  if found_section
26
24
  break if line =~ /\#{2}\s?\[(.*?)\]/
27
25
  if !excluded_markdown_elements.nil? && !excluded_markdown_elements.empty?
28
26
  markdownless_line = remove_markdown(line, excluded_markdown_elements)
29
27
  section_content.concat(markdownless_line)
30
- else
28
+ else
31
29
  section_content.concat(line)
32
- end
33
- end
30
+ end
31
+ end
34
32
 
35
33
  if line =~ /\#{2}\s?\[#{escaped_section_identifier}\]/
36
34
  found_section = true
37
35
  end
38
-
39
36
  end
40
37
  end
41
38
 
42
- UI.error("Could not find #{section_identifier} section in your CHANGELOG.md") unless (!section_content.empty?)
39
+ UI.error("Could not find #{section_identifier} section in your CHANGELOG.md") if section_content.empty?
43
40
 
44
- UI.success("Finished reading #{section_identifier} section from '#{changelog_path}'") unless (section_content.empty?)
41
+ UI.success("Finished reading #{section_identifier} section from '#{changelog_path}'") unless section_content.empty?
45
42
 
46
43
  Actions.lane_context[SharedValues::READ_CHANGELOG_SECTION_CONTENT] = section_content
47
44
  end
@@ -52,7 +49,7 @@ module Fastlane
52
49
  if line =~ /^#{element}/
53
50
  markdownless_line = markdownless_line.gsub(element.to_s, "")
54
51
  end
55
- end
52
+ end
56
53
 
57
54
  markdownless_line
58
55
  end
@@ -66,9 +63,7 @@ module Fastlane
66
63
  end
67
64
 
68
65
  def self.details
69
- "This action is inspired by \"Keep a CHANGELOG\" project (see http://keepachangelog.com/). \"Keep a CHANGELOG\" introduces a structed CHANGELOG.md file,
70
- which contains a curated, chronologically ordered list of notable changes for each version of a project. Use this action to read content of a section
71
- from your project's CHANGELOG.md."
66
+ "Use this action to read content of an arbitrary section from your project CHANGELOG.md"
72
67
  end
73
68
 
74
69
  def self.available_options
@@ -77,7 +72,7 @@ module Fastlane
77
72
  env_name: "FL_READ_CHANGELOG_PATH_TO_CHANGELOG",
78
73
  description: "The path to your project CHANGELOG.md",
79
74
  is_string: true,
80
- default_value: "./CHANGELOG.md",
75
+ default_value: "./CHANGELOG.md",
81
76
  optional: true),
82
77
  FastlaneCore::ConfigItem.new(key: :section_identifier,
83
78
  env_name: "FL_READ_CHANGELOG_SECTION_IDENTIFIER",
@@ -86,8 +81,8 @@ module Fastlane
86
81
  default_value: "[Unreleased]",
87
82
  optional: true,
88
83
  verify_block: proc do |value|
89
- UI.user_error!("Sections (##) in CHANGELOG format must be encapsulated in []") unless (value.start_with?("[") && value.end_with?("]"))
90
- UI.user_error!("Sections (##) in CHANGELOG format cannot be empty") unless (!value[/\[(.*?)\]/,1].empty?)
84
+ UI.user_error!("Sections (##) in CHANGELOG format must be encapsulated in []") unless value.start_with?("[") && value.end_with?("]")
85
+ UI.user_error!("Sections (##) in CHANGELOG format cannot be empty") if value[/\[(.*?)\]/, 1].empty?
91
86
  end),
92
87
  FastlaneCore::ConfigItem.new(key: :excluded_markdown_elements,
93
88
  env_name: "FL_READ_CHANGELOG_EXCLUDED_MARKDOWN_ELEMENTS",
@@ -0,0 +1,103 @@
1
+ module Fastlane
2
+ module Actions
3
+ class StampChangelogAction < Action
4
+ def self.run(params)
5
+ changelog_path = params[:changelog_path] unless params[:changelog_path].to_s.empty?
6
+ UI.error("CHANGELOG.md at path '#{changelog_path}' does not exist") unless File.exist?(changelog_path)
7
+
8
+ # 1. Update [Unreleased] section with provided identifier
9
+ section_identifier = params[:section_identifier] unless params[:section_identifier].to_s.empty?
10
+ Actions::UpdateChangelogAction.run(changelog_path: changelog_path,
11
+ section_identifier: "[Unreleased]",
12
+ updated_section_identifier: section_identifier)
13
+
14
+ file_content = ""
15
+
16
+ # 2. Create new [Unreleased] section (placeholder)
17
+ inserted_unreleased = false
18
+ File.open(changelog_path, "r") do |file|
19
+ file.each_line do |line|
20
+ # Find the first section identifier
21
+ if !inserted_unreleased && line =~ /\#{2}\s?\[(.*?)\]/
22
+ unreleased_section = "## [Unreleased]"
23
+ line = "#{unreleased_section}\n\n#{line}"
24
+ inserted_unreleased = true
25
+
26
+ UI.message("Created [Unreleased] placeholder section")
27
+
28
+ # Output updated line
29
+ file_content.concat(line)
30
+ next
31
+ end
32
+
33
+ # Output read line
34
+ file_content.concat(line)
35
+ end
36
+ end
37
+
38
+ # 3. Create link to Github tags diff
39
+ unless params[:git_tag].empty?
40
+ last_line = file_content.lines.last
41
+ previous_section_name = last_line[/\[(.*?)\]/, 1]
42
+ previous_previous_tag = %r{(?<=compare\/)(.*)?(?=\.{3})}.match(last_line)
43
+ previous_tag = /(?<=\.{3})(.*)?/.match(last_line)
44
+
45
+ last_line.sub!(previous_tag.to_s, params[:git_tag]) # Replace previous tag with new
46
+ last_line.sub!(previous_previous_tag.to_s, previous_tag.to_s) # Replace previous-previous tag with previous
47
+ last_line.sub!(previous_section_name.to_s, section_identifier) # Replace section identifier
48
+
49
+ UI.message("Created link to Github tags diff")
50
+
51
+ file_content.concat(last_line)
52
+ end
53
+
54
+ # 4. Write updated content to file
55
+ changelog = File.open(changelog_path, "w")
56
+ changelog.puts(file_content)
57
+ changelog.close
58
+ UI.success("Successfuly stamped #{section_identifier} in #{changelog_path}")
59
+ end
60
+
61
+ #####################################################
62
+ # @!group Documentation
63
+ #####################################################
64
+
65
+ def self.description
66
+ "Stamps the [Unreleased] section with provided identifier in your project CHANGELOG.md file"
67
+ end
68
+
69
+ def self.details
70
+ "Use this action to stamp the [Unreleased] section with provided identifier in your project CHANGELOG.md. Additionally, you can provide git tag
71
+ associated with this section. `stamp_changelog` will then create a new link to diff between this and previous section's tag on Github"
72
+ end
73
+
74
+ def self.available_options
75
+ [
76
+ FastlaneCore::ConfigItem.new(key: :changelog_path,
77
+ env_name: "FL_STAMP_CHANGELOG_PATH_TO_CHANGELOG",
78
+ description: "The path to your project CHANGELOG.md",
79
+ is_string: true,
80
+ default_value: "./CHANGELOG.md",
81
+ optional: true),
82
+ FastlaneCore::ConfigItem.new(key: :section_identifier,
83
+ env_name: "FL_STAMP_CHANGELOG_SECTION_IDENTIFIER",
84
+ description: "The unique section identifier to stamp the [Unreleased] section with",
85
+ is_string: true),
86
+ FastlaneCore::ConfigItem.new(key: :git_tag,
87
+ env_name: "FL_STAMP_CHANGELOG_GIT_TAG",
88
+ description: "The git tag associated with this section",
89
+ is_string: true,
90
+ optional: true)
91
+ ]
92
+ end
93
+
94
+ def self.authors
95
+ ["pajapro"]
96
+ end
97
+
98
+ def self.is_supported?(platform)
99
+ true
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,107 @@
1
+ module Fastlane
2
+ module Actions
3
+ class UpdateChangelogAction < Action
4
+ def self.run(params)
5
+ changelog_path = params[:changelog_path] unless params[:changelog_path].to_s.empty?
6
+ UI.error("CHANGELOG.md at path '#{changelog_path}' does not exist") unless File.exist?(changelog_path)
7
+
8
+ section_identifier = params[:section_identifier] unless params[:section_identifier].to_s.empty?
9
+ escaped_section_identifier = section_identifier[/\[(.*?)\]/, 1]
10
+
11
+ new_section_identifier = params[:updated_section_identifier] unless params[:updated_section_identifier].to_s.empty?
12
+ # new_section_content = params[:updated_section_content] unless (params[:updated_section_content].to_s.empty?)
13
+
14
+ UI.message "Starting to update #{section_identifier} section of '#{changelog_path}'"
15
+
16
+ # Read & update file content
17
+ file_content = ""
18
+ File.open(changelog_path, "r") do |file|
19
+ file.each_line do |line|
20
+ # Find line matching section identifier
21
+ if line =~ /\#{2}\s?\[#{escaped_section_identifier}\]/
22
+ found_identifying_section = true
23
+ end
24
+
25
+ # Update section identifier (if found)
26
+ if !new_section_identifier.empty? && found_identifying_section
27
+ section_name = section_identifier[/\[(.*?)\]/, 1]
28
+
29
+ line_old = line.dup
30
+ line.sub!(section_name, new_section_identifier)
31
+ found_identifying_section = false
32
+
33
+ UI.message "Old section identifier: #{line_old.delete!("\n")}"
34
+ UI.message "New section identifier: #{line.delete("\n")}"
35
+
36
+ # Output updated line
37
+ file_content.concat(line)
38
+ next
39
+ end
40
+
41
+ # TODO: implement updating of section content
42
+
43
+ # Output read line
44
+ file_content.concat(line)
45
+ end
46
+ end
47
+
48
+ # Write updated content to file
49
+ changelog = File.open(changelog_path, "w")
50
+ changelog.puts(file_content)
51
+ changelog.close
52
+ UI.success("Successfuly updated #{changelog_path}")
53
+ end
54
+
55
+ #####################################################
56
+ # @!group Documentation
57
+ #####################################################
58
+
59
+ def self.description
60
+ "Updates content of a section of your project CHANGELOG.md file"
61
+ end
62
+
63
+ def self.details
64
+ "Use this action to update content of an arbitrary section of your project CHANGELOG.md"
65
+ end
66
+
67
+ def self.available_options
68
+ [
69
+ FastlaneCore::ConfigItem.new(key: :changelog_path,
70
+ env_name: "FL_UPDATE_CHANGELOG_PATH_TO_CHANGELOG",
71
+ description: "The path to your project CHANGELOG.md",
72
+ is_string: true,
73
+ default_value: "./CHANGELOG.md",
74
+ optional: true),
75
+ FastlaneCore::ConfigItem.new(key: :section_identifier,
76
+ env_name: "FL_UPDATE_CHANGELOG_SECTION_IDENTIFIER",
77
+ description: "The unique section identifier to update content of",
78
+ is_string: true,
79
+ default_value: "[Unreleased]",
80
+ optional: true,
81
+ verify_block: proc do |value|
82
+ UI.user_error!("Sections (##) in CHANGELOG format must be encapsulated in []") unless value.start_with?("[") && value.end_with?("]")
83
+ UI.user_error!("Sections (##) in CHANGELOG format cannot be empty") if value[/\[(.*?)\]/, 1].empty?
84
+ end),
85
+ FastlaneCore::ConfigItem.new(key: :updated_section_identifier,
86
+ env_name: "FL_UPDATE_CHANGELOG_UPDATED_SECTION_IDENTIFIER",
87
+ description: "The updated unique section identifier",
88
+ is_string: true,
89
+ optional: true)
90
+ # FastlaneCore::ConfigItem.new(key: :updated_section_content,
91
+ # env_name: "FL_UPDATE_CHANGELOG_UPDATED_SECTION_CONTENT",
92
+ # description: "The updated section content",
93
+ # is_string: true,
94
+ # optional: true)
95
+ ]
96
+ end
97
+
98
+ def self.authors
99
+ ["pajapro"]
100
+ end
101
+
102
+ def self.is_supported?(platform)
103
+ true
104
+ end
105
+ end
106
+ end
107
+ end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Changelog
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Prochazka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-25 00:00:00.000000000 Z
11
+ date: 2016-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -100,8 +100,9 @@ executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
- - lib/fastlane/plugin/changelog/actions/changelog_action.rb
104
103
  - lib/fastlane/plugin/changelog/actions/read_changelog.rb
104
+ - lib/fastlane/plugin/changelog/actions/stamp_changelog.rb
105
+ - lib/fastlane/plugin/changelog/actions/update_changelog.rb
105
106
  - lib/fastlane/plugin/changelog/helper/changelog_helper.rb
106
107
  - lib/fastlane/plugin/changelog/version.rb
107
108
  - lib/fastlane/plugin/changelog.rb
@@ -1,35 +0,0 @@
1
- module Fastlane
2
- module Actions
3
- class ChangelogAction < Action
4
- def self.run(params)
5
- UI.message("The changelog plugin is working!")
6
- end
7
-
8
- def self.description
9
- "Automate changes to your project CHANGELOG.md"
10
- end
11
-
12
- def self.authors
13
- ["Pavel Prochazka"]
14
- end
15
-
16
- def self.available_options
17
- [
18
- # FastlaneCore::ConfigItem.new(key: :your_option,
19
- # env_name: "CHANGELOG_YOUR_OPTION",
20
- # description: "A description of your option",
21
- # optional: false,
22
- # type: String)
23
- ]
24
- end
25
-
26
- def self.is_supported?(platform)
27
- # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
28
- # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
29
- #
30
- # [:ios, :mac, :android].include?(platform)
31
- true
32
- end
33
- end
34
- end
35
- end