Skip to content

Commit 07328c8

Browse files
add fragment
1 parent 743b265 commit 07328c8

File tree

4 files changed

+75
-16
lines changed

4 files changed

+75
-16
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# REQUIRED
2+
# Kind can be one of:
3+
# - breaking-change: a change to previously-documented behavior
4+
# - deprecation: functionality that is being removed in a later release
5+
# - bug-fix: fixes a problem in a previous version
6+
# - enhancement: extends functionality but does not break or fix existing behavior
7+
# - feature: new functionality
8+
# - known-issue: problems that we are aware of in a given version
9+
# - security: impacts on the security of a product or a user’s deployment.
10+
# - upgrade: important information for someone upgrading from a prior version
11+
# - other: does not fit into any of the other categories
12+
kind: feature
13+
14+
# REQUIRED for all kinds
15+
# Change summary; a 80ish characters long description of the change.
16+
summary: Support outputting Markdown files.
17+
18+
# REQUIRED for breaking-change, deprecation, known-issue
19+
# Long description; in case the summary is not enough to describe the change
20+
# this field accommodate a description without length limits.
21+
description: |
22+
Updates the `render` command to accept `--file_type` set to either `asciidoc` or `markdown`.
23+
24+
When set to `asciidoc`, it renders a single AsciiDoc file for a given version using the existing `asciidoc-embedded` template.
25+
26+
When set to `markdown`, it renders three Markdown files for a given version:
27+
28+
* Release notes: Creates an `index.md` file using `markdown-index-template`.
29+
* Breaking changes: Creates a `breaking.md` file using `markdown-breaking-template`.
30+
* Deprecations: Creates a `deprecations.md` file using `markdown-deprecations-template`.
31+
32+
# REQUIRED for breaking-change, deprecation, known-issue
33+
# impact:
34+
35+
# REQUIRED for breaking-change, deprecation, known-issue
36+
# action:
37+
38+
# REQUIRED for all kinds
39+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
40+
component:
41+
42+
# AUTOMATED
43+
# OPTIONAL to manually add other PR URLs
44+
# PR URL: A link the PR that added the changeset.
45+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
46+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
47+
# Please provide it if you are adding a fragment for a different PR.
48+
pr:
49+
- https://github.com/elastic/elastic-agent-changelog-tool/pull/213
50+
51+
# AUTOMATED
52+
# OPTIONAL to manually add other issue URLs
53+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
54+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
55+
# issue: https://github.com/owner/repo/1234

cmd/render.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import (
1717
var RenderLongDescription = `Use this command to render the consolidated changelog.
1818
1919
--version is required. Consolidated changelog version (x.y.z) in 'changelogs' folder
20-
--file_type is required. Specify the file_type: 'asciidoc' or 'markdown'`
20+
--file_type is optional. Specify the file_type: 'asciidoc' or 'markdown'
21+
--template is optional. Specify full path to your template file or use predefined templates. Default: asciidoc-embedded`
2122

2223
func RenderCmd(fs afero.Fs) *cobra.Command {
2324
renderCmd := &cobra.Command{
@@ -42,6 +43,11 @@ func RenderCmd(fs afero.Fs) *cobra.Command {
4243
return fmt.Errorf("error parsing flag 'file_type': %w", err)
4344
}
4445

46+
template, err := cmd.Flags().GetString("template")
47+
if err != nil {
48+
return fmt.Errorf("error parsing flag 'template': %w", err)
49+
}
50+
4551
c, err := changelog.FromFile(fs, fmt.Sprintf("./%s/%s.yaml", dest, version))
4652
if err != nil {
4753
return fmt.Errorf("error loading changelog from file: %w", err)
@@ -55,23 +61,29 @@ func RenderCmd(fs afero.Fs) *cobra.Command {
5561
} else if file_type == "markdown" {
5662
r_index := changelog.NewRenderer(fs, c, renderedDest, "markdown-index", repo)
5763
if err := r_index.Render(); err != nil {
58-
return fmt.Errorf("cannot build asciidoc file: %w", err)
64+
return fmt.Errorf("cannot build markdown file: %w", err)
5965
}
6066
r_breaking := changelog.NewRenderer(fs, c, renderedDest, "markdown-breaking", repo)
6167
if err := r_breaking.Render(); err != nil {
62-
return fmt.Errorf("cannot build asciidoc file: %w", err)
68+
return fmt.Errorf("cannot build markdown file: %w", err)
6369
}
6470
r_deprecations := changelog.NewRenderer(fs, c, renderedDest, "markdown-deprecations", repo)
6571
if err := r_deprecations.Render(); err != nil {
66-
return fmt.Errorf("cannot build asciidoc file: %w", err)
72+
return fmt.Errorf("cannot build markdown file: %w", err)
73+
}
74+
} else {
75+
r := changelog.NewRenderer(fs, c, renderedDest, template, repo)
76+
if err := r.Render(); err != nil {
77+
return fmt.Errorf("cannot build file: %w", err)
6778
}
6879
}
6980

7081
return nil
7182
},
7283
}
7384

74-
renderCmd.Flags().String("file_type", viper.GetString("file_type"), "The file type used to generate the changelog: `asciidoc` or `markdown`")
85+
renderCmd.Flags().String("file_type", viper.GetString("file_type"), "The file type of the rendered release notes: `asciidoc` or `markdown`")
86+
renderCmd.Flags().String("template", viper.GetString("template"), "The template used to generate the changelog")
7587
renderCmd.Flags().String("version", "", "The version of the consolidated changelog being created")
7688
err := renderCmd.MarkFlagRequired("version")
7789
if err != nil {

config.changelog.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
owner: elastic
2+
repo: elastic-agent-changelog-tool
3+
rendered_changelog_destination: changelog

config.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)