Skip to content

Commit 2b66305

Browse files
committed
+ --version command
generate version.ml file so that compile-time version is used
1 parent 86567a8 commit 2b66305

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
_build
22
*.merlin
33
*.install
4+
src/version.ml

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ default: build
55
start:
66
dune exec -- ./src/monorobot.exe
77

8-
build:
8+
build: gen_version
99
dune build src/monorobot.exe
1010

11+
gen_version:
12+
./gen_version.sh
13+
1114
test:
1215
dune runtest
1316

@@ -20,4 +23,5 @@ fmt:
2023
dune build @fmt --auto-promote
2124

2225
clean:
26+
rm -f src/version.ml
2327
dune clean

gen_version.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
VERSION=$(git describe --always --tags --dirty=+M)
4+
cat > src/version.ml <<- EOF
5+
(* do not edit; generated by gen_version.sh *)
6+
7+
let current = "$VERSION"
8+
EOF

src/monorobot.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ let check_slack =
119119

120120
let default_cmd =
121121
let doc = "the notification bot" in
122-
Term.(ret (const (`Help (`Pager, None)))), Term.info "monorobot" ~doc
122+
Term.(ret (const (`Help (`Pager, None)))), Term.info "monorobot" ~doc ~version:Version.current
123123

124124
let cmds = [ run; check_gh; check_slack ]
125125

0 commit comments

Comments
 (0)