🎓 A1Learner
🔍
0 of 47 lessons completed

Julia Versioning and Compat

Versioning and compat is a system for naming releases and bounding the versions a project accepts. It lets a reader tell at a glance whether an update is small or breaking.

A version number has three parts

The file below states a version. The printout shows the three parts in order.

write("version_a.toml", "[project]\nname = \"Demo\"\nversion = \"1.2.3\"\n")
print(read("version_a.toml", String))

A compat entry bounds a dependency version

The file below adds a bound for one dependency. The printout shows the bound.

write("version_b.toml", "[project]\nname = \"Demo\"\nversion = \"0.2.0\"\n\n[compat]\nExample = \"0.1\"\n")
print(read("version_b.toml", String))

A file can be checked for its compat section

The code reads the file back. The printout shows whether the section is present.

write("version_c.toml", "[project]\nname = \"Demo\"\nversion = \"0.2.0\"\n\n[compat]\nExample = \"0.1\"\n")
text = read("version_c.toml", String)
println(occursin("[compat]", text))

Example

write("version_example.toml", "[project]\nname = \"DemoApp\"\nversion = \"2.0.0\"\n\n[compat]\nExample = \"1\"\n")
print(read("version_example.toml", String))

Key points

  • Semantic version: a version number written as major, minor, and patch numbers.
  • Major rise: a major rise means an old use may break.
  • Minor rise: a minor rise adds a feature without breaking old uses.
  • Patch rise: a patch rise fixes a fault without adding a feature.
  • Compat entry: a bound in Project.toml that limits which dependency versions are accepted.

In this example, the code writes a project file with a name, a version, and a bound. It reads the file back. It prints the full file.

Note

a tight bound is safer when a dependency changes often.

Try it Yourself

Edit the code, then press Run.

Running is simulated · JuliaHub

Exercise

What does version 2.0.0 signal when the major number rises from 1 to 2?