Skip to content

Commit ff9bbd8

Browse files
handle releases with no changes
1 parent 8e84739 commit ff9bbd8

File tree

3 files changed

+59
-10
lines changed

3 files changed

+59
-10
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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: enhancement
13+
14+
# REQUIRED for all kinds
15+
# Change summary; a 80ish characters long description of the change.
16+
summary: Handle releases with no changes.
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: If there are no changes included in the release — in other words, there are no changelog fragment files — the changelog YAML file will still be generated, but the entries will be an empty array. This helps clarify that the release didn't have any notable changes rather than the release notes are missing.
22+
23+
# REQUIRED for breaking-change, deprecation, known-issue
24+
# impact:
25+
26+
# REQUIRED for breaking-change, deprecation, known-issue
27+
# action:
28+
29+
# REQUIRED for all kinds
30+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
31+
component:
32+
33+
# AUTOMATED
34+
# OPTIONAL to manually add other PR URLs
35+
# PR URL: A link the PR that added the changeset.
36+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
37+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
38+
# Please provide it if you are adding a fragment for a different PR.
39+
pr: https://github.com/elastic/elastic-agent-changelog-tool/pull/222
40+
41+
# AUTOMATED
42+
# OPTIONAL to manually add other issue URLs
43+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
44+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
45+
# issue: https://github.com/owner/repo/1234

docs/usage.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ The side effect is that the changelog will include all entries from latest stabl
108108

109109
## I'm the release manager
110110

111-
> NOTE: This instructions are for the 0.2.0 milestone (when ready). As more features and automation is added the process will become simpler.
112-
113111
### Preparing the changelog
114112

115113
These steps require [GitHub Authentication](./github-authentication.md).
@@ -126,9 +124,13 @@ These steps require [GitHub Authentication](./github-authentication.md).
126124
127125
* `x.y.z` is the version to release.
128126
* `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`.
127+
* `repo` is the name of the repository containing the issues and PRs. The default value is `elastic-agent`.
128+
129+
>NOTE: If the repo you're targeting has an `owner` and `repo` defined in a `config.changelog.yaml` file, you do not need to specify them when running the command.
130130
131131
This will create `./changelog/x.y.z.yaml`.
132+
133+
>NOTE: If there are no changes included in the release (there are no changelog fragment files), the changelog file will be generated with an empty array of entries.
132134
1. From the root of the repository run:
133135
```
134136
$ elastic-agent-changelog-tool cleanup
@@ -140,6 +142,7 @@ These steps require [GitHub Authentication](./github-authentication.md).
140142
```
141143
142144
>IMPORTANT: Use `file_type` `markdown` for 9.x versions and `asciidoc` for 8.x versions.
145+
>If the repo you're targeting has a `file_type` defined in a `config.changelog.yaml` file, you do not need to specify it when running the command.
143146
144147
The files that are generated depend on the specified `file_type`. The destination directory depends on the `rendered_changelog_destination` defined in the the repo's `config.changelog.yaml`. If no `rendered_changelog_destination` is specified, it will be added to the `changelog` directory.
145148

internal/changelog/builder.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package changelog
66

77
import (
88
"context"
9-
"errors"
109
"fmt"
1110
"log"
1211
"net/url"
@@ -44,26 +43,24 @@ func NewBuilder(fs afero.Fs, filename, version, src, dest string) *Builder {
4443
}
4544

4645
var changelogFilePerm = os.FileMode(0660)
47-
var errNoFragments = errors.New("no fragments found in the source folder")
4846

4947
func (b Builder) Build(owner, repo string) error {
5048
log.Printf("building changelog for version: %s\n", b.changelog.Version)
5149
log.Printf("collecting fragments from %s\n", b.src)
5250

5351
var files []string
5452
err := afero.Walk(b.fs, b.src, func(path string, info os.FileInfo, err error) error {
53+
if err != nil {
54+
return err
55+
}
5556
if info.IsDir() && info.Name() == "fixtures" {
5657
return filepath.SkipDir
5758
}
5859

5960
return collectFragment(b.fs, path, info, err, &files)
6061
})
6162
if err != nil {
62-
return fmt.Errorf("cannot walk path %s: %w", b.src, err)
63-
}
64-
65-
if len(files) == 0 {
66-
return errNoFragments
63+
log.Printf("no fragment directory found %s: %s", b.src, err)
6764
}
6865

6966
for _, file := range files {
@@ -87,6 +84,10 @@ func (b Builder) Build(owner, repo string) error {
8784

8885
log.Println("Verifying entries:")
8986

87+
if len(b.changelog.Entries) == 0 {
88+
log.Printf("no entries for version %s", b.changelog.Version)
89+
}
90+
9091
for i, entry := range b.changelog.Entries {
9192
// Filling empty PR fields
9293
if len(entry.LinkedPR) == 0 {

0 commit comments

Comments
 (0)