Skip to content

Commit 15ff76e

Browse files
committed
Support documentation link update
1 parent 1794968 commit 15ff76e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

dev-tools/build_release.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,29 @@ def callback(line):
208208
return line
209209
process_file(readme_file, callback)
210210

211+
# Moves the README.md file from a snapshot to a release (documentation link)
212+
def remove_documentation_snapshot(readme_file, repo_url, release, branch):
213+
pattern = '* [%s-SNAPSHOT](%sblob/%s/README.md)' % (release, repo_url, branch)
214+
replacement = '* [%s](%sblob/v%s/README.md)' % (release, repo_url, release)
215+
def callback(line):
216+
# If we find pattern, we replace its content
217+
if line.find(pattern) >= 0:
218+
return line.replace(pattern, replacement)
219+
else:
220+
return line
221+
process_file(readme_file, callback)
222+
223+
# Add in README.markdown file the documentation for the next version
224+
def add_documentation_snapshot(readme_file, repo_url, release, snapshot, branch):
225+
pattern = '* [%s](%sblob/v%s/README.md)' % (release, repo_url, release)
226+
replacement = '* [%s-SNAPSHOT](%sblob/%s/README.md)' % (snapshot, repo_url, branch)
227+
def callback(line):
228+
# If we find pattern, we copy the line and replace its content
229+
if line.find(pattern) >= 0:
230+
return line.replace(pattern, replacement)+line
231+
else:
232+
return line
233+
process_file(readme_file, callback)
211234

212235
# Set release date in README.md file
213236
def set_date(readme_file):
@@ -603,8 +626,12 @@ def check_email_settings():
603626
artifact_name = find_from_pom('name')
604627
artifact_description = find_from_pom('description')
605628
project_url = find_from_pom('url')
629+
elasticsearch_version = find_from_pom('elasticsearch.version')
606630
print(' Artifact Id: [%s]' % artifact_id)
607631
print(' Release version: [%s]' % release_version)
632+
print(' Elasticsearch: [%s]' % elasticsearch_version)
633+
if elasticsearch_version.find('-SNAPSHOT') != -1:
634+
raise RuntimeError('Can not release with a SNAPSHOT elasticsearch dependency: %s' % elasticsearch_version)
608635

609636
# extract snapshot
610637
default_snapshot_version = guess_snapshot(release_version)
@@ -626,6 +653,7 @@ def check_email_settings():
626653
try:
627654
pending_files = [POM_FILE, README_FILE]
628655
remove_maven_snapshot(POM_FILE, release_version)
656+
remove_documentation_snapshot(README_FILE, project_url, release_version, src_branch)
629657
remove_version_snapshot(README_FILE, release_version)
630658
set_date(README_FILE)
631659
set_install_instructions(README_FILE, artifact_id, release_version)
@@ -657,6 +685,7 @@ def check_email_settings():
657685

658686
add_maven_snapshot(POM_FILE, release_version, snapshot_version)
659687
add_version_snapshot(README_FILE, release_version, snapshot_version)
688+
add_documentation_snapshot(README_FILE, project_url, release_version, snapshot_version, src_branch)
660689
add_pending_files(*pending_files)
661690
commit_snapshot()
662691

0 commit comments

Comments
 (0)