Skip to content

Commit 0a22b3d

Browse files
rename template to file_type
1 parent b6b455c commit 0a22b3d

File tree

3 files changed

+53
-46
lines changed

3 files changed

+53
-46
lines changed

cmd/render.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,16 @@ import (
88
"fmt"
99
"log"
1010

11-
"github.com/elastic/elastic-agent-changelog-tool/internal/assets"
1211
"github.com/elastic/elastic-agent-changelog-tool/internal/changelog"
1312
"github.com/spf13/afero"
1413
"github.com/spf13/cobra"
1514
"github.com/spf13/viper"
1615
)
1716

18-
var RenderLongDescription = fmt.Sprintf(`Use this command to render the consolidated changelog.
17+
var RenderLongDescription = `Use this command to render the consolidated changelog.
1918
2019
--version is required. Consolidated changelog version (x.y.z) in 'changelogs' folder
21-
--template is optional. Specify full path to your template file or use predefined templates. Default: asciidoc-embedded
22-
23-
Predefined templates:
24-
%s
25-
`, assets.GetEmbeddedTemplates().String())
20+
--file_type is required. Specify the file_type: 'asciidoc' or 'markdown'`
2621

2722
func RenderCmd(fs afero.Fs) *cobra.Command {
2823
renderCmd := &cobra.Command{
@@ -42,22 +37,22 @@ func RenderCmd(fs afero.Fs) *cobra.Command {
4237
return fmt.Errorf("error parsing flag 'version': %w", err)
4338
}
4439

45-
template, err := cmd.Flags().GetString("template")
40+
file_type, err := cmd.Flags().GetString("file_type")
4641
if err != nil {
47-
return fmt.Errorf("error parsing flag 'template': %w", err)
42+
return fmt.Errorf("error parsing flag 'file_type': %w", err)
4843
}
4944

5045
c, err := changelog.FromFile(fs, fmt.Sprintf("./%s/%s.yaml", dest, version))
5146
if err != nil {
5247
return fmt.Errorf("error loading changelog from file: %w", err)
5348
}
5449

55-
if template == "asciidoc-embedded" {
56-
r := changelog.NewRenderer(fs, c, renderedDest, template, repo)
50+
if file_type == "asciidoc" {
51+
r := changelog.NewRenderer(fs, c, renderedDest, "asciidoc-embedded", repo)
5752
if err := r.Render(); err != nil {
5853
return fmt.Errorf("cannot build asciidoc file: %w", err)
5954
}
60-
} else if template == "markdown" {
55+
} else if file_type == "markdown" {
6156
r_index := changelog.NewRenderer(fs, c, renderedDest, "markdown-index", repo)
6257
if err := r_index.Render(); err != nil {
6358
return fmt.Errorf("cannot build asciidoc file: %w", err)
@@ -76,7 +71,7 @@ func RenderCmd(fs afero.Fs) *cobra.Command {
7671
},
7772
}
7873

79-
renderCmd.Flags().String("template", viper.GetString("template"), "The template used to generate the changelog")
74+
renderCmd.Flags().String("file_type", viper.GetString("file_type"), "The file type used to generate the changelog: `asciidoc` or `markdown`")
8075
renderCmd.Flags().String("version", "", "The version of the consolidated changelog being created")
8176
err := renderCmd.MarkFlagRequired("version")
8277
if err != nil {

docs/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ There will be multiple entries, one for each files in `changelog/fragments`.
113113
From the root folder of the repository run:
114114

115115
```
116-
$ elastic-agent-changelog-tool render --version 0.1.0 --template markdown
116+
$ elastic-agent-changelog-tool render --version 0.1.0 --file_type markdown
117117
```
118118

119119
This will create three files:
@@ -127,7 +127,7 @@ This will create three files:
127127
From the root folder of the repository run:
128128

129129
```
130-
$ elastic-agent-changelog-tool render --version 0.1.0 --template asciidoc-embedded
130+
$ elastic-agent-changelog-tool render --version 0.1.0 --file_type asciidoc
131131
```
132132

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

docs/usage.md

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ $ elastic-agent-changelog-tool build --version=next --owner <owner> --repo <repo
4343

4444
then render the consolidated changelog with:
4545
```
46-
$ elastic-agent-changelog-tool render --version=next --template <template>
46+
$ elastic-agent-changelog-tool render --version=next --file_type <asciidoc|markdown>
4747
```
4848

49-
The template value can be chosen from a predefined internal list of templates (`render --help`) or use a full path to your template file.
50-
5149
An example is [`../changelog/0.1.0.yaml`](../changelog/0.1.0.yaml).
5250

5351
### My PR does not need a changelog
@@ -82,9 +80,8 @@ $ elastic-agent-changelog-tool build --version=next --owner <owner> --repo <repo
8280

8381
then render the consolidated changelog with:
8482
```
85-
$ $ elastic-agent-changelog-tool render --version=next --template <template>
83+
$ elastic-agent-changelog-tool render --version=next --file_type <asciidoc|markdown>
8684
```
87-
The template value can be chosen from a predefined internal list of templates (`render --help`) or use a full path to your template file.
8885

8986
An example is [`../changelog/0.1.0.yaml`](../changelog/0.1.0.yaml).
9087

@@ -97,8 +94,14 @@ The side effect is that the changelog will include all entries from latest stabl
9794

9895
1. Create consolidated changelog with `$ elastic-agent-changelog-tool build --version <version> --owner <owner> --repo <repo>`;
9996
* This will create `./changelog/x.y.z.yaml`;
100-
2. Create rendered changelog with `$ elastic-agent-changelog-tool render --version <version> --template <template>`;
101-
* This will generate an asciidoc file in the `changelog/` directory;
97+
2. Create rendered changelog with `$ elastic-agent-changelog-tool render --version <version> --file_type <asciidoc|markdown>`;
98+
99+
Depending on the specified `file_type`, this will generate the following files:
100+
* `markdown`:
101+
* Release notes: `./changelog/<version>/index.md`
102+
* Breaking changes: `./changelog/<version>/breaking.md`
103+
* Deprecations: `./changelog/<version>/deprecations.md`
104+
* `asciidoc`: `changelog/<version>.asciidoc`
102105
3. Use the rendered changelog.
103106

104107
**Note**: we do not remove fragments, as they will be needed for the stable release version changelog.
@@ -111,30 +114,39 @@ The side effect is that the changelog will include all entries from latest stabl
111114

112115
These steps require [GitHub Authentication](./github-authentication.md).
113116

114-
* Wait for the last BC of the release. If another BC is generated after that or a patch version for a previous minor is released, you might need to restart the process.
115-
* Create a branch **from the commit of the BC**.
116-
* From the root folder of the repository run:
117-
118-
```
119-
$ elastic-agent-changelog-tool build --version x.y.z --owner <owner> --repo <repo>
120-
```
121-
* Where:
122-
* `x.y.z` is the version to release.
123-
* `owner` is the user / organization the repository to use belongs to. The default value is `elastic`.
124-
* `repo` is the name of the repository containing the issues / PRs, etc. The default value is `elastic-agent`.
125-
* This will create `./changelog/x.y.z.yaml`.
126-
* From the root of the repository run:
127-
```
128-
$ elastic-agent-changelog-tool cleanup
129-
```
130-
* Commit the previous changes (consolidated changelod and removed files)
131-
* From the root folder of the repository run:
132-
```
133-
$ elastic-agent-changelog-tool render --version x.y.z --template <template>
134-
```
135-
* This will generate an asciidoc fragment in the `changelog/` directory.
136-
* Integrate the generated fragment into the changelog. If the changelog is stored in the same repository, commit the changes in this same branch.
137-
* Create a PR with the changes to the `x.y` branch.
117+
1. Wait for the last BC of the release. If another BC is generated after that or a patch version for a previous minor is released, you might need to restart the process.
118+
1. Create a branch **from the commit of the BC**.
119+
1. From the root folder of the repository run:
120+
121+
```
122+
$ elastic-agent-changelog-tool build --version x.y.z --owner <owner> --repo <repo>
123+
```
124+
125+
Where:
126+
127+
* `x.y.z` is the version to release.
128+
* `owner` is the user / organization the repository to use belongs to. The default value is `elastic`.
129+
* `repo` is the name of the repository containing the issues / PRs, etc. The default value is `elastic-agent`.
130+
131+
This will create `./changelog/x.y.z.yaml`.
132+
1. From the root of the repository run:
133+
```
134+
$ elastic-agent-changelog-tool cleanup
135+
```
136+
1. Commit the previous changes (consolidated changelod and removed files)
137+
1. From the root folder of the repository run:
138+
```
139+
$ elastic-agent-changelog-tool render --version x.y.z --file_type <asciidoc|markdown>
140+
```
141+
142+
Depending on the specified `file_type`, this will generate the following files:
143+
* `markdown`:
144+
* Release notes: `./changelog/<version>/index.md`
145+
* Breaking changes: `./changelog/<version>/breaking.md`
146+
* Deprecations: `./changelog/<version>/deprecations.md`
147+
* `asciidoc`: `changelog/<version>.asciidoc`
148+
1. Integrate the generated fragment into the changelog. If the changelog is stored in the same repository, commit the changes in this same branch.
149+
1. Create a PR with the changes to the `x.y` branch.
138150
139151
140152
### On Release Day

0 commit comments

Comments
 (0)