Some projects publish a .sig or .asc file next to the download. A checksum shows the file arrived intact, a signature also shows who made it.
gpg --import project-signing-key.asc
gpg --verify file.tar.gz.sig file.tar.gz
Give gpg --verify the signature first and the signed data second. The manual says the first argument should be the file with the detached signature and the remaining files should contain the signed data. Verifying with only the signature file is described as a strongly discouraged historical feature, so always name the data file.
Read the answer carefully. Good signature from followed by a name means the signature matches. You still have to check that the key fingerprint is the one the project publishes, because a signature from the wrong key is still a valid signature.
For scripts there is the smaller gpgv tool, used the same way: gpgv message.sig message.txt.
The caveat is about exit codes. The GnuPG examples say the program returns 0 if there are no severe errors and 1 if at least one signature was bad, and that using only the return code is not an appropriate way to verify a signature in a script. Use the status output or gpgv there. Also do not add --output when verifying a detached signature, because that produces an empty file.
Further reading: GnuPG: gpg(1) manual, GnuPG: GPG examples