hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 1 | #!/usr/bin/python2.7 |
| 2 | |
| 3 | import os |
| 4 | import subprocess |
| 5 | import fileinput |
| 6 | import time |
| 7 | |
onqtam | e6d0d51 | 2016-04-27 23:23:16 +0300 | [diff] [blame] | 8 | # the version of the release |
| 9 | version_major = "1" |
| 10 | version_minor = "0" |
| 11 | version_patch = "0" |
| 12 | |
| 13 | version = version_major + "." + version_minor + "." + version_patch |
| 14 | |
| 15 | # update version in the header file |
onqtam | e6d0d51 | 2016-04-27 23:23:16 +0300 | [diff] [blame] | 16 | doctest_contents = "" |
| 17 | for line in fileinput.input(["../doctest/doctest.h"]): |
onqtam | f3a680f | 2016-04-30 03:15:07 +0300 | [diff] [blame] | 18 | if line.startswith("#define DOCTEST_VERSION_MAJOR "): |
onqtam | e6d0d51 | 2016-04-27 23:23:16 +0300 | [diff] [blame] | 19 | doctest_contents += "#define DOCTEST_VERSION_MAJOR " + version_major + "\n" |
onqtam | f3a680f | 2016-04-30 03:15:07 +0300 | [diff] [blame] | 20 | elif line.startswith("#define DOCTEST_VERSION_MINOR "): |
onqtam | e6d0d51 | 2016-04-27 23:23:16 +0300 | [diff] [blame] | 21 | doctest_contents += "#define DOCTEST_VERSION_MINOR " + version_minor + "\n" |
onqtam | f3a680f | 2016-04-30 03:15:07 +0300 | [diff] [blame] | 22 | elif line.startswith("#define DOCTEST_VERSION_PATCH "): |
onqtam | e6d0d51 | 2016-04-27 23:23:16 +0300 | [diff] [blame] | 23 | doctest_contents += "#define DOCTEST_VERSION_PATCH " + version_patch + "\n" |
onqtam | f3a680f | 2016-04-30 03:15:07 +0300 | [diff] [blame] | 24 | elif line.startswith("#define DOCTEST_VERSION "): |
| 25 | doctest_contents += "#define DOCTEST_VERSION \"" + version + "\"\n" |
onqtam | e6d0d51 | 2016-04-27 23:23:16 +0300 | [diff] [blame] | 26 | else: |
| 27 | doctest_contents += line |
| 28 | |
| 29 | readme = open("../doctest/doctest.h", "w") |
| 30 | readme.write(doctest_contents) |
| 31 | readme.close() |
| 32 | |
| 33 | os.system("git add ../doctest/doctest.h") |
| 34 | |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 35 | # run generate_html.py |
| 36 | print("generating html documentation from markdown") |
| 37 | os.system("python generate_html.py") |
| 38 | |
onqtam | e6d0d51 | 2016-04-27 23:23:16 +0300 | [diff] [blame] | 39 | # update changelog |
| 40 | os.chdir("../") |
| 41 | os.system("github_changelog_generator --future-release " + version) |
| 42 | os.system("git add CHANGELOG.md") |
| 43 | os.chdir("scripts") |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 44 | |
onqtam | e6d0d51 | 2016-04-27 23:23:16 +0300 | [diff] [blame] | 45 | examples = "../examples/" |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 46 | ''' |
| 47 | # create readme files in examples with 'try it online' badges with permalinks |
| 48 | examples_skip = ["multiprocess"] |
| 49 | |
| 50 | for dir in os.listdir(examples): |
| 51 | if not os.path.isdir(examples + dir): |
| 52 | continue |
| 53 | |
| 54 | # skip folders with more than 1 source file |
| 55 | sources = [s for s in os.listdir(examples + dir) if ".cpp" in s] |
| 56 | if dir in examples_skip or len(sources) > 1 or len(sources) == 0: |
| 57 | continue |
| 58 | |
| 59 | print("generating readme for example '" + examples + dir + "'") |
| 60 | |
| 61 | proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + dir + "/" + sources[0], stdout = subprocess.PIPE) |
| 62 | url = proc.stdout.read().strip() |
| 63 | |
| 64 | if not url.startswith("http"): |
| 65 | print("skipping current example because of crappy url: '" + url + "'\n") |
| 66 | continue |
| 67 | |
| 68 | readme = open(examples + dir + "/README.md", "w") |
| 69 | readme.write("[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")") |
| 70 | readme.close() |
| 71 | os.system("git add " + examples + dir + "/README.md") |
| 72 | ''' |
| 73 | |
| 74 | # update main readme 'try it online' badge permalink |
| 75 | print("updating main readme") |
| 76 | proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + "hello_world/main.cpp", stdout = subprocess.PIPE) |
| 77 | url = proc.stdout.read().strip() |
| 78 | |
| 79 | readme_contents = "" |
| 80 | for line in fileinput.input(["../README.md"]): |
| 81 | if line.startswith("[![Try it online]"): |
| 82 | readme_contents += "[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")\n" |
| 83 | else: |
| 84 | readme_contents += line |
| 85 | |
| 86 | readme = open("../README.md", "w") |
| 87 | readme.write(readme_contents) |
| 88 | readme.close() |
| 89 | |
| 90 | os.system("git add ../README.md") |