blob: 67fecc9f7193b072a8c16ca4b42d8479f1b0fbf7 [file] [log] [blame]
hardlyb1e7e142014-08-06 00:43:51 +03001#!/usr/bin/python2.7
2
3import os
onqtam90d95de2016-05-22 04:17:34 +03004import sys
hardlyb1e7e142014-08-06 00:43:51 +03005import subprocess
6import fileinput
7import time
8
onqtame6d0d512016-04-27 23:23:16 +03009# the version of the release
10version_major = "1"
11version_minor = "0"
12version_patch = "0"
13
14version = version_major + "." + version_minor + "." + version_patch
15
16# update version in the header file
onqtame6d0d512016-04-27 23:23:16 +030017doctest_contents = ""
18for line in fileinput.input(["../doctest/doctest.h"]):
onqtamf3a680f2016-04-30 03:15:07 +030019 if line.startswith("#define DOCTEST_VERSION_MAJOR "):
onqtame6d0d512016-04-27 23:23:16 +030020 doctest_contents += "#define DOCTEST_VERSION_MAJOR " + version_major + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030021 elif line.startswith("#define DOCTEST_VERSION_MINOR "):
onqtame6d0d512016-04-27 23:23:16 +030022 doctest_contents += "#define DOCTEST_VERSION_MINOR " + version_minor + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030023 elif line.startswith("#define DOCTEST_VERSION_PATCH "):
onqtame6d0d512016-04-27 23:23:16 +030024 doctest_contents += "#define DOCTEST_VERSION_PATCH " + version_patch + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030025 elif line.startswith("#define DOCTEST_VERSION "):
26 doctest_contents += "#define DOCTEST_VERSION \"" + version + "\"\n"
onqtame6d0d512016-04-27 23:23:16 +030027 else:
28 doctest_contents += line
29
30readme = open("../doctest/doctest.h", "w")
31readme.write(doctest_contents)
32readme.close()
33
34os.system("git add ../doctest/doctest.h")
35
hardlyb1e7e142014-08-06 00:43:51 +030036# run generate_html.py
onqtam1586ea22016-05-21 18:02:26 +030037#print("generating html documentation from markdown")
38#os.system("python generate_html.py")
hardlyb1e7e142014-08-06 00:43:51 +030039
onqtame6d0d512016-04-27 23:23:16 +030040# update changelog
41os.chdir("../")
42os.system("github_changelog_generator --future-release " + version)
43os.system("git add CHANGELOG.md")
44os.chdir("scripts")
hardlyb1e7e142014-08-06 00:43:51 +030045
onqtame6d0d512016-04-27 23:23:16 +030046examples = "../examples/"
hardlyb1e7e142014-08-06 00:43:51 +030047'''
48# create readme files in examples with 'try it online' badges with permalinks
49examples_skip = ["multiprocess"]
50
51for 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
onqtamfe80dc92016-05-22 13:32:20 +030075sys.exit(0) # for now dont continue to update the wandbox link - working with the api has changed
76
hardlyb1e7e142014-08-06 00:43:51 +030077# update main readme 'try it online' badge permalink
78print("updating main readme")
79proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + "hello_world/main.cpp", stdout = subprocess.PIPE)
80url = proc.stdout.read().strip()
81
82readme_contents = ""
83for line in fileinput.input(["../README.md"]):
onqtam90d95de2016-05-22 04:17:34 +030084 if line.startswith("[![Try it online]"):
85 readme_contents += "[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](" + url + ")\n"
hardlyb1e7e142014-08-06 00:43:51 +030086 else:
87 readme_contents += line
88
89readme = open("../README.md", "w")
90readme.write(readme_contents)
91readme.close()
92
93os.system("git add ../README.md")