-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (43 loc) · 1.01 KB
/
main.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"context"
"github.com/prodyna/changelog-json/changelog"
"github.com/prodyna/changelog-json/config"
"log/slog"
"os"
)
func main() {
ctx := context.Background()
c, err := config.New()
if err != nil {
slog.Error("unable to load config", "error", err)
os.Exit(1)
}
slog.Debug("config loaded")
generator, err := changelog.New(changelog.Config{
GitHubToken: c.GithubToken,
Repositories: c.Repositories,
Organization: c.Organization,
ExpandLinks: c.ExpandLinks,
})
if err != nil {
slog.Error("unable to create changelog generator", "error", err)
os.Exit(1)
}
cl, err := generator.Generate(ctx)
if err != nil {
slog.Error("unable to generate changelog", "error", err)
os.Exit(1)
}
output, err := cl.RenderJSON()
if err != nil {
slog.Error("unable to render changelog", "error", err)
os.Exit(1)
}
// write changelog to file
err = os.WriteFile(c.OutputFile, output, 0644)
if err != nil {
slog.Error("unable to write changelog to file", "error", err)
os.Exit(1)
}
}