Semantic Versioning

Video loading...

  • 0:01
    Semantic Versioning with Addison Berry
  • 0:03
    The term "semantic versioning," or SemVer,
  • 0:07
    is a way of numbering a software release.
  • 0:12
    And it's something that's being adopted more and more
  • 0:15
    widely by different software projects.
  • 0:18
    So in this tutorial, we're just going
  • 0:21
    to walk through a few basic steps.
  • 0:22
    We're going to explain exactly what semantic versioning, how
  • 0:25
    that works.
  • 0:26
    We'll talk about some of the benefits
  • 0:27
    and why people are switching over to semantic versioning.
  • 0:31
    And we'll wrap up by showing how you can get more information
  • 0:34
    and the actual specifications for it.
  • 0:37
    So semantic versioning, as I said earlier, SemVer
  • 0:41
    is a short form of it that you may see out there.
  • 0:44
    So if someone was talking about SemVer,
  • 0:45
    that's what they're talking about, semantic versioning.
  • 0:48
    And it uses a three-number system instead of a two-number system
  • 0:52
    for a release number on a piece of software.
  • 0:54
    So you might be familiar with software release numbers
  • 0:58
    that do something like 1.0, 1.1, 1.2.
  • 1:02
    And with semantic versioning, we use three.
  • 1:04
    And we're going to take a look at that in a second
  • 1:06
    to see what that means and what it looks like.
  • 1:10
    One of the important things about semantic versioning
  • 1:12
    as well is that it requires a public API.
  • 1:15
    So if you are saying you're using semantic versioning,
  • 1:18
    you have to have some kind of publicly declared API
  • 1:21
    because the semantic versioning numbering system is
  • 1:25
    dependent on whether; things like whether or not you're breaking
  • 1:28
    your API or how the version is changing the API.
  • 1:32
    So if you don't have something that's sort of publicly declared
  • 1:35
    that can be sort of looked at and measured against so you can
  • 1:38
    actually see is this actually changing and breaking something
  • 1:41
    or not, then the semantic versioning numbering
  • 1:44
    doesn't tend to make, well, as much sense.
  • 1:47
    So it's an assumption that you have a public API that people are
  • 1:50
    tracking and able to use and interact with.
  • 1:52
    And then with semantic versioning, you're
  • 1:54
    letting them know what changes have been made
  • 1:58
    to the software that affects the API.
  • 2:00
    And then they can make a decision on whether or not
  • 2:02
    they want to upgrade, or if they have to upgrade,
  • 2:05
    what other changes they're going to have to make in their dependencies.
  • 2:08
    So let's take a look at the actual numbers themselves.
  • 2:10
    So here's just a made up version number.
  • 2:13
    And you can see that we have three numbers.
  • 2:15
    So the first number is the major version number.
  • 2:17
    The second is minor version.
  • 2:19
    And then the third number is a patch number
  • 2:22
    basically meant for bug patching.
  • 2:25
    So let's walk through each of the numbers individually.
  • 2:28
    So a major version, whenever you increment the major version number,
  • 2:34
    you are actually breaking the API.
  • 2:37
    There's no backwards compatibility with the old API.
  • 2:40
    So something-- like in this instance, this
  • 2:42
    is version 8 of this software.
  • 2:44
    This is not backwards compatible with the version 7 of the software.
  • 2:50
    For a minor version, this does not break backwards compatibility
  • 2:55
    with the version number before it.
  • 2:56
    So 8.2 is backwards compatible with 8.1.
  • 3:01
    We didn't actually break anything major here.
  • 3:04
    This number is used for things that are like new features
  • 3:07
    or big changes that are being made in the software,
  • 3:10
    but it's not breaking backwards compatibility.
  • 3:13
    The last number, this third number, is the patch
  • 3:15
    number, which is meant for bug fixes.
  • 3:18
    So every time we have a version of the software,
  • 3:20
    every time we do security updates or fix bugs
  • 3:23
    or those kinds of things, that just gets a patch number.
  • 3:26
    And that should never break backwards compatibility.
  • 3:28
    If you need to break backwards compatibility to fix those bugs,
  • 3:33
    then you're going to end up having to increment
  • 3:35
    to a whole new major version number.
  • 3:37
    So that is the basic numbering system.
  • 3:41
    That's why there are three numbers.
  • 3:42
    They each indicate different kinds of changes.
  • 3:45
    So by looking at the number, you can immediately
  • 3:47
    tell sort of what the state of the piece of software is.
  • 3:50
    So in this instance, we're on the eighth major version.
  • 3:53
    So there have been seven changes that
  • 3:55
    have broken backwards compatibility in the past.
  • 3:58
    We're on the second minor version, which means there have been two
  • 4:01
    feature changes and additions have been made.
  • 4:04
    And we're on the sixth bug fix or patch,
  • 4:07
    so there have been six bug fixes to the second minor version here.
  • 4:12
    So after we did our second big feature push,
  • 4:15
    we've had six bugs that we've fixed in the meantime.
  • 4:18
    So if we had another bug that came along from 8.2.6,
  • 4:23
    we would increment our release 8.2.7 for that bug fix.
  • 4:29
    But everything else is essentially the same.
  • 4:31
    Now, if we actually come along and we do a new feature, like we're
  • 4:34
    really changing stuff and adding some new stuff to the site,
  • 4:37
    we're going to increment the minor version up to 3
  • 4:40
    and that's going to reset the patch to 0, because there are
  • 4:43
    no actual bug fixes for version 3 yet.
  • 4:46
    So 8.3.0.
  • 4:48
    If we get to actually breaking the backwards compatibility
  • 4:51
    with the API, then we're going to increment
  • 4:54
    the major version number up to 9.
  • 4:57
    And we're going to zero out all of the rest of the numbers
  • 5:00
    because we don't have any features or bug fixes in version 9
  • 5:04
    yet when we first release it.
  • 5:07
    And we would begin all over.
  • 5:08
    Again our first feature would be 9.1.0,
  • 5:11
    and then our first bug fix to that would be 9.1.1.
  • 5:15
    So that's the basics of the numbers and what those numbers signify.
  • 5:18
    And it's very clear and distinct what each number is representing.
  • 5:23
    So when you look at the number, you should have a very good sense
  • 5:25
    of what the status of that code is, particularly
  • 5:29
    in comparison to previous versions.
  • 5:31
    Now, before you actually get to releasing something
  • 5:35
    and you're working on it, of course you also
  • 5:37
    want to keep track of your versions before you're talking about API
  • 5:40
    changes and features and those kinds of things.
  • 5:44
    So with initial development with semantic versioning,
  • 5:46
    you're going to use the major version number of 0.
  • 5:51
    So my first feature as I begin to work on my code
  • 5:55
    is going to be 0.1.0.
  • 5:57
    That's the first feature.
  • 5:59
    And as I add features, I will increment the minor number.
  • 6:02
    And of course, bug fixes will get the patch number.
  • 6:05
    You can also use pre-release strings with semantic versioning.
  • 6:09
    So things like alphas and betas and release candidates.
  • 6:12
    You can also put in numbers with those.
  • 6:16
    And you would just append that to the end of the release.
  • 6:19
    So your pre-release, before you actually release a real version,
  • 6:23
    would be 1.0.0 because that's where your public release-- like I've
  • 6:28
    been doing all of my development, I'm ready to go.
  • 6:31
    I'm going to put it out there for the public to begin using.
  • 6:33
    That's 1.0.0.
  • 6:35
    So if I was doing my alpha and then beta and release candidate
  • 6:39
    for that particular release, I would just put that at the end,
  • 6:43
    as you can see here in the slide.
  • 6:44
    So development, you're going to start with 0.
  • 6:48
    When you first make your software publicly available for other people
  • 6:51
    to use, you start off with a major version of 1.
  • 6:55
    And then you'll increment the three different numbers
  • 6:58
    as we just discussed in the previous slides.
  • 7:00
    So why go through this?
  • 7:02
    Why have three numbers and all of this like very
  • 7:04
    specific definition of what's going on?
  • 7:07
    One of the main motivations for doing this
  • 7:09
    was just to make really clear when you have
  • 7:12
    compatibility or dependency problems.
  • 7:14
    If someone is using your software, and especially
  • 7:17
    if they're using an API and they're using it in a code way
  • 7:19
    and they've written other code that's dependent on it
  • 7:21
    in some way, when those things change
  • 7:23
    it affects everybody else's work that they've done.
  • 7:26
    And so it makes it very clear from the version number what is going
  • 7:30
    on in terms of my code is compatible with or dependent upon 8.2.x.
  • 7:38
    Or 8.x.x.
  • 7:42
    People can decide what they need to do.
  • 7:43
    But if you break that API, then people will immediately
  • 7:47
    know that their compatibility and dependencies are probably broken
  • 7:50
    and then they're going to need to update their stuff.
  • 7:52
    So just to make it very clear which version people are using
  • 7:55
    and what that actually means, what the implications
  • 7:57
    are for other code that may be dependent on it.
  • 8:01
    It also really encourages well-defined APIs.
  • 8:04
    In order for you to know whether you're breaking an API
  • 8:07
    or if you are still fully backwards compatible,
  • 8:10
    you need to have a pretty clear idea of what your API is doing
  • 8:14
    and how people are using it.
  • 8:15
    And so it really helps to clearly define that and then when you make
  • 8:19
    changes to think about in terms of that backwards compatibility
  • 8:23
    in very clear terms.
  • 8:25
    And that just is better for everybody
  • 8:27
    in terms of documenting things and making sure
  • 8:29
    that people who are using the software
  • 8:31
    aren't caught by surprises.
  • 8:33
    It can also help with upgrade decisions.
  • 8:35
    If I'm just an end user of some software
  • 8:38
    and I see that a bug fix has come out,
  • 8:41
    chances are that's a good thing for me
  • 8:43
    to upgrade to get that bug fixed.
  • 8:47
    But I also know it's not going to majorly change anything in terms
  • 8:50
    of how I'm used to using the software.
  • 8:52
    If I see that the minor version has changed,
  • 8:54
    then this is a new feature.
  • 8:56
    There's some new change that's going on.
  • 8:58
    But it's not going to break how the software works,
  • 9:01
    so how I'm used to it working in terms of backwards compatibility.
  • 9:04
    And then if a major version comes along,
  • 9:06
    I know that things are going to be likely very, very different.
  • 9:09
    And it can change how I make my decision about whether or not
  • 9:12
    I should upgrade my software or not.
  • 9:14
    It's just a clearer message to people who are using the software.
  • 9:18
    So all around, it's just making things clearer and more explicit,
  • 9:23
    which is, of course, just going to be beneficial to everybody,
  • 9:26
    including developers of software so that you have a clear idea of what
  • 9:30
    it is you're creating and communicating that
  • 9:32
    well to the people who are using it.
  • 9:34
    If you want to find out more details and get the actual specification
  • 9:38
    for this, you can go to
  • 9:41
    And that is where you actually will find the explicit list That's where
  • 9:46
    it says things like, you have to have
  • 9:48
    a public API, how the numbering system works.
  • 9:51
    It also talks about some edge cases and other things
  • 9:54
    that I might not have covered in this short presentation.
  • 9:57
    And it gets versioned just like semantic versioning,
  • 10:01
    so you can always tell if there's been a major change
  • 10:04
    in the specification by the number of the semantic versioning website.
  • 10:09
    So in this short tutorial, we've covered what semantic versioning is
  • 10:14
    and how we actually use it with the three-number system, why this is
  • 10:18
    a good thing, and go check out more information at

Semantic Versioning


Semantic Versioning, or SemVer, is a relatively new specification for how to number software releases, which uses three numbers (e.g. 1.2.6) instead of two (e.g. 1.2). It is being used by more and more open source projects, including Drupal, as of Drupal 8. This presentation walks you through the numbering system so you can understand how to read and apply the version numbers correctly, along with understanding why more projects are adopting it.

Note: There is a typo in the slide that shows pre-release versions. The slide shows a period as the separator, when it should be a hyphen. I.e. 1.0.0.alpha1 should instead be 1.0.0-alpha1.

Log in or sign up to download companion files.