Skip to content

Commit

Permalink
Simplify set_version
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Nov 15, 2024
1 parent 5f70c44 commit 5431c61
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions build/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ Usage: `ribasim path/to/model/ribasim.toml`
Documentation: https://ribasim.org/
"""

function set_version(filename, version; group = nothing)
"Use the git tag for `ribasim --version`,
so dev builds can be identified by <tag>-g<short-commit>"
function set_version(filename::String, tag::String)::Nothing
data = TOML.parsefile(filename)
if !isnothing(group)
data[group]["version"] = version
else
data["version"] = version
end
data["package"]["version"] = tag
open(filename, "w") do io
TOML.print(io, data)
end
return nothing
end

"""
Expand Down Expand Up @@ -119,7 +118,7 @@ function add_metadata(project_dir, license_file, output_dir, git_repo, readme)
end

# Override the Cargo.toml file with the git version
set_version("cli/Cargo.toml", tag; group = "package")
set_version("cli/Cargo.toml", tag)
end

main()

0 comments on commit 5431c61

Please sign in to comment.