blob: 078504b4cc90365bd30490937505d3831bcd5b0c [file] [log] [blame]
hardlyb1e7e142014-08-06 00:43:51 +03001#!/usr/bin/python2.7
2
3import os
4import subprocess
5import fileinput
6import time
7
onqtame6d0d512016-04-27 23:23:16 +03008# the version of the release
9version_major = "1"
10version_minor = "0"
11version_patch = "0"
12
13version = version_major + "." + version_minor + "." + version_patch
14
15# update version in the header file
onqtame6d0d512016-04-27 23:23:16 +030016doctest_contents = ""
17for line in fileinput.input(["../doctest/doctest.h"]):
onqtamf3a680f2016-04-30 03:15:07 +030018 if line.startswith("#define DOCTEST_VERSION_MAJOR "):
onqtame6d0d512016-04-27 23:23:16 +030019 doctest_contents += "#define DOCTEST_VERSION_MAJOR " + version_major + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030020 elif line.startswith("#define DOCTEST_VERSION_MINOR "):
onqtame6d0d512016-04-27 23:23:16 +030021 doctest_contents += "#define DOCTEST_VERSION_MINOR " + version_minor + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030022 elif line.startswith("#define DOCTEST_VERSION_PATCH "):
onqtame6d0d512016-04-27 23:23:16 +030023 doctest_contents += "#define DOCTEST_VERSION_PATCH " + version_patch + "\n"
onqtamf3a680f2016-04-30 03:15:07 +030024 elif line.startswith("#define DOCTEST_VERSION "):
25 doctest_contents += "#define DOCTEST_VERSION \"" + version + "\"\n"
onqtame6d0d512016-04-27 23:23:16 +030026 else:
27 doctest_contents += line
28
29readme = open("../doctest/doctest.h", "w")
30readme.write(doctest_contents)
31readme.close()
32
33os.system("git add ../doctest/doctest.h")
34
hardlyb1e7e142014-08-06 00:43:51 +030035# run generate_html.py
36print("generating html documentation from markdown")
37os.system("python generate_html.py")
38
onqtame6d0d512016-04-27 23:23:16 +030039# update changelog
40os.chdir("../")
41os.system("github_changelog_generator --future-release " + version)
42os.system("git add CHANGELOG.md")
43os.chdir("scripts")
hardlyb1e7e142014-08-06 00:43:51 +030044
onqtame6d0d512016-04-27 23:23:16 +030045examples = "../examples/"
hardlyb1e7e142014-08-06 00:43:51 +030046'''
47# create readme files in examples with 'try it online' badges with permalinks
48examples_skip = ["multiprocess"]
49
50for 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
75print("updating main readme")
76proc = subprocess.Popen('python send_to_wandbox.py ../doctest/ ' + examples + "hello_world/main.cpp", stdout = subprocess.PIPE)
77url = proc.stdout.read().strip()
78
79readme_contents = ""
80for 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
86readme = open("../README.md", "w")
87readme.write(readme_contents)
88readme.close()
89
90os.system("git add ../README.md")