Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/changelog/main.go
2492 views
1
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
//
5
// Based on https://github.com/leodido/rn2md with kind permission from the author
6
package main
7
8
import (
9
"context"
10
"fmt"
11
"os"
12
13
"github.com/google/go-github/v38/github"
14
"github.com/spf13/cobra"
15
"golang.org/x/oauth2"
16
)
17
18
func main() {
19
if err := rootCommand.Execute(); err != nil {
20
fmt.Println(err)
21
os.Exit(1)
22
}
23
}
24
25
var rootCommand = &cobra.Command{
26
Use: "changelog",
27
Long: "Little configurable CLI create/update/push the markdown for your changelogs from release-note blocks found into your project pull requests.",
28
Short: "Automate changelog generation from release-note blocks.",
29
}
30
31
func NewClient(token string) *github.Client {
32
client := github.NewClient(nil)
33
34
// Eventually create an authenticated client
35
if token != "" {
36
ts := oauth2.StaticTokenSource(
37
&oauth2.Token{AccessToken: token},
38
)
39
tc := oauth2.NewClient(context.Background(), ts)
40
client = github.NewClient(tc)
41
}
42
return client
43
}
44
45