nolint:revive // Long function is fine for a sequential release flow.
(ctx context.Context, inv *serpent.Invocation, executor ReleaseExecutor, ghAvailable, gpgConfigured, dryRun bool)
| 20 | |
| 21 | //nolint:revive // Long function is fine for a sequential release flow. |
| 22 | func runRelease(ctx context.Context, inv *serpent.Invocation, executor ReleaseExecutor, ghAvailable, gpgConfigured, dryRun bool) error { |
| 23 | w := inv.Stderr |
| 24 | |
| 25 | // --- Release landscape --- |
| 26 | infof(w, "Checking current releases...") |
| 27 | allTags, err := allSemverTags() |
| 28 | if err != nil { |
| 29 | return xerrors.Errorf("listing tags: %w", err) |
| 30 | } |
| 31 | |
| 32 | var latestMainline *version |
| 33 | for _, t := range allTags { |
| 34 | if t.Pre == "" { |
| 35 | latestMainline = &t |
| 36 | break |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | stableMinor := -1 |
| 41 | latestStableStr := "(unknown)" |
| 42 | if latestMainline != nil { |
| 43 | stableMinor = latestMainline.Minor - 1 |
| 44 | // Find highest tag in the stable minor series. |
| 45 | for _, t := range allTags { |
| 46 | if t.Major == latestMainline.Major && t.Minor == stableMinor && t.Pre == "" { |
| 47 | latestStableStr = t.String() |
| 48 | break |
| 49 | } |
| 50 | } |
| 51 | if latestStableStr == "(unknown)" { |
| 52 | latestStableStr = fmt.Sprintf("(none found for v%d.%d.x)", latestMainline.Major, stableMinor) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | fmt.Fprintln(w) |
| 57 | mainlineStr := "(none)" |
| 58 | if latestMainline != nil { |
| 59 | mainlineStr = latestMainline.String() |
| 60 | } |
| 61 | fmt.Fprintf(w, " Latest mainline release: %s\n", pretty.Sprint(cliui.BoldFmt(), mainlineStr)) |
| 62 | fmt.Fprintf(w, " Latest stable release: %s\n", pretty.Sprint(cliui.BoldFmt(), latestStableStr)) |
| 63 | fmt.Fprintln(w) |
| 64 | |
| 65 | // --- Branch detection --- |
| 66 | currentBranch, err := gitOutput("branch", "--show-current") |
| 67 | if err != nil { |
| 68 | return xerrors.Errorf("detecting branch: %w", err) |
| 69 | } |
| 70 | |
| 71 | // Two modes: |
| 72 | // 1. On "main" — for tagging release candidates (RCs). |
| 73 | // 2. On "release/X.Y" — for releases and patches. |
| 74 | // RCs are tagged directly on main to avoid the toil of |
| 75 | // cherry-picking hundreds of commits onto a release branch. |
| 76 | // The release/X.Y branch is only cut when the release is |
| 77 | // ready. |
| 78 | // |
| 79 | // Detached HEAD is common: the release manager checks out a |
no test coverage detected