-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
Copy pathpromote_docs
35 lines (30 loc) · 1.19 KB
/
promote_docs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
import argparse
from subprocess import check_call
def main():
parser = argparse.ArgumentParser(
description="Used to promote doc version and branch. Doesn't commit changes.")
parser.add_argument("version",
help="The new docs version")
parser.add_argument("branch",
help="The new docs branch")
args = parser.parse_args()
version = args.version
branch = args.branch
# make sure we have no dirty files in this branch (might throw off `make update`)
check_call("git clean -dfx", shell=True)
# edit the file
with open("libbeat/docs/version.asciidoc", "r") as f:
lines = f.readlines()
for i, line in enumerate(lines):
if line.startswith(":stack-version:"):
lines[i] = ":stack-version: {}\n".format(version)
if line.startswith(":branch:"):
lines[i] = ":branch: {}\n".format(branch)
if line.startswith(":doc-branch:"):
lines[i] = ":doc-branch: {}\n".format(branch)
with open("libbeat/docs/version.asciidoc", "w") as f:
f.writelines(lines)
check_call("make update", shell=True)
if __name__ == "__main__":
main()