|
3 | 3 | When you have an update for `gen-ir`, there's a couple things that need to happen: |
4 | 4 |
|
5 | 5 | - Release a version in the `gen-ir` repo |
6 | | -- Update the version in the `homebrew-tap` repo, so brew picks up the update |
| 6 | +- Update the version(s) in the `homebrew-tap` repo, so brew picks up the update(s) |
7 | 7 |
|
8 | | -## Releasing a gen-ir version |
| 8 | +## Releasing a Gen IR version |
9 | 9 |
|
10 | | -To release a new version of `gen-ir`, create a Pull Request with your changes, ensuring the `build` pipeline finishes successfully, then attach one of the following labels to the PR. |
| 10 | +As mentioned in the [Branching Model](branching_model.md), features should be merged into the `develop` branch. You should never merge a feature directly to `main`. |
11 | 11 |
|
12 | | -- `merge-bump-major` |
13 | | - - This will merge the PR & bump a major version (i.e. 1.0.0 to 2.0.0) |
14 | | -- `merge-bump-minor` |
15 | | - - This will merge the PR & bump a minor version (i.e. 1.0.0 to 1.1.0) |
16 | | -- `merge-bump-patch` |
17 | | - - This will merge the PR & bump a patch version (i.e. 1.0.0 to 1.0.1) |
18 | | -- `merge-no-bump` |
19 | | - - This will merge the PR with no version bump |
| 12 | +To release a new version of `gen-ir`, create a release branch and open a merge request from the release branch (see the [Branching Model](branching_model.md)) to `main` at the commit point you're wanting to release and to `develop`. Allow any automated check, peer reviews, and - when approved - merge the request. |
20 | 13 |
|
21 | | -This will merge the PR, bump the version, fix the version in the `Versions.swift` file, push the commit to main, tag the _new_ commit with the version number, and perform a GitHub release with that tag. |
| 14 | +Then, on your local machine: |
22 | 15 |
|
23 | | -Now, navigate to the release and note the tag name & revision for the next part |
| 16 | +- Change to `main` and pull the changes |
| 17 | + - `git checkout main && git pull` |
| 18 | +- Create the new tag for the release: |
| 19 | + - `git tag -a 1.0.0 -m "Gen IR version: 1.0.0` |
| 20 | + - `git push --tags` |
| 21 | +- Change to `develop` and pull the changes |
| 22 | + - `git checkout develop && git pull` |
| 23 | +- Recreate the new `develop` tag for the release: |
| 24 | + - `git tag -d develop && git push --delete origin develop` |
| 25 | + - `git tag -a develop -m "Gen IR Develop version: <commit hash>` |
| 26 | + - `git push --tags` |
24 | 27 |
|
25 | | -## Updating Homebrew Tap |
| 28 | +Then, in the GitHub UI: |
26 | 29 |
|
27 | | -The formula for the tap lives in the [veracode/homebrew-taps](https://github.com/veracode/homebrew-tap) repo. This needs to be updated in order to propagate a new version to users. |
| 30 | +- Go to the [Releases](https://github.com/veracode/gen-ir/releases) page |
| 31 | +- Click `Draft a new release` |
| 32 | +- Set the title to the version name |
| 33 | +- From the drop down list, choose your newly created tag |
| 34 | +- Click the `Generate release notes` button to create a change log |
| 35 | +- Ensure `Set as the latest release` is checked |
| 36 | +- Click the `Publish` button |
28 | 37 |
|
29 | | -- Create a new branch: `gen_ir_<version>` |
30 | | -- Update the `gen-ir` formulae url.tag & url.revision keys to match the release the previous step made |
31 | | -- Open a PR with these changes _and these changes only!_. |
32 | | - - If any other changes are detected, or more than one commit is made, homebrew's automation will fail |
33 | | -- When checks pass, add the `pr-pull` label to the PR |
34 | | -- Automation will make a new release |
| 38 | +- Click `Draft a new release` |
| 39 | +- Set the title to `develop` |
| 40 | +- From the drop down list, choose your newly created `develop` tag |
| 41 | +- Click the `Generate release notes` button to create a change log |
| 42 | +- Ensure `Set as pre-release` is checked |
| 43 | +- Click the `Publish` button |
35 | 44 |
|
36 | | -Users can now run `brew update && brew upgrade` to update `gen-ir` and `brew install gen-ir` will install the latest version. |
| 45 | +A release has been made, congratulations. However there's additional steps for distributing the release via `brew`. |
| 46 | + |
| 47 | +## Distributing a release |
| 48 | + |
| 49 | +Gen IR uses a Homebrew Tap for distribution. In order for the Tap to see the new release, you need to update the [Gen IR Formula](https://github.com/veracode/homebrew-tap/blob/main/Formula/gen-ir.rb). |
| 50 | + |
| 51 | +> Note: You may have to update more than one formula! If you're releasing a new major or minor version, you'll need to ensure versioning of the formula is correct. See the section [Versioning Tap Releases](#versioning-tap-releases) for more information. |
| 52 | +
|
| 53 | +First, if you haven't already, checkout the `veracode/homebrew-tap` repo: |
| 54 | + |
| 55 | +```shell |
| 56 | +git clone [email protected]:veracode/homebrew-tap.git |
| 57 | +``` |
| 58 | + |
| 59 | +Then, do the following to increment the formula: |
| 60 | + |
| 61 | +- Create a new branch - replacing `<version>` with the released version: |
| 62 | + - `git checkout -b gen_ir_<version>` |
| 63 | +- Update the `gen-ir.rb` formula: |
| 64 | + - Change `url.tag`'s value to the tag's name |
| 65 | + - Change `url.revision` to the commit hash pointed to by the tag |
| 66 | +- Open a merge request with _only these changes!_ |
| 67 | + - If you have more than one commit, or change more than this single file - homebrews automation will refuse to merge the request. |
| 68 | +- When the `test-bot` check passes, add the `pr-pull` label to the request |
| 69 | +- Automation will make the new release |
| 70 | + |
| 71 | +Users can now run `brew update && brew upgrade gen-ir` to update to the latest version. |
| 72 | + |
| 73 | +## Versioning Tap Releases |
| 74 | + |
| 75 | +It is likely that you will need to do One More Thing, which is to ensure the formula is versioned correctly. |
| 76 | + |
| 77 | +Gen IR has the following policy on versions: |
| 78 | + |
| 79 | +- Gen IR will maintain formulae for one version behind _and_ any current prerelease versions |
| 80 | +- Any versioned formulae **must** use `keg_only :versioned_formula` |
| 81 | + - This means brew will _only_ install into the Cellar, and will not link into the brew prefix |
| 82 | +- Gen IR _will not_ maintain formulae for patch versions |
| 83 | + |
| 84 | +So, if you have released a new major or minor version you should: |
| 85 | + |
| 86 | +- Create a new versioned formula for the previous release to yours |
| 87 | +- Remove any now-deprecated formula(e) |
| 88 | + |
| 89 | +### Creating Versioned Formulae |
| 90 | + |
| 91 | +Using the history of the `homebrew-tap` find the version of the Gen IR formula you're looking for, then copy the file to the `Formula` folder renaming it like so: `gen-ir@<version>` |
| 92 | + |
| 93 | +Edit the file to: |
| 94 | + |
| 95 | +- change the name of the class to add the version, for example version 0.3.11 becomes: `GenIrAT0311`. |
| 96 | +- add the `keg_only :versioned_formula` tag after the `bottle`. |
| 97 | + |
| 98 | +> Note: it is a good idea to run `brew style Formulae/gen-ir@<version>.rb` before you push the commit! Brew is _very_ particular about the layout of a formula and the test-bot will fail if your key isn't in the right spot. |
0 commit comments