Skip to content

Commit

Permalink
feat(changelog.md): merge changelog from repo and childRepo (#61)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukasz Dziedziak <[email protected]>
Signed-off-by: Charly Molter <[email protected]>
Co-authored-by: Charly Molter <[email protected]>
  • Loading branch information
lukidzi and lahabana authored Jan 14, 2025
1 parent 00cd1cc commit efcfd6b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
15 changes: 15 additions & 0 deletions cmd/release-tool/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,27 @@ var autoChangelog = &cobra.Command{
}
return res[i].PublishedAt.After(res[j].PublishedAt)
})
childReleases := map[string]github.GQLRelease{}
if config.childRepo != "" {
childResources, err := gqlClient.ReleaseGraphQL(config.childRepo)
if err != nil {
return err
}
for _, release := range childResources {
childReleases[release.Name] = release
}
}
_, _ = cmd.OutOrStdout().Write([]byte("# Changelog\n<!-- Autogenerated with (github.com/kumahq/ci-tools) release-tool changelog.md -->\n"))
for _, release := range res {
if !release.IsReleased() { // If the release is not an actual release don't add in changelog.md
continue
}
if strings.Contains(release.Description, "## Changelog") {
changelog := strings.SplitN(release.Description, "## Changelog", 2)[1]
if childRelease, found := childReleases[release.Name]; found && childRelease.IsReleased() && strings.Contains(release.Description, "## Changelog") {
changelog += fmt.Sprintf("\n### Includes [%s@%s](https://github.com/%s/releases/tag/%s) changelog", config.childRepo, childRelease.Name, config.childRepo, childRelease.Name)
changelog += strings.SplitN(childRelease.Description, "## Changelog", 2)[1]
}
_, _ = cmd.OutOrStdout().Write([]byte(fmt.Sprintf(`
## %s
> Released on %s%s
Expand Down Expand Up @@ -147,4 +161,5 @@ func init() {
versionChangelog.Flags().StringVar(&config.format, "format", string(FormatMarkdown), fmt.Sprintf("The output format (%s, %s)", FormatJson, FormatMarkdown))
versionChangelog.Flags().StringVar(&config.repo, "repo", "kumahq/kuma", "The repository to query")
autoChangelog.Flags().StringVar(&config.repo, "repo", "kumahq/kuma", "The repository to query")
autoChangelog.Flags().StringVar(&config.childRepo, "childRepo", "", "The child repository to query")
}
11 changes: 6 additions & 5 deletions cmd/release-tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ func main() {
var config Config

type Config struct {
branch string
repo string
fromTag string
format string
release string
branch string
repo string
childRepo string
fromTag string
format string
release string
}

var rootCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kumahq/ci-tools

go 1.22
go 1.23.4

require (
github.com/Masterminds/semver/v3 v3.3.1
Expand Down

0 comments on commit efcfd6b

Please sign in to comment.