Build Artifacts and Semantic Versioning Explained
A customer reports a bug, and your teammate asks which version they run. "The one from last week, I think" is not an answer: nobody knows which code that is or whether the fix shipped. This lesson explains build artifacts and semantic versioning: what a version promises, how it leads back to the exact code, and why it must never change.
What a build artifact is
As lesson 2 put it, a build artifact is the packaged result of a build that you install and run: a container image, a Python wheel (a .whl file), a Java jar (a zip of compiled Java code) or a tarball (a .tar.gz archive). The package stage from lesson 4 makes it.
The rule is build once, promote many. The pipeline builds the artifact one time and stores it, labelled with its version and its commit SHA, the ID of the commit it was built from. To promote an artifact is to deploy that same stored artifact, byte for byte, to the next environment: dev, then staging, then production. Each environment adds its own config, never its own build.
Why not rebuild for production? A second build can pull in a newer dependency or base image (the image yours starts from), so you would ship something nobody tested. In the flowchart, only one box builds anything: every environment shows the same version and SHA.
Semantic versioning: what MAJOR.MINOR.PATCH promises
Semantic versioning (SemVer) gives the three numbers of MAJOR.MINOR.PATCH fixed meanings, so the number alone tells users whether an upgrade is safe. The meanings refer to your public API (application programming interface): what other code relies on, such as a library's functions or a web service's endpoints, the URL paths it answers, like /orders.
- PATCH goes up for a backward-compatible bug fix, meaning code that worked with 2.7.4 still works with 2.7.5.
- MINOR goes up for a backward-compatible new feature, and PATCH resets to 0: 2.7.4 becomes 2.8.0.
- MAJOR goes up for a breaking change, one that makes some existing callers fail: 2.7.4 becomes 3.0.0.
The aha in the diagram is the reset: after 2.7.4 comes 3.0.0, never 3.7.4, because bumping a number sets every number to its right back to 0.
The table applies the rules to a web service at 1.4.2. In its last row, what decides the bump is who relies on the change, not how small the edit is.
| Change at 1.4.2 | Bumps | Next |
|---|---|---|
| Fix a typo in an error message | PATCH | 1.4.3 |
Add a new endpoint, /receipts | MINOR | 1.5.0 |
Mark /v1/orders as deprecated (due for removal) | MINOR | 1.5.0 |
Remove the /v1/orders endpoint | MAJOR | 2.0.0 |
| Rename a response field, even to fix a typo | MAJOR | 2.0.0 |
Below 1.0.0, as in 0.9.3, SemVer says anything may change at any time; releasing 1.0.0 promises a stable API.
A pre-release is a test version not yet promised stable, written after a hyphen, as in 2.0.0-rc.1 (release candidate 1). It sorts before the final release: 2.0.0-beta < 2.0.0-rc.1 < 2.0.0-rc.2 < 2.0.0. Keep the dot: after it, numbers compare as numbers, so rc.11 sorts after rc.2. Without it, rc11 and rc2 compare character by character, putting rc11 first.
Tying a version to its code: tags and SHAs
The commit SHA is a 40-character hexadecimal hash, or fingerprint, of the commit's contents, named after SHA-1, the algorithm Git uses by default. People usually quote the first seven characters, such as 7f3c2a1.
A git tag is a name pointing to one commit. Release tags are usually annotated tags, which also record who made them, when and why. By convention the tag adds a v: the tag is v1.4.2, the version 1.4.2. In your own repository, tag the current commit and push the tag:
git tag -a v1.4.2 -m "Release 1.4.2"
git push origin v1.4.2
A plain git push does not send tags, which is why you name it. The output ends with this line:
* [new tag] v1.4.2 -> v1.4.2
If git tag says fatal: tag 'v1.4.2' already exists, that version is taken: release the next number instead of moving the tag.
CI stamps the SHA on every build. It knows the commit it is building (GitHub Actions provides it as GITHUB_SHA) and adds it to the artifact as an extra image tag, such as sample-app:7f3c2a1, or as an image label (a key-value note stored in the image) under the standard key org.opencontainers.image.revision. Any running artifact then leads back to its source. Lesson 13 does this hands-on.
Immutability: 1.4.2 means one thing forever
An artifact is immutable when its content never changes once published. SemVer makes this a rule: a released version's contents must not be modified, and any change needs a new version. If 1.4.2 means different code on Monday and Friday, the label no longer tells you what runs, and rolling back to 1.4.2 may not restore what you had.
The JavaScript registry npm enforces this: it never accepts the same name and version twice, even after an unpublish. Container image tags are looser: pushing a new image under an existing tag repoints it. So treat release tags as write-once; lesson 7 covers the fixed alternative, the image digest, a fingerprint of the image's content.
The most-moved tag is latest, simply the tag Docker uses when you give none. It points at whatever was last pushed with that tag, not necessarily the newest release. Two servers that pull latest an hour apart can run different code, and a rollback has nothing fixed to return to. Deploy an exact version, such as sample-app:1.4.2.
Changelogs and release notes
A version number says how big a change is, not what changed. A changelog, usually CHANGELOG.md in the repository, lists each version's notable changes, newest first. The Keep a Changelog convention sorts them under Added, Changed, Deprecated, Removed, Fixed and Security, below an Unreleased section for upcoming work. Here is the sample service's changelog (dates illustrative):
## [Unreleased]
## [2.0.0] - 2026-11-20
### Removed
- The /v1/orders endpoint. Use /v2/orders.
## [1.5.0] - 2026-10-02
### Added
- A /receipts endpoint for order receipts.
### Deprecated
- The /v1/orders endpoint, to be removed in 2.0.0.
Each heading explains its number: Removed is why 2.0.0 is MAJOR, and Deprecated warned users a release earlier. Write for the people upgrading, not a dump of commit messages, which Keep a Changelog calls "full of noise".
Release notes tell the same story for one release. A GitHub release is built on a git tag, and its Generate release notes button drafts a list of merged pull requests and contributors for you to edit.
Check yourself
Your library is at 3.2.5. A bug fix also renames a public function that other teams call. What is the next version, and why?
4.0.0. The rename makes existing callers fail, and any breaking change bumps MAJOR however small the edit, resetting MINOR and PATCH to 0.
Staging approved image 1.4.2. Later, someone rebuilds the same commit and pushes it as 1.4.2 again. Why is that a problem if the code did not change?
The rebuild can pull in newer dependencies or a newer base image, so production gets an untested build under a tested label. A change needs a new version, such as 1.4.3.
A bug report says "version 1.4.2". How do you find the exact code, and why would latest make it harder?
Check out the tag v1.4.2, or read the SHA stamped on the artifact: each names one commit. latest may have moved since the server pulled it, so the name no longer says which commit runs.