| 1 |
# Releasing a new version of `go-tpm-tools` |
| 2 |
|
| 3 |
This repository contains multiple Go modules, so care is needed when creating a |
| 4 |
new version. Be sure to follow these steps as it's very easy to accidentally |
| 5 |
cut a release (as GitHub doesn't have sufficiently advanced |
| 6 |
[tag protections](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/configuring-tag-protection-rules)). |
| 7 |
|
| 8 |
## Create the main release PR |
| 9 |
|
| 10 |
Create a standalone PR titled "Release vX.Y.Z" against the `main` branch. This |
| 11 |
PR should (ideally) be an empty commit, but might contain some minor changes if |
| 12 |
we want to get them in for a specific release. You can create an empty commit |
| 13 |
by running: |
| 14 |
``` |
| 15 |
git commit --allow-empty |
| 16 |
``` |
| 17 |
|
| 18 |
The description of the PR should just be the release notes that we want to |
| 19 |
publish in the GitHub Release. The notes should just have one-line summaries |
| 20 |
of the PRs in the release. Trivial PRs can be omitted and related PRs can be |
| 21 |
combined in a single line. It should have the following subsections: |
| 22 |
- "Breaking Changes" (backwards-incompatible changes to the package API) |
| 23 |
- "New Features" (backwards-compatible changes to the package API) |
| 24 |
- "Bug Fixes" (fixes to any particular issues) |
| 25 |
- "Other Changes" (non-breaking code changes or Doc/CI updates) |
| 26 |
|
| 27 |
Sections can be omitted if there wouldn't be any PRs under them. The |
| 28 |
[`v0.3.2` release notes](https://github.com/google/go-tpm-tools/releases/tag/v0.3.2) |
| 29 |
are a good example. We don't need to specifically mention who wrote what PR or |
| 30 |
link to the "Full Changelog". Users can just look this stuff up on GitHub on |
| 31 |
their own. |
| 32 |
|
| 33 |
This commit _should not_ change the version numbers in [`go.work`](go.work), |
| 34 |
[`cmd/go.mod`](cmd/go.mod), or [`launcher/go.mod`](launcher/go.mod). When |
| 35 |
reviewing the PR, the reviewers and author should decide if the release |
| 36 |
will be a major, minor, or patch release. Note that the PR should only consist |
| 37 |
of a single commit and be "squashed" instead of "merged". |
| 38 |
|
| 39 |
## Tag the releases |
| 40 |
|
| 41 |
After the new release is in the `main` branch, we need to create git tags so |
| 42 |
that the Go version system can find the releases. Generally the author of the |
| 43 |
PR should do this. |
| 44 |
|
| 45 |
Tagging can be done via the GitHub Web UI. On the |
| 46 |
[Releases Page](https://github.com/google/go-tpm-tools/releases), |
| 47 |
click [Draft a New Release](https://github.com/google/go-tpm-tools/releases/new). |
| 48 |
In that draft, create the git tag corresponding to your release, and copy the |
| 49 |
approved release notes into the description. |
| 50 |
|
| 51 |
Check that the preview of the release notes looks good, and click |
| 52 |
"Publish release". The release and tag should now be visible on GitHub. |
| 53 |
|
| 54 |
## Follow-up Submodule update PR |
| 55 |
|
| 56 |
After the main release has been merged and tagged, we need to update the go.mod |
| 57 |
files in the various submodules. First, you should update the version number in: |
| 58 |
- [`go.work`](go.work) |
| 59 |
- [`cmd/go.mod`](cmd/go.mod) |
| 60 |
- [`launcher/go.mod`](launcher/go.mod) |
| 61 |
|
| 62 |
Next, we cleanup the modules by running: |
| 63 |
- run `go mod tidy` in each module directory |
| 64 |
- run `go work sync` in the root directory |
| 65 |
- this requires Go 1.20 or later |
| 66 |
|
| 67 |
Finally, create a PR with the title "Submodule update for vX.Y.Z". This PR |
| 68 |
doesn't need a description. The reviewers should just check that the above |
| 69 |
steps were done. Note that the PR should only consist |
| 70 |
of a single commit and be "squashed" instead of "merged". |
| 71 |
|
| 72 |
## Tagging the submodules |
| 73 |
|
| 74 |
The submodules must be tagged separately from the main library release. This |
| 75 |
is best done on the git command line. After the Submodule update PR has been |
| 76 |
merged, checkout the repo and check that your `HEAD` is on the commit for the |
| 77 |
submodule update PR on the `main` branch. This _should not_ be normal release |
| 78 |
commit `vX.Y.Z`, but a later commit. Then, run the following command: |
| 79 |
``` |
| 80 |
git tag "cmd/vX.Y.Z" && git tag "launcher/vX.Y.Z" |
| 81 |
``` |
| 82 |
replacing `vX.Y.Z` with the actual version number. |
| 83 |
|
| 84 |
Finally, double check that you've tagged the correct commit, and then push the |
| 85 |
tags to the `main` branch by running: |
| 86 |
``` |
| 87 |
git push origin "cmd/vX.Y.Z" "launcher/vX.Y.Z" |
| 88 |
``` |
| 89 |
|
| 90 |
The tags should then be visible at https://github.com/google/go-tpm-tools/tags |
| 91 |
|
| 92 |
## (Googlers only) sync code back into google3 |
| 93 |
|
| 94 |
Follow the directions at http://go/thirdpartygo#updating-imported-code to import |
| 95 |
the three modules back into google3. You will need to run the import script for |
| 96 |
each module. It's fine for the imports for all the modules to be in one CL. |