-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.go
33 lines (26 loc) · 704 Bytes
/
release.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package mikku
import (
"bytes"
"fmt"
"text/template"
"github.com/google/go-github/v32/github"
)
const (
releaseBodyTemplate = `
## Changelog
{{ range $i, $pr := .PullRequests }}
- {{ $pr.Title }} (#{{ $pr.Number }}) by @{{ $pr.User.Login }}{{ end }}
`
)
func generateReleaseBody(prs []*github.PullRequest) (string, error) {
tmpl, err := template.New("body").Parse(releaseBodyTemplate)
if err != nil {
return "", fmt.Errorf("template parse error: %w", err)
}
buff := bytes.NewBuffer([]byte{})
body := map[string]interface{}{"PullRequests": prs}
if err := tmpl.Execute(buff, body); err != nil {
return "", fmt.Errorf("template execute error: %w", err)
}
return buff.String(), nil
}