func defaultGithubClient() *github.Client {
	token, ok := os.LookupEnv("GITHUB_TOKEN")
	if ok {
		ctx := context.Background()
		ts := oauth2.StaticTokenSource(
			&oauth2.Token{AccessToken: token},
		)
		tc := oauth2.NewClient(ctx, ts)
		return github.NewClient(tc)
	}
	return github.NewClient(nil)
}
defaultGithubClient returns a OAuth scoped Github API Client if GITHUB_TOKEN
is set the local environment, or an unauthorized one otherwise.
package main
import (
	"context"
	"os"
	"time"
	"github.com/google/go-github/v29/github"
	"golang.org/x/oauth2"
)
func getLatestRelease(owner, repo string) (*github.RepositoryRelease, error) {
	client, ctx := defaultGithubClient(), context.Background()
	defer timeTrack(time.Now(), "API call to client.Repositories.GetLatestRelease()")
	release, _, err := client.Repositories.GetLatestRelease(ctx, owner, repo)
	return release, err
}
func compareRelease(owner, repo, tagName string) (*github.CommitsComparison, error) {
	client, ctx := defaultGithubClient(), context.Background()
	defer timeTrack(time.Now(), "API call to client.Repositories.CompareCommits()")
	cc, _, err := client.Repositories.CompareCommits(ctx, owner, repo, tagName, "HEAD")
	if cc != nil {
		reverseCommitOrder(cc)
	}
	return cc, err
}
func reverseCommitOrder(cc *github.CommitsComparison) {
	for i := len(cc.Commits)/2 - 1; i >= 0; i-- {
		opp := len(cc.Commits) - 1 - i
		cc.Commits[i], cc.Commits[opp] = cc.Commits[opp], cc.Commits[i]
	}
}