-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #419 from y-yu/generate-version-from-opam-file
Generate `version.ml` from `satysfi.opam` to make releasing easy
- Loading branch information
Showing
5 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(executable | ||
(name genversion) | ||
(libraries str)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(lang dune 1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
let version_regex = Str.regexp {|^version: ?"\([0-9]+\.[0-9]+\.[0-9]+\)"$|} | ||
|
||
let () = | ||
let version = ref "" in | ||
let opam_file_path = Sys.argv.(1) in | ||
let channel_in = open_in opam_file_path in | ||
let search_version () = | ||
let cond = ref true in | ||
while !cond do | ||
let line = input_line channel_in in | ||
try | ||
let _ = Str.search_forward version_regex line 0 in | ||
version := Str.matched_group 1 line; | ||
cond := false | ||
with Not_found -> | ||
() | ||
done | ||
in | ||
search_version (); | ||
close_in channel_in; | ||
print_endline ("let version = \"" ^ !version ^ "\"") |