Basic

Checking your own versions

The version is a claim about the artifact, and claims get stale. The check is a command that prints what the artifact actually carries, run against what you believe, which is the only way a mismatch is found before a release.

What you will see

MISMATCH - the build on the server is not the one you think. That is the bug a release without this check ships.

About 1 min of reading

Try It

Assert the version.

1

The check

actual = '2.4.1'; claimed = '2.5.0' print('MISMATCH' if actual != claimed else 'ok')

Before you run it, say out loud what it will print. Then open the answer.

What it prints
MISMATCH - the build on the server is not the one you think. That is the bug a release without this check ships.

Data Flow

A check compares claim to artifact.
1 Read the artifact
↓
2 Print what it carries
↓
3 Compare to the claim
↓
4 Exit non zero on mismatch
Line by line

Read the first example one line at a time. A line that prints shows what appears on screen; the rest set things up quietly.

actual = '2.4.1'; claimed = '2.5.0' sets nothing on screen
print('MISMATCH' if actual != claimed else 'ok') MISMATCH - the build on the server is not the one you think. That is the bug a release without this check ships.
Why this works
One command, all of it

A single command that prints version, build hash, and dependency lock is the report a release is made against. Three separate commands is three chances to forget one.

Fail loudly

A version check that prints a warning is a check that gets ignored. A check that exits non zero is one that a release script will not step past.

Examples

Print it at runtime

A command that reports the running version is the check that the right build is deployed. Without it, a deploy is a belief about a server you are not looking at.

Compare the two

The version in the build metadata and the version in the file name should be equal. A script that asserts it is what catches the mismatch that a release then ships.

Check the tag exists

Before a release, assert the tag is on the remote. A release with no reachable tag is a release that cannot be rebuilt, and the assertion is one line.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Pinning a version
Previous Lesson
Pinning a version
Next Lesson
Migrating saved data
Migrating saved data →