diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index f2267c842..2a5b327ad 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -22,6 +22,8 @@ jobs: version: latest args: release env: + GH_OAUTH_CLIENT_ID: 178c6fc778ccc68e1d6a + GH_OAUTH_CLIENT_SECRET: ${{secrets.OAUTH_CLIENT_SECRET}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Copy release id: copy diff --git a/.goreleaser.yml b/.goreleaser.yml index 52496693a..eef85417e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -7,6 +7,8 @@ builds: - binary: bin/gh ldflags: - -s -w -X github.com/github/gh-cli/command.Version={{.Version}} -X github.com/github/gh-cli/command.BuildDate={{.Date}} + - -X github.com/github/gh-cli/context.oauthClientID={{.Env.GH_OAUTH_CLIENT_ID}} + - -X github.com/github/gh-cli/context.oauthClientSecret={{.Env.GH_OAUTH_CLIENT_SECRET}} goos: - linux - darwin diff --git a/Makefile b/Makefile index 63e424b84..120d44cad 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,10 @@ BUILD_FILES = $(shell go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}}\ GH_VERSION = $(shell go describe --tags 2>/dev/null || git rev-parse --short HEAD) LDFLAGS := -X github.com/github/gh-cli/command.Version=$(GH_VERSION) $(LDFLAGS) LDFLAGS := -X github.com/github/gh-cli/command.BuildDate=$(shell date +%Y-%m-%d) $(LDFLAGS) +ifdef GH_OAUTH_CLIENT_SECRET + LDFLAGS := -X github.com/github/gh-cli/context.oauthClientID=$(GH_OAUTH_CLIENT_ID) $(LDFLAGS) + LDFLAGS := -X github.com/github/gh-cli/context.oauthClientSecret=$(GH_OAUTH_CLIENT_SECRET) $(LDFLAGS) +endif bin/gh: $(BUILD_FILES) @go build -ldflags "$(LDFLAGS)" -o "$@" diff --git a/context/config_setup.go b/context/config_setup.go index 290547b4a..bb7addbce 100644 --- a/context/config_setup.go +++ b/context/config_setup.go @@ -14,6 +14,9 @@ import ( const ( oauthHost = "github.com" +) + +var ( // The GitHub app that is meant for development oauthClientID = "4d747ba5675d5d66553f" // This value is safe to be embedded in version control