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