Skip to content

Commit

Permalink
Inject production OAuth client ID+secret into release
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Nov 8, 2019
1 parent 8deaf21 commit e7bebae
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
Expand Down
3 changes: 3 additions & 0 deletions context/config_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7bebae

Please sign in to comment.