Skip to content

Commit 180e3d3

Browse files
authored
Merge branch 'master' into lint
2 parents cf4a836 + 66b1147 commit 180e3d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4036
-2490
lines changed

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
runs-on: ${{ matrix.platform }}
2323

2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626

2727
- name: golangci-lint ${{ matrix.working-directory }}
2828
uses: golangci/golangci-lint-action@v3

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- uses: actions/setup-go@v4
4040
with:
4141
go-version: ${{ matrix.go-version }}
42-
- uses: actions/checkout@v3
42+
- uses: actions/checkout@v4
4343

4444
# Get values for cache paths to be used in later steps
4545
- id: cache-paths

README.md

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# go-github #
22

33
[![go-github release (latest SemVer)](https://img.shields.io/github/v/release/google/go-github?sort=semver)](https://github.com/google/go-github/releases)
4-
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v54/github)
4+
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v55/github)
55
[![Test Status](https://github.com/google/go-github/workflows/tests/badge.svg)](https://github.com/google/go-github/actions?query=workflow%3Atests)
66
[![Test Coverage](https://codecov.io/gh/google/go-github/branch/master/graph/badge.svg)](https://codecov.io/gh/google/go-github)
77
[![Discuss at go-github@googlegroups.com](https://img.shields.io/badge/discuss-go--github%40googlegroups.com-blue.svg)](https://groups.google.com/group/go-github)
@@ -24,29 +24,29 @@ If you're interested in using the [GraphQL API v4][], the recommended library is
2424
go-github is compatible with modern Go releases in module mode, with Go installed:
2525

2626
```bash
27-
go get github.com/google/go-github/v54
27+
go get github.com/google/go-github/v55
2828
```
2929

3030
will resolve and add the package to the current development module, along with its dependencies.
3131

3232
Alternatively the same can be achieved if you use import in a package:
3333

3434
```go
35-
import "github.com/google/go-github/v54/github"
35+
import "github.com/google/go-github/v55/github"
3636
```
3737

3838
and run `go get` without parameters.
3939

4040
Finally, to use the top-of-trunk version of this repo, use the following command:
4141

4242
```bash
43-
go get github.com/google/go-github/v54@master
43+
go get github.com/google/go-github/v55@master
4444
```
4545

4646
## Usage ##
4747

4848
```go
49-
import "github.com/google/go-github/v54/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
49+
import "github.com/google/go-github/v55/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
5050
import "github.com/google/go-github/github" // with go modules disabled
5151
```
5252

@@ -84,36 +84,18 @@ For more sample code snippets, head over to the
8484

8585
### Authentication ###
8686

87-
The go-github library does not directly handle authentication. Instead, when
88-
creating a new client, pass an `http.Client` that can handle authentication for
89-
you. The easiest and recommended way to do this is using the [oauth2][]
90-
library, but you can always use any other library that provides an
91-
`http.Client`. If you have an OAuth2 access token (for example, a [personal
92-
API token][]), you can use it with the oauth2 library using:
87+
Use the `WithAuthToken` method to configure your client to authenticate using an
88+
OAuth token (for example, a [personal access token][]). This is what is needed
89+
for a majority of use cases aside from GitHub Apps.
9390

9491
```go
95-
import "golang.org/x/oauth2"
96-
97-
func main() {
98-
ctx := context.Background()
99-
ts := oauth2.StaticTokenSource(
100-
&oauth2.Token{AccessToken: "... your access token ..."},
101-
)
102-
tc := oauth2.NewClient(ctx, ts)
103-
104-
client := github.NewClient(tc)
105-
106-
// list all repositories for the authenticated user
107-
repos, _, err := client.Repositories.List(ctx, "", nil)
108-
}
92+
client := github.NewClient(nil).WithAuthToken("... your access token ...")
10993
```
11094

11195
Note that when using an authenticated Client, all calls made by the client will
11296
include the specified OAuth token. Therefore, authenticated clients should
11397
almost never be shared between different users.
11498

115-
See the [oauth2 docs][] for complete instructions on using that library.
116-
11799
For API methods that require HTTP Basic Authentication, use the
118100
[`BasicAuthTransport`](https://godoc.org/github.com/google/go-github/github#BasicAuthTransport).
119101

@@ -135,7 +117,7 @@ import (
135117
"net/http"
136118

137119
"github.com/bradleyfalzon/ghinstallation/v2"
138-
"github.com/google/go-github/v54/github"
120+
"github.com/google/go-github/v55/github"
139121
)
140122

141123
func main() {
@@ -232,16 +214,9 @@ https://github.com/gregjones/httpcache for that. For example:
232214
```go
233215
import "github.com/gregjones/httpcache"
234216

235-
ts := oauth2.StaticTokenSource(
236-
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
237-
)
238-
tc := &http.Client{
239-
Transport: &oauth2.Transport{
240-
Base: httpcache.NewMemoryCacheTransport(),
241-
Source: ts,
242-
},
243-
}
244-
client := github.NewClient(tc)
217+
client := github.NewClient(
218+
httpcache.NewMemoryCacheTransport().Client()
219+
).WithAuthToken(os.Getenv("GITHUB_TOKEN"))
245220
```
246221

247222
Learn more about GitHub conditional requests at
@@ -320,10 +295,8 @@ Furthermore, there are libraries like [cbrgm/githubevents][] that build upon the
320295
For complete usage of go-github, see the full [package docs][].
321296

322297
[GitHub API v3]: https://docs.github.com/en/rest
323-
[oauth2]: https://github.com/golang/oauth2
324-
[oauth2 docs]: https://godoc.org/golang.org/x/oauth2
325-
[personal API token]: https://github.com/blog/1509-personal-api-tokens
326-
[package docs]: https://pkg.go.dev/github.com/google/go-github/v54/github
298+
[personal access token]: https://github.com/blog/1509-personal-api-tokens
299+
[package docs]: https://pkg.go.dev/github.com/google/go-github/v55/github
327300
[GraphQL API v4]: https://developer.github.com/v4/
328301
[shurcooL/githubv4]: https://github.com/shurcooL/githubv4
329302
[GitHub webhook events]: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads
@@ -396,6 +369,7 @@ Versions prior to 48.2.0 are not listed.
396369

397370
| go-github Version | GitHub v3 API Version |
398371
| ----------------- | --------------------- |
372+
| 55.0.0 | 2022-11-28 |
399373
| 54.0.0 | 2022-11-28 |
400374
| 53.2.0 | 2022-11-28 |
401375
| 53.1.0 | 2022-11-28 |

example/actionpermissions/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"log"
1515
"os"
1616

17-
"github.com/google/go-github/v54/github"
17+
"github.com/google/go-github/v55/github"
1818
)
1919

2020
var (
@@ -35,7 +35,7 @@ func main() {
3535
log.Fatal("No owner: owner of repo must be given")
3636
}
3737
ctx := context.Background()
38-
client := github.NewTokenClient(ctx, token)
38+
client := github.NewClient(nil).WithAuthToken(token)
3939

4040
actionsPermissionsRepository, _, err := client.Repositories.GetActionsPermissions(ctx, *owner, *name)
4141
if err != nil {

example/appengine/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"net/http"
1313
"os"
1414

15-
"github.com/google/go-github/v54/github"
15+
"github.com/google/go-github/v55/github"
1616
"google.golang.org/appengine"
1717
"google.golang.org/appengine/log"
1818
)
@@ -28,7 +28,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
2828
}
2929

3030
ctx := appengine.NewContext(r)
31-
client := github.NewTokenClient(ctx, os.Getenv("GITHUB_AUTH_TOKEN"))
31+
client := github.NewClient(nil).WithAuthToken(os.Getenv("GITHUB_AUTH_TOKEN"))
3232

3333
commits, _, err := client.Repositories.ListCommits(ctx, "google", "go-github", nil)
3434
if err != nil {

example/basicauth/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"strings"
2323
"syscall"
2424

25-
"github.com/google/go-github/v54/github"
25+
"github.com/google/go-github/v55/github"
2626
"golang.org/x/term"
2727
)
2828

example/codespaces/newreposecretwithxcrypto/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"log"
3737
"os"
3838

39-
"github.com/google/go-github/v54/github"
39+
"github.com/google/go-github/v55/github"
4040
"golang.org/x/crypto/nacl/box"
4141
)
4242

@@ -72,7 +72,7 @@ func main() {
7272
}
7373

7474
ctx := context.Background()
75-
client := github.NewTokenClient(ctx, token)
75+
client := github.NewClient(nil).WithAuthToken(token)
7676

7777
if err := addRepoSecret(ctx, client, *owner, *repo, secretName, secretValue); err != nil {
7878
log.Fatal(err)

example/codespaces/newusersecretwithxcrypto/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
"log"
3838
"os"
3939

40-
"github.com/google/go-github/v54/github"
40+
"github.com/google/go-github/v55/github"
4141
"golang.org/x/crypto/nacl/box"
4242
)
4343

@@ -65,7 +65,7 @@ func main() {
6565
}
6666

6767
ctx := context.Background()
68-
client := github.NewTokenClient(ctx, token)
68+
client := github.NewClient(nil).WithAuthToken(token)
6969

7070
if err := addUserSecret(ctx, client, secretName, secretValue, *owner, *repo); err != nil {
7171
log.Fatal(err)

example/commitpr/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"strings"
3131
"time"
3232

33-
"github.com/google/go-github/v54/github"
33+
"github.com/google/go-github/v55/github"
3434
)
3535

3636
var (
@@ -189,7 +189,7 @@ func main() {
189189
if *sourceOwner == "" || *sourceRepo == "" || *commitBranch == "" || *sourceFiles == "" || *authorName == "" || *authorEmail == "" {
190190
log.Fatal("You need to specify a non-empty value for the flags `-source-owner`, `-source-repo`, `-commit-branch`, `-files`, `-author-name` and `-author-email`")
191191
}
192-
client = github.NewTokenClient(ctx, token)
192+
client = github.NewClient(nil).WithAuthToken(token)
193193

194194
ref, err := getRef()
195195
if err != nil {

example/go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
module github.com/google/go-github/v54/example
1+
module github.com/google/go-github/v55/example
22

33
go 1.17
44

55
require (
66
github.com/bradleyfalzon/ghinstallation/v2 v2.0.4
77
github.com/gofri/go-github-ratelimit v1.0.3
8-
github.com/google/go-github/v54 v54.0.0
8+
github.com/google/go-github/v55 v55.0.0
99
golang.org/x/crypto v0.12.0
10-
golang.org/x/oauth2 v0.7.0
1110
golang.org/x/term v0.11.0
1211
google.golang.org/appengine v1.6.7
1312
)
@@ -25,4 +24,4 @@ require (
2524
)
2625

2726
// Use version at HEAD, not the latest published.
28-
replace github.com/google/go-github/v54 => ../
27+
replace github.com/google/go-github/v55 => ../

0 commit comments

Comments
 (0)