@@ -12,58 +12,58 @@ def update_version_in_go_file(file_path, major, minor, build):
1212 """Update the version in the Go plugin metadata."""
1313 with open (file_path , 'r' ) as f :
1414 content = f .read ()
15-
15+
1616 # Pattern to match the Version struct in PluginMetadata
1717 pattern = r'(Version: plugin\.VersionType\s*{\s*Major:\s*)\d+(\s*,\s*Minor:\s*)\d+(\s*,\s*Build:\s*)\d+(\s*,\s*})'
18-
18+
1919 replacement = rf'\g<1>{ major } \g<2>{ minor } \g<3>{ build } \g<4>'
20-
20+
2121 new_content = re .sub (pattern , replacement , content )
22-
22+
2323 if new_content == content :
2424 print (f"Warning: Version pattern not found or not updated in { file_path } " )
2525 return False
26-
26+
2727 with open (file_path , 'w' ) as f :
2828 f .write (new_content )
29-
29+
3030 print (f"✅ Updated version to { major } .{ minor } .{ build } in { file_path } " )
3131 return True
3232
3333def process_readme_changelog (readme_path , version ):
3434 """Process the README changelog section for the release."""
3535 with open (readme_path , 'r' ) as f :
3636 content = f .read ()
37-
37+
3838 # Look for the snapshot section
3939 snapshot_pattern = rf'## { re .escape (version )} -snapshot\s*\n'
4040 match = re .search (snapshot_pattern , content )
41-
41+
4242 if not match :
4343 print (f"Error: README.md does not contain a '## { version } -snapshot' section" )
4444 return False , None
45-
45+
4646 # Find the content of the snapshot section
4747 start_pos = match .end ()
48-
48+
4949 # Find the next ## section or end of file
5050 next_section_pattern = r'\n## '
5151 next_match = re .search (next_section_pattern , content [start_pos :])
52-
52+
5353 if next_match :
5454 end_pos = start_pos + next_match .start ()
5555 section_content = content [start_pos :end_pos ].strip ()
5656 else :
5757 section_content = content [start_pos :].strip ()
58-
58+
5959 # Remove the "-snapshot" from the header
6060 new_header = f"## { version } "
6161 updated_content = re .sub (snapshot_pattern , new_header + '\n \n ' , content )
62-
62+
6363 # Write the updated README
6464 with open (readme_path , 'w' ) as f :
6565 f .write (updated_content )
66-
66+
6767 print (f"✅ Updated README.md: converted '## { version } -snapshot' to '## { version } '" )
6868 return True , section_content
6969
@@ -75,20 +75,77 @@ def is_rc_version(version_str):
7575 """Return True if the version string ends with -rc or -rcN."""
7676 return bool (re .match (r"^\d+\.\d+\.\d+-rc(\d+)?$" , version_str ))
7777
78+ def generate_release_notes (version , changelog_content ):
79+ """Generate complete release notes file."""
80+ release_notes = f"""## CF CLI Java Plugin { version }
81+
82+ Plugin for profiling Java applications and getting heap and thread-dumps.
83+
84+ ## Changes
85+
86+ { changelog_content }
87+
88+ ## Installation
89+
90+ ### Installation via CF Community Repository
91+
92+ Make sure you have the CF Community plugin repository configured or add it via:
93+ ```bash
94+ cf add-plugin-repo CF-Community http://plugins.cloudfoundry.org
95+ ```
96+
97+ Trigger installation of the plugin via:
98+ ```bash
99+ cf install-plugin -r CF-Community "java"
100+ ```
101+
102+ ### Manual Installation
103+
104+ Download this specific release ({ version } ) and install manually:
105+
106+ ```bash
107+ # on Mac arm64
108+ cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/{ version } /cf-cli-java-plugin-macos-arm64
109+ # on Windows x86
110+ cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/{ version } /cf-cli-java-plugin-windows-amd64
111+ # on Linux x86
112+ cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/download/{ version } /cf-cli-java-plugin-linux-amd64
113+ ```
114+
115+ Or download the latest release:
116+
117+ ```bash
118+ # on Mac arm64
119+ cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-macos-arm64
120+ # on Windows x86
121+ cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-windows-amd64
122+ # on Linux x86
123+ cf install-plugin https://github.com/SAP/cf-cli-java-plugin/releases/latest/download/cf-cli-java-plugin-linux-amd64
124+ ```
125+
126+ **Note:** On Linux and macOS, if you get a permission error, run `chmod +x [cf-cli-java-plugin]` on the plugin binary.
127+ On Windows, the plugin will refuse to install unless the binary has the `.exe` file extension.
128+
129+ You can verify that the plugin is successfully installed by looking for `java` in the output of `cf plugins`.
130+ """
131+
132+ with open ("release_notes.md" , 'w' ) as f :
133+ f .write (release_notes )
134+
78135def main ():
79136 if len (sys .argv ) != 4 :
80137 print ("Usage: update_version.py <major> <minor> <build>" )
81138 print ("Example: update_version.py 4 1 0" )
82139 sys .exit (1 )
83-
140+
84141 try :
85142 major = int (sys .argv [1 ])
86143 minor = int (sys .argv [2 ])
87144 build = int (sys .argv [3 ])
88145 except ValueError :
89146 print ("Error: Version numbers must be integers" )
90147 sys .exit (1 )
91-
148+
92149 version = f"{ major } .{ minor } .{ build } "
93150 version_arg = f"{ major } .{ minor } .{ build } " if (major + minor + build ) != 0 else sys .argv [1 ]
94151 # Accept any -rc suffix, e.g. 4.0.0-rc, 4.0.0-rc1, 4.0.0-rc2
@@ -117,29 +174,38 @@ def main():
117174 section_content = content [start_pos :].strip ()
118175 with open (changelog_file , 'w' ) as f :
119176 f .write (section_content )
177+
178+ # Generate full release notes for RC
179+ generate_release_notes (sys .argv [1 ], section_content )
180+
120181 print (f"✅ RC release: Changelog for { base_version } saved to { changelog_file } " )
182+ print (f"✅ RC release: Full release notes saved to release_notes.md" )
121183 sys .exit (0 )
122-
184+
123185 go_file = Path ("cf_cli_java_plugin.go" )
124186 readme_file = Path ("README.md" )
125187 changelog_file = Path ("release_changelog.txt" )
126-
188+
127189 # Update Go version
128190 success = update_version_in_go_file (go_file , major , minor , build )
129191 if not success :
130192 sys .exit (1 )
131-
193+
132194 # Process README changelog
133195 success , changelog_content = process_readme_changelog (readme_file , version )
134196 if not success :
135197 sys .exit (1 )
136-
198+
137199 # Write changelog content to a file for the workflow to use
138200 with open (changelog_file , 'w' ) as f :
139201 f .write (changelog_content )
140-
202+
203+ # Generate full release notes
204+ generate_release_notes (version , changelog_content )
205+
141206 print (f"✅ Version updated successfully to { version } " )
142207 print (f"✅ Changelog content saved to { changelog_file } " )
208+ print (f"✅ Full release notes saved to release_notes.md" )
143209
144210if __name__ == "__main__" :
145211 main ()
0 commit comments