MCPcopy Index your code
hub / github.com/coder/coder / updateReleaseDocs

Function updateReleaseDocs

scripts/releaser/docs.go:401–493  ·  view source on GitHub ↗

updateReleaseDocs updates all release-related docs files and creates a PR with the changes. nolint:revive // dryRun flag is needed to control PR creation behavior.

(
	inv *serpent.Invocation,
	newVer version,
	channel string,
	dryRun bool,
)

Source from the content-addressed store, hash-verified

399//
400//nolint:revive // dryRun flag is needed to control PR creation behavior.
401func updateReleaseDocs(
402 inv *serpent.Invocation,
403 newVer version,
404 channel string,
405 dryRun bool,
406) error {
407 w := inv.Stderr
408
409 // Find the repo root (where .git is).
410 repoRoot, err := gitOutput("rev-parse", "--show-toplevel")
411 if err != nil {
412 return xerrors.Errorf("finding repo root: %w", err)
413 }
414
415 verStr := fmt.Sprintf("%d.%d.%d", newVer.Major, newVer.Minor, newVer.Patch)
416 vTag := "v" + verStr
417 branchName := fmt.Sprintf("docs/update-release-%s", vTag)
418
419 infof(w, "Updating release docs for %s (channel: %s)...", vTag, channel)
420 fmt.Fprintln(w)
421
422 if dryRun {
423 _, _ = fmt.Fprintf(w, "[DRYRUN] would update %s\n", releasesFile)
424 _, _ = fmt.Fprintf(w, "[DRYRUN] would update %s\n", kubernetesFile)
425 _, _ = fmt.Fprintf(w, "[DRYRUN] would update %s\n", rancherFile)
426 _, _ = fmt.Fprintf(w, "[DRYRUN] would create branch %s\n", branchName)
427 _, _ = fmt.Fprintf(w, "[DRYRUN] would create PR: chore(docs): update release docs for %s\n", vTag)
428 return nil
429 }
430
431 // Create a new branch from main.
432 if err := gitRun("checkout", "-b", branchName, "origin/main"); err != nil {
433 return xerrors.Errorf("creating branch: %w", err)
434 }
435
436 // Update the files.
437 if err := updateCalendarFile(repoRoot, newVer, channel); err != nil {
438 return xerrors.Errorf("updating calendar: %w", err)
439 }
440 successf(w, "Updated %s", releasesFile)
441
442 k8sPath := filepath.Join(repoRoot, kubernetesFile)
443 if err := updateAutoversionFile(k8sPath, channel, verStr); err != nil {
444 return xerrors.Errorf("updating kubernetes.md: %w", err)
445 }
446 successf(w, "Updated %s", kubernetesFile)
447
448 rancherPath := filepath.Join(repoRoot, rancherFile)
449 if err := updateRancherFile(rancherPath, channel, verStr); err != nil {
450 return xerrors.Errorf("updating rancher.md: %w", err)
451 }
452 successf(w, "Updated %s", rancherFile)
453
454 // Stage and commit.
455 if err := gitRun("add",
456 filepath.Join(repoRoot, releasesFile),
457 k8sPath,
458 rancherPath,

Callers 1

promptAndUpdateDocsFunction · 0.85

Calls 9

gitOutputFunction · 0.85
infofFunction · 0.85
gitRunFunction · 0.85
updateCalendarFileFunction · 0.85
successfFunction · 0.85
updateAutoversionFileFunction · 0.85
updateRancherFileFunction · 0.85
ghOutputFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected