Sub topic 12
How GitHub Releases Build on Tags
This chapter assumes you can create and push Git tags, and that you know the difference between lightweight and annotated tags. It explains what a GitHub Release adds on top of a tag and how the two are linked.
A release is a tag plus published content
A Git tag is a name for a commit. It lives in the Git repository and works with any host. A GitHub Release is a GitHub feature. It is a page attached to a tag, and it holds a title, release notes, optional downloadable files, and a state such as draft or pre-release.
Git itself knows nothing about releases. If you clone a repository, you receive its tags, but you do not receive the release notes or the uploaded files. Those are stored by GitHub, not in your Git history.
| Item | Stored in | Contains |
|---|---|---|
| Tag | Git repository | Name, target commit, and for annotated tags the tagger, date and message |
| Release | GitHub | Title, notes, attached files, draft and pre-release flags, link to a tag |
How the link works
Every release is tied to one tag name. There are two ways to get that tag:
- You push an existing tag first, then create the release from it. This is the usual route, because you choose exactly which commit is released.
- You create the release and name a tag that does not exist yet. GitHub creates the tag for you, on the target branch or commit you pick, when the release is published.
The second route is convenient, but a tag created this way is lightweight, so it has no message or signature. If you want an annotated or signed tag, create and push it yourself first.
git tag -a v1.1.0 -m "Release 1.1.0"
git push origin v1.1.0After the push, the tag appears in the repository's tag list. It is not yet a release. A tag with no release shows up only as a tag, and GitHub also offers downloads of the source code at that tag as .zip and .tar.gz archives.
What GitHub adds
- Release notes describe what changed, and GitHub can generate them from merged pull requests.
- Assets are files you upload, such as compiled binaries. GitHub adds the source archives automatically.
- States let you prepare a release as a draft or mark it as a pre-release.
- A "latest" label marks the most recent full release, which is what the repository's front page shows.
Later chapters cover each of these. For now, remember that they belong to the release, not to the tag.
Deleting and moving tags affects releases
Because a release depends on its tag, tag changes have side effects. If you delete a tag that a published release uses, the release can be left without a tag, and it may show as a draft. If you move a tag to another commit, the release page and its source archives follow the tag to the new commit, but any binaries you uploaded still come from the old one. Avoid moving published tags for this reason.
Exercise
You pushed the tag v2.0.0 and then created a release for it. A colleague runs git clone on the repository. Which parts do they receive: the tag, the release notes, the uploaded binaries?
Show answer
They receive the tag v2.0.0 and the commit it points to. The release notes and uploaded binaries are stored by GitHub, not in Git, so cloning does not include them.