1
+ require 'fileutils'
2
+
1
3
fastlane_version "2.63.0"
2
4
3
5
skip_docs
@@ -57,6 +59,28 @@ lane :bump do |options|
57
59
new_version_xcode
58
60
end
59
61
62
+ desc "Get all pull requests since the last release"
63
+ lane :pr_commits do
64
+ # Only include squashed pull requests which end with something like "(#123)".
65
+ changelog_from_git_commits ( pretty :"- %s" )
66
+ . split ( "\n " )
67
+ . grep ( /\( #[0-9]*\) $/ )
68
+ . join ( "\n " )
69
+ end
70
+
71
+ lane :update_changelog do
72
+ ensure_git_status_clean
73
+
74
+ changelog_path = "../CHANGELOG.md"
75
+ changelog_additions = "## [#{ get_version_number } ] - #{ Time . now . strftime ( "%Y-%m-%d" ) } \n \n #{ pr_commits } "
76
+ changelog = File . read ( changelog_path )
77
+ changelog = changelog . sub ( /##/ , "#{ changelog_additions } \n \n \\ 0" )
78
+ File . write ( changelog_path , changelog )
79
+
80
+ sh ( "git commit -am 'Update changelog'" )
81
+ ensure_git_status_clean
82
+ end
83
+
60
84
desc "Prepares a release by bumping version, formatting code, running tests, setting up a release preparation branch"
61
85
lane :prepare do |options |
62
86
# Ensure we prepare from current master
@@ -80,9 +104,10 @@ lane :prepare do |options|
80
104
# Update copyright year if needed
81
105
copyright
82
106
83
- # Run tests
84
107
test
85
108
109
+ update_changelog
110
+
86
111
# Prompt for confimation
87
112
promt_text = "Version #{ version } has been prepared for release. " \
88
113
"Please make any additional changes that should be included in the release before continuing. " \
@@ -104,9 +129,12 @@ lane :release_pr do
104
129
next
105
130
end
106
131
132
+ pr_body = "'This pull request was autogenerated by fastlane. :robot: :rocket:\n " \
133
+ "## Changes included in this release\n #{ pr_commits } '"
134
+
107
135
gh_command = "gh pr create" \
108
136
" --title 'Prepare #{ get_version_number ( target : "JOSESwift" ) } '" \
109
- " --body 'This pull request was autogenerated by fastlane. :robot: :rocket:' "
137
+ " --body #{ pr_body } "
110
138
111
139
system ( gh_command )
112
140
end
0 commit comments