How to decide when to rebuild on Linux?

So I'm making a GitHub Action to build and cache tools like SwiftFormat and SwiftLint to run in CI workflows. Since GitHub regularly updates the runners, I want to make sure that the tools are rebuilt when the environment changes enough to make the previous build invalid.

Currently I'm using uname -v, os.arch() and swift -version to decide that it's a compatible environment. I suspect that using lsb_release -c would be sufficient instead of uname -v but it's hard to test that.