Skip to content

Commit

Permalink
Replaced update-version-string.sh with python version
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed Nov 2, 2023
1 parent a1aee3e commit bd09b6b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ OCPINDENT = ocp-indent \

.PHONY: all
all :
./update-version-string.sh
python3 update-version-string.py
dune build @all

.PHONY: podman-build
Expand All @@ -15,7 +15,7 @@ podman-build:

.PHONY: release-static
release-static :
./update-version-string.sh
python3 update-version-string.py
OCAMLPARAM='_,ccopt=-static' dune build --release bin/docfd.exe
mkdir -p statically-linked
cp -f _build/default/bin/docfd.exe statically-linked/docfd
Expand Down
34 changes: 34 additions & 0 deletions update-version-string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import re

ml_path = "bin/version_string.ml"

version = ""

with open("CHANGELOG.md") as f:
for line in f:
if line.startswith("## "):
version = line.split(" ")[1].strip()
break

print(f"Detected version for Docfd: {version}")

print(f"Writing to {ml_path}")

with open(ml_path, "w") as f:
f.write(f"let s = \"{version}\"")
f.write("\n")

print(f"Replacing version string in dune-project")

dune_project_lines = []
dune_project_new_lines = []

with open("dune-project") as f:
dune_project_lines = f.readlines()

for line in dune_project_lines:
dune_project_new_lines.append(re.sub(r"\(version.*", f"(version {version})", line))

with open("dune-project", "w") as f:
for line in dune_project_new_lines:
f.write(line)
18 changes: 0 additions & 18 deletions update-version-string.sh

This file was deleted.

0 comments on commit bd09b6b

Please sign in to comment.