mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-02-09 19:27:04 +00:00
Compare commits
3 commits
74122b69e7
...
e2e0246004
| Author | SHA1 | Date | |
|---|---|---|---|
| e2e0246004 | |||
|
|
e7333e4603 | ||
| 2621c48d75 |
8 changed files with 89 additions and 36 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
|
@ -1,5 +1,21 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [v0.4.0](https://github.com/apricote/releaser-pleaser/releases/tag/v0.4.0)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- add support for GitLab repositories (#49)
|
||||||
|
- add shell to container image (#59)
|
||||||
|
- **gitlab**: add CI/CD component (#55)
|
||||||
|
- **changelog**: omit version heading in forge release notes
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- **parser**: continue on unparsable commit message (#48)
|
||||||
|
- **cli**: command name in help output (#52)
|
||||||
|
- **parser**: invalid handling of empty lines (#53)
|
||||||
|
- multiple extra-files are not evaluated properly (#61)
|
||||||
|
|
||||||
## [v0.4.0-beta.1](https://github.com/apricote/releaser-pleaser/releases/tag/v0.4.0-beta.1)
|
## [v0.4.0-beta.1](https://github.com/apricote/releaser-pleaser/releases/tag/v0.4.0-beta.1)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ inputs:
|
||||||
outputs: {}
|
outputs: {}
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: ghcr.io/apricote/releaser-pleaser:v0.4.0-beta.1 # x-releaser-pleaser-version
|
image: ghcr.io/apricote/releaser-pleaser:v0.4.0 # x-releaser-pleaser-version
|
||||||
args:
|
args:
|
||||||
- run
|
- run
|
||||||
- --forge=github
|
- --forge=github
|
||||||
|
|
|
||||||
|
|
@ -26,27 +26,37 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewChangelogEntry(logger *slog.Logger, commits []commitparser.AnalyzedCommit, version, link, prefix, suffix string) (string, error) {
|
func DefaultTemplate() *template.Template {
|
||||||
features := make([]commitparser.AnalyzedCommit, 0)
|
return changelogTemplate
|
||||||
fixes := make([]commitparser.AnalyzedCommit, 0)
|
}
|
||||||
|
|
||||||
for _, commit := range commits {
|
type Data struct {
|
||||||
switch commit.Type {
|
Commits map[string][]commitparser.AnalyzedCommit
|
||||||
case "feat":
|
Version string
|
||||||
features = append(features, commit)
|
VersionLink string
|
||||||
case "fix":
|
Prefix string
|
||||||
fixes = append(fixes, commit)
|
Suffix string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func New(commits map[string][]commitparser.AnalyzedCommit, version, versionLink, prefix, suffix string) Data {
|
||||||
|
return Data{
|
||||||
|
Commits: commits,
|
||||||
|
Version: version,
|
||||||
|
VersionLink: versionLink,
|
||||||
|
Prefix: prefix,
|
||||||
|
Suffix: suffix,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Formatting struct {
|
||||||
|
HideVersionTitle bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func Entry(logger *slog.Logger, tpl *template.Template, data Data, formatting Formatting) (string, error) {
|
||||||
var changelog bytes.Buffer
|
var changelog bytes.Buffer
|
||||||
err := changelogTemplate.Execute(&changelog, map[string]any{
|
err := tpl.Execute(&changelog, map[string]any{
|
||||||
"Features": features,
|
"Data": data,
|
||||||
"Fixes": fixes,
|
"Formatting": formatting,
|
||||||
"Version": version,
|
|
||||||
"VersionLink": link,
|
|
||||||
"Prefix": prefix,
|
|
||||||
"Suffix": suffix,
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,24 @@
|
||||||
## [{{.Version}}]({{.VersionLink}})
|
{{define "entry" -}}
|
||||||
{{- if .Prefix }}
|
- {{ if .Scope }}**{{.Scope}}**: {{end}}{{.Description}}
|
||||||
{{ .Prefix }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{- if not .Formatting.HideVersionTitle }}
|
||||||
|
## [{{.Data.Version}}]({{.Data.VersionLink}})
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{- if (gt (len .Features) 0) }}
|
{{- if .Data.Prefix }}
|
||||||
|
{{ .Data.Prefix }}
|
||||||
|
{{ end -}}
|
||||||
|
{{- with .Data.Commits.feat }}
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
{{ range .Features -}}
|
{{ range . -}}{{template "entry" .}}{{end}}
|
||||||
- {{ if .Scope }}**{{.Scope}}**: {{end}}{{.Description}}
|
|
||||||
{{ end -}}
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- if (gt (len .Fixes) 0) }}
|
{{- with .Data.Commits.fix }}
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
{{ range .Fixes -}}
|
{{ range . -}}{{template "entry" .}}{{end}}
|
||||||
- {{ if .Scope }}**{{.Scope}}**: {{end}}{{.Description}}
|
|
||||||
{{ end -}}
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- if .Suffix }}
|
{{- if .Data.Suffix }}
|
||||||
{{ .Suffix }}
|
{{ .Data.Suffix }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,8 @@ This version is compatible with flux-compensator v2.2 - v2.9.
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
got, err := NewChangelogEntry(slog.Default(), tt.args.analyzedCommits, tt.args.version, tt.args.link, tt.args.prefix, tt.args.suffix)
|
data := New(commitparser.ByType(tt.args.analyzedCommits), tt.args.version, tt.args.link, tt.args.prefix, tt.args.suffix)
|
||||||
|
got, err := Entry(slog.Default(), DefaultTemplate(), data, Formatting{})
|
||||||
if !tt.wantErr(t, err) {
|
if !tt.wantErr(t, err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,18 @@ type AnalyzedCommit struct {
|
||||||
Scope *string
|
Scope *string
|
||||||
BreakingChange bool
|
BreakingChange bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ByType groups the Commits by the type field. Used by the Changelog.
|
||||||
|
func ByType(in []AnalyzedCommit) map[string][]AnalyzedCommit {
|
||||||
|
out := map[string][]AnalyzedCommit{}
|
||||||
|
|
||||||
|
for _, commit := range in {
|
||||||
|
if out[commit.Type] == nil {
|
||||||
|
out[commit.Type] = make([]AnalyzedCommit, 0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
out[commit.Type] = append(out[commit.Type], commit)
|
||||||
|
}
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,9 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
changelogEntry, err := changelog.NewChangelogEntry(logger, analyzedCommits, nextVersion, rp.forge.ReleaseURL(nextVersion), releaseOverrides.Prefix, releaseOverrides.Suffix)
|
changelogData := changelog.New(commitparser.ByType(analyzedCommits), nextVersion, rp.forge.ReleaseURL(nextVersion), releaseOverrides.Prefix, releaseOverrides.Suffix)
|
||||||
|
|
||||||
|
changelogEntry, err := changelog.Entry(logger, changelog.DefaultTemplate(), changelogData, changelog.Formatting{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to build changelog entry: %w", err)
|
return fmt.Errorf("failed to build changelog entry: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -289,9 +291,16 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
|
||||||
logger.InfoContext(ctx, "file content is already up-to-date in remote branch, skipping push")
|
logger.InfoContext(ctx, "file content is already up-to-date in remote branch, skipping push")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We do not need the version title here. In the pull request the version is available from the title, and in the
|
||||||
|
// release on the Forge its usually in a heading somewhere above the text.
|
||||||
|
changelogEntryPullRequest, err := changelog.Entry(logger, changelog.DefaultTemplate(), changelogData, changelog.Formatting{HideVersionTitle: true})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to build pull request changelog entry: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Open/Update PR
|
// Open/Update PR
|
||||||
if pr == nil {
|
if pr == nil {
|
||||||
pr, err = releasepr.NewReleasePullRequest(rpBranch, rp.targetBranch, nextVersion, changelogEntry)
|
pr, err = releasepr.NewReleasePullRequest(rpBranch, rp.targetBranch, nextVersion, changelogEntryPullRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -308,7 +317,7 @@ func (rp *ReleaserPleaser) runReconcileReleasePR(ctx context.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = pr.SetDescription(changelogEntry, overrides)
|
err = pr.SetDescription(changelogEntryPullRequest, overrides)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ releaser-pleaser:
|
||||||
# There is no way to run a pipeline when the MR description is updated :(
|
# There is no way to run a pipeline when the MR description is updated :(
|
||||||
- if: $CI_COMMIT_BRANCH == "$[[ inputs.branch ]]"
|
- if: $CI_COMMIT_BRANCH == "$[[ inputs.branch ]]"
|
||||||
image:
|
image:
|
||||||
name: ghcr.io/apricote/releaser-pleaser:v0.4.0-beta.1 # x-releaser-pleaser-version
|
name: ghcr.io/apricote/releaser-pleaser:v0.4.0 # x-releaser-pleaser-version
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
variables:
|
variables:
|
||||||
GITLAB_TOKEN: $[[ inputs.token ]]
|
GITLAB_TOKEN: $[[ inputs.token ]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue