autoversion automatically updates the provided channel to version in markdown files.
(ctx context.Context, channel, version string)
| 313 | // autoversion automatically updates the provided channel to version in markdown |
| 314 | // files. |
| 315 | func (r *releaseCommand) autoversion(ctx context.Context, channel, version string) error { |
| 316 | var files []string |
| 317 | |
| 318 | // For now, scope this to docs, perhaps we include README.md in the future. |
| 319 | if err := afero.Walk(r.fs, "docs", func(path string, _ fs.FileInfo, err error) error { |
| 320 | if err != nil { |
| 321 | return err |
| 322 | } |
| 323 | if strings.EqualFold(filepath.Ext(path), ".md") { |
| 324 | files = append(files, path) |
| 325 | } |
| 326 | return nil |
| 327 | }); err != nil { |
| 328 | return xerrors.Errorf("walk failed: %w", err) |
| 329 | } |
| 330 | |
| 331 | for _, file := range files { |
| 332 | err := r.autoversionFile(ctx, file, channel, version) |
| 333 | if err != nil { |
| 334 | return xerrors.Errorf("autoversion file failed: %w", err) |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | return nil |
| 339 | } |
| 340 | |
| 341 | // autoversionMarkdownPragmaRe matches the autoversion pragma in markdown files. |
| 342 | // |