Skip to content

Commit

Permalink
Merge pull request #15 from nekonenene/develop
Browse files Browse the repository at this point in the history
Release 2021-03-28 00:42
  • Loading branch information
nekonenene authored Mar 27, 2021
2 parents 30c49ca + deef14c commit 01185a0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release_page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
- name: Run release-it
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: release-it --ci --increment patch
run: release-it --ci --increment minor
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ gh-release-pr-generator --help
|-dev-branch| Development branch name (default: `develop`) | |
|-template-path| PATH of the [template file](#template-file) | |
|-limit| Limit number of fetching pull requests (default: `100`) | |
|-enterprise-url| URL of GitHub Enterprise (ex. https://github.your.domain ) | |

### Template File

Expand Down Expand Up @@ -86,6 +87,7 @@ Release {{ .Year }}-{{ .Month }}-{{ .Date }} {{ .Hour }}:{{ .Minute }}
| MinuteShort | Current Minute (ex. `4`) |
| Second | Current Second (ex. `05`) |
| SecondShort | Current Second (ex. `5`) |
| Time | Current [Time](https://golang.org/pkg/time/#Time) |
| Pulls | [Pull Requests](https://github.com/google/go-github/blob/master/github/pulls.go) Array |


Expand Down
6 changes: 5 additions & 1 deletion cmd/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import (
// ENTRY POINT of this package
func Exec() {
ParseParameters()
InitContextAndClient()

err := InitContextAndGitHubClient()
if err != nil {
log.Fatal(err)
}

diffCommitIDs, err := FetchDiffCommitIDs()
if err != nil {
Expand Down
15 changes: 13 additions & 2 deletions cmd/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@ var (
)

// init ctx and githubClient
func InitContextAndClient() {
func InitContextAndGitHubClient() error {
ctx = context.Background()
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: params.GitHubAPIToken})
httpClient := oauth2.NewClient(ctx, tokenSource)
githubClient = github.NewClient(httpClient)

if params.EnterpriseURL == "" {
githubClient = github.NewClient(httpClient)
} else {
var err error
githubClient, err = github.NewEnterpriseClient(params.EnterpriseURL, params.EnterpriseURL, httpClient)
if err != nil {
return err
}
}

return nil
}

// Fetch the difference of commit IDs between develop and main
Expand Down
2 changes: 2 additions & 0 deletions cmd/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type parameters struct {
DevelopmentBranchName string
TemplatePath string
FetchPullRequestsLimit int
EnterpriseURL string
}

var params parameters
Expand All @@ -25,6 +26,7 @@ func ParseParameters() {
flag.StringVar(&params.DevelopmentBranchName, "dev-branch", DevelopmentBranchNameDefault, "[Opiton] development branch name")
flag.StringVar(&params.TemplatePath, "template-path", "", "[Opiton] template path for customizing the title and the body of the release pull request")
flag.IntVar(&params.FetchPullRequestsLimit, "limit", FetchPullRequestsLimitDefault, "[Opiton] limit number of fetching pull requests")
flag.StringVar(&params.EnterpriseURL, "enterprise-url", "", "[Opiton] URL of GitHub Enterprise (ex. https://github.your.domain )")
flag.Parse()

if params.GitHubAPIToken == "" {
Expand Down

0 comments on commit 01185a0

Please sign in to comment.