Skip to content

Commit 3071c62

Browse files
package all markdown templates in one command
1 parent 3286c50 commit 3071c62

File tree

5 files changed

+71
-24
lines changed

5 files changed

+71
-24
lines changed

cmd/render.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,24 @@ func RenderCmd(fs afero.Fs) *cobra.Command {
5252
return fmt.Errorf("error loading changelog from file: %w", err)
5353
}
5454

55-
r := changelog.NewRenderer(fs, c, renderedDest, template, repo)
56-
57-
if err := r.Render(); err != nil {
58-
return fmt.Errorf("cannot build asciidoc file: %w", err)
55+
if template == "asciidoc-embedded" {
56+
r := changelog.NewRenderer(fs, c, renderedDest, template, repo)
57+
if err := r.Render(); err != nil {
58+
return fmt.Errorf("cannot build asciidoc file: %w", err)
59+
}
60+
} else if template == "markdown" {
61+
r_index := changelog.NewRenderer(fs, c, renderedDest, "markdown-index", repo)
62+
if err := r_index.Render(); err != nil {
63+
return fmt.Errorf("cannot build asciidoc file: %w", err)
64+
}
65+
r_breaking := changelog.NewRenderer(fs, c, renderedDest, "markdown-breaking", repo)
66+
if err := r_breaking.Render(); err != nil {
67+
return fmt.Errorf("cannot build asciidoc file: %w", err)
68+
}
69+
r_deprecations := changelog.NewRenderer(fs, c, renderedDest, "markdown-deprecations", repo)
70+
if err := r_deprecations.Render(); err != nil {
71+
return fmt.Errorf("cannot build asciidoc file: %w", err)
72+
}
5973
}
6074

6175
return nil

docs/configuration.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
# Configuration options
22

3-
`elastic-agent-changelog-tool` has configuration options available to change it's behaviour.
3+
`elastic-agent-changelog-tool` has configuration options available to change its behaviour.
44

5-
All settings are managed via the [`settings`][settings] package, using [`spf13/viper`][viper].
5+
All settings are managed via the [`settings`][settings] package, using [`spf13/viper`][viper].
66
Configurations are bound to environment variables with same name and `ELASTIC_AGENT_CHANGELOG` prefix using [`viper.BindEnv`][bindenv].
77

88
This CLI supports and adhere to cross platform XDG Standard provided by [`OpenPeeDeeP/xdg`][xdg].
99

10-
|Settings key|Default value|Note|
10+
| Settings | Default value | Description |
1111
|---|---|---|
12-
|`fragment_location`|`$GIT_REPO_ROOT/changelog/fragments`|The location of changelog fragments used by the CLI. By default `fragment_root` + `fragment_path`.|
12+
|`fragment_location`|`$GIT_REPO_ROOT/changelog/fragments`|The location of changelog fragments used by the CLI. By default `fragment_root` + `fragment_path`.|
1313
|`fragment_path`|`changelog/fragments`|The path in `fragment_root` where to locate changelog fragments.|
1414
|`fragment_root`|`$GIT_REPO_ROOT`|The root folder for `fragment_location`.|
1515

1616
## Configuration file
1717

18-
Not supported yet.
18+
Add a `config.changelog.yaml` file to the repo where you're generating release notes.
19+
20+
When generating Markdown files, at a minimum you should set the following settings:
21+
22+
| Setting | Default value | Description |
23+
|---|---|---|
24+
| `owner` (required) | `elastic` | The owner of the GitHub repo. |
25+
| `repo` (required) || The name of the GitHub repo. |
26+
| `rendered_changelog_destination` | `changelog` | The directory where you want to put the generated files.<br><br>When generating Markdown files, this should probably be `docs/release-notes/_snippets`. |
1927

2028
## Supported Environment Variables
2129

docs/getting-started.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ $ elastic-agent-changelog-tool new "my test fragment"
2525
This will create `./changelog/fragments/<timestamp>-my-test-fragment.yaml` with this content:
2626

2727
```yaml
28+
# REQUIRED
2829
# Kind can be one of:
2930
# - breaking-change: a change to previously-documented behavior
3031
# - deprecation: functionality that is being removed in a later release
@@ -37,25 +38,39 @@ This will create `./changelog/fragments/<timestamp>-my-test-fragment.yaml` with
3738
# - other: does not fit into any of the other categories
3839
kind: feature
3940

41+
# REQUIRED for all kinds
4042
# Change summary; a 80ish characters long description of the change.
41-
summary:
43+
summary: {{.Summary}}
4244

45+
# REQUIRED for breaking-change, deprecation, known-issue
4346
# Long description; in case the summary is not enough to describe the change
4447
# this field accommodate a description without length limits.
45-
#description:
48+
# description:
4649

50+
# REQUIRED for breaking-change, deprecation, known-issue
51+
# impact:
52+
53+
# REQUIRED for breaking-change, deprecation, known-issue
54+
# action:
55+
56+
# REQUIRED for all kinds
4757
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
4858
component:
4959

50-
# PR URL; optional; the PR number that added the changeset.
60+
# AUTOMATED
61+
# OPTIONAL to manually add other PR URLs
62+
# PR URL: A link the PR that added the changeset.
5163
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
5264
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
5365
# Please provide it if you are adding a fragment for a different PR.
54-
#pr: https://github.com/owner/repo/1234
66+
# pr: https://github.com/owner/repo/1234
5567

68+
# AUTOMATED
69+
# OPTIONAL to manually add other issue URLs
5670
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
5771
# If not present is automatically filled by the tooling with the issue linked to the PR number.
58-
#issue: https://github.com/owner/repo/1234
72+
# issue: https://github.com/owner/repo/1234
73+
5974
```
6075

6176
Ensure `kind` is correct and fill the `summary` field with a brief description.
@@ -80,7 +95,7 @@ entries:
8095
kind: feature
8196
pr:
8297
- https://github.com/elastic/elastic-agent-changelog-tool/pull/13
83-
issue:
98+
issue:
8499
- https://github.com/elastic/elastic-agent-changelog-tool/issues/21
85100
timestamp: 1649924282
86101
file:
@@ -93,12 +108,26 @@ There will be multiple entries, one for each files in `changelog/fragments`.
93108

94109
## 5. Render the consolidated changelog
95110

96-
_Note_: at the moment there is only one renderer implemented: Asciidoc.
111+
### Markdown
112+
113+
From the root folder of the repository run:
114+
115+
```
116+
$ elastic-agent-changelog-tool render --version 0.1.0 --template markdown
117+
```
118+
119+
This will create three files:
120+
121+
* `./changelog/0.1.0/index.md`
122+
* `./changelog/0.1.0/breaking.md`
123+
* `./changelog/0.1.0/deprecations.md`
124+
125+
### AsciiDoc
97126

98127
From the root folder of the repository run:
99128

100129
```
101-
$ elastic-agent-changelog-tool render --version 0.1.0
130+
$ elastic-agent-changelog-tool render --version 0.1.0 --template asciidoc-embedded
102131
```
103132

104133
This will create `./changelog/0.1.0.asciidoc`.

internal/changelog/renderer.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func NewRenderer(fs afero.Fs, c Changelog, dest string, templ string, repo strin
3939
}
4040

4141
func (r Renderer) Render() error {
42-
log.Printf("render changelog for version: %s\n", r.changelog.Version)
42+
log.Printf("render %s for version: %s\n", r.templ, r.changelog.Version)
4343

4444
tpl, err := r.Template()
4545
if err != nil {
@@ -133,11 +133,7 @@ func (r Renderer) Render() error {
133133
if len(td.KnownIssue) > 0 {
134134
links = append(
135135
links,
136-
fmt.Sprintf(
137-
"[Known issues](/release-notes/known-issues.md#%s-%s-known-issues)",
138-
r.repo,
139-
r.changelog.Version,
140-
),
136+
"[Known issues](/release-notes/known-issues.md)",
141137
)
142138
}
143139
if len(td.BreakingChange) > 0 {

internal/settings/settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func setDefaults() {
5959
viper.GetString("fragment_path")))
6060

6161
viper.SetDefault("changelog_destination", "changelog")
62-
// viper.SetDefault("rendered_changelog_destination", "changelog")
62+
viper.SetDefault("rendered_changelog_destination", "changelog")
6363

6464
viper.SetDefault("template", "asciidoc-embedded")
6565
}

0 commit comments

Comments
 (0)