-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pull OIDC options into subcommands * Remove Docker based build, rely on GitHub Actions
- Loading branch information
Showing
13 changed files
with
124 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
/oidc-token-ferry | ||
/oidc-token-ferry.darwin-amd64 | ||
/oidc-token-ferry.linux-amd64 | ||
/oidc-token-ferry.windows-amd64 | ||
/oidc-token-ferry.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,15 @@ | ||
PROGRAM = oidc-token-ferry | ||
GO_PACKAGE = github.com/twz123/$(PROGRAM) | ||
BUILDER_IMAGE = docker.io/golang:1.14.4-alpine3.12 | ||
|
||
# binaries | ||
DOCKER = docker | ||
GO = go | ||
DEP = dep | ||
GO = go | ||
|
||
OS_ARCH_PROGRAMS = | ||
PROGRAM_DEPENDENCIES = Makefile go.mod go.sum $(shell find pkg/ cmd/ -type f -name \*.go -print) | ||
VERSION := $(shell git describe --tags --always) | ||
GIT_UNTRACKEDCHANGES := $(shell git status --porcelain) | ||
ifneq ($(GIT_UNTRACKEDCHANGES),) | ||
VERSION := $(VERSION)-dirty | ||
endif | ||
|
||
$(PROGRAM): $(PROGRAM_DEPENDENCIES) | ||
$(GO) build ./cmd/oidc-token-ferry | ||
|
||
define _os_arch_program = | ||
OS_ARCH_PROGRAMS += $(PROGRAM).$(1)-$(2) | ||
oidc-token-ferry.$(1)-$(2): $(PROGRAM_DEPENDENCIES) | ||
$(DOCKER) run --rm -e GOOS=$(1) -e GOARCH=$(2) -e CGO_ENABLED=0 -v "$(shell pwd -P):/go/src/$(GO_PACKAGE):ro" -w "/go/src/$(GO_PACKAGE)/cmd/$(PROGRAM)" $(BUILDER_IMAGE) \ | ||
sh -c 'go build -ldflags="-s -w" -o /tmp/go.out && apk add --no-cache upx 1>&2 && upx -o /tmp/go.out.upx /tmp/go.out 1>&2 && cat /tmp/go.out.upx' > $(PROGRAM).$(1)-$(2) || { rm $(PROGRAM).$(1)-$(2); exit 1; } | ||
chmod +x $(PROGRAM).$(1)-$(2) | ||
endef | ||
|
||
$(eval $(call _os_arch_program,linux,amd64)) | ||
$(eval $(call _os_arch_program,darwin,amd64)) | ||
$(eval $(call _os_arch_program,windows,amd64)) | ||
|
||
.PHONY: all | ||
all: $(OS_ARCH_PROGRAMS) | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f $(PROGRAM) $(OS_ARCH_PROGRAMS) | ||
.PHONY: build | ||
build: Makefile go.mod go.sum $(shell find pkg/ cmd/ -type f -name \*.go -print) | ||
$(GO) build -ldflags="-s -w -X $(GO_PACKAGE)/cmd/$(PROGRAM)/version.VERSION=$(VERSION)" ./cmd/$(PROGRAM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
type Version struct { | ||
Version string | ||
GoVersion string | ||
GoCompiler string | ||
GoOs string | ||
GoArch string | ||
} | ||
|
||
func NewVersion() Version { | ||
return Version{ | ||
Version: VERSION, | ||
GoVersion: runtime.Compiler, | ||
GoOs: runtime.GOOS, | ||
GoArch: runtime.GOARCH, | ||
} | ||
} | ||
|
||
type VersionCmd struct { | ||
} | ||
|
||
func (cmd *VersionCmd) Execute(args []string) error { | ||
_, err := fmt.Printf("oidc-token-ferry: %+v\n", NewVersion()) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package version | ||
|
||
// VERSION indicates which version of the binary is running. | ||
var VERSION string |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.