Inject production OAuth client ID+secret into release

This commit is contained in:
Mislav Marohnić 2019-11-08 18:45:48 +01:00
parent 8deaf21520
commit e7bebaeebc
4 changed files with 11 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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 "$@"

View file

@ -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