From ed089581576c5f76543b1cb902dda8a13a18b05d Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 1 Mar 2026 00:02:16 -0700 Subject: [PATCH] fix(monorel): skip writing .goreleaser.yaml when content is unchanged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compare generated content against the file on disk before writing. If identical, do nothing — no write, no "wrote" message, no commit attempt. --- tools/monorel/main.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/monorel/main.go b/tools/monorel/main.go index ea0609f..08ffc8a 100644 --- a/tools/monorel/main.go +++ b/tools/monorel/main.go @@ -312,16 +312,17 @@ func initModuleGroup(group *moduleGroup, dryRun bool) { prefixParts := strings.Split(prefix, "/") projectName := prefixParts[len(prefixParts)-1] - // 1. Write .goreleaser.yaml (always regenerate so it stays current). + // 1. Write .goreleaser.yaml only when the content has changed. yamlContent := goreleaserYAML(projectName, bins) yamlPath := filepath.Join(modRoot, ".goreleaser.yaml") - isNewFile := true - if _, err := os.ReadFile(yamlPath); err == nil { - isNewFile = false - } + existing, readErr := os.ReadFile(yamlPath) + isNewFile := readErr != nil + isChanged := isNewFile || string(existing) != yamlContent if dryRun { - fmt.Fprintf(os.Stderr, "[dry-run] would write %s\n", yamlPath) - } else { + if isChanged { + fmt.Fprintf(os.Stderr, "[dry-run] would write %s\n", yamlPath) + } + } else if isChanged { if err := os.WriteFile(yamlPath, []byte(yamlContent), 0o644); err != nil { fatalf("writing %s: %v", yamlPath, err) }