feat: update publiccode.yml automatically during release

This commit is contained in:
kolaente 2026-04-08 10:40:04 +02:00 committed by kolaente
parent f775f7de79
commit 415d5d23ad
1 changed files with 28 additions and 1 deletions

View File

@ -1877,10 +1877,16 @@ func (Dev) TagRelease(ctx context.Context, version string) error {
return fmt.Errorf("failed to update frontend package.json: %w", err)
}
// Update publiccode.yml version and release date
fmt.Println("Updating publiccode.yml...")
if err := updatePublicCodeYml(version); err != nil {
return fmt.Errorf("failed to update publiccode.yml: %w", err)
}
// Commit the changes
fmt.Println("Committing changes...")
commitMsg := fmt.Sprintf("chore: %s release preparations", version)
cmd := exec.CommandContext(ctx, "git", "add", "README.md", "CHANGELOG.md", "frontend/package.json")
cmd := exec.CommandContext(ctx, "git", "add", "README.md", "CHANGELOG.md", "frontend/package.json", "publiccode.yml")
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to stage files: %w", err)
}
@ -2024,6 +2030,27 @@ func updateFrontendPackageJSON(version string) error {
return nil
}
// updatePublicCodeYml updates the softwareVersion and releaseDate in publiccode.yml.
func updatePublicCodeYml(version string) error {
filePath := "publiccode.yml"
content, err := os.ReadFile(filePath)
if err != nil {
return fmt.Errorf("failed to read %s: %w", filePath, err)
}
reVersion := regexp.MustCompile(`(softwareVersion:\s*')([^']+)(')`)
newContent := reVersion.ReplaceAllString(string(content), "${1}"+version+"${3}")
reDate := regexp.MustCompile(`(releaseDate:\s*')([^']+)(')`)
newContent = reDate.ReplaceAllString(newContent, "${1}"+time.Now().Format("2006-01-02")+"${3}")
if err := os.WriteFile(filePath, []byte(newContent), 0o600); err != nil {
return fmt.Errorf("failed to write %s: %w", filePath, err)
}
return nil
}
// prependChangelog prepends the new changelog entries to CHANGELOG.md
func prependChangelog(newChangelog string) error {
changelogPath := "CHANGELOG.md"