Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: build targets use go build directly #253

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v4
with:
Expand Down
12 changes: 5 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
env:
- GOPROXY=https://proxy.golang.org|direct
- GO111MODULE=on
- CGO_ENABLED=0
before:
hooks:
- go mod tidy
Expand All @@ -10,16 +6,18 @@ builds:
- id: operator-controller
main: ./cmd/manager/
binary: bin/manager
tags: $GO_BUILD_TAGS
asmflags: "{{ .Env.GO_BUILD_ASMFLAGS }}"
gcflags: "{{ .Env.GO_BUILD_GCFLAGS }}"
ldflags: "{{ .Env.GO_BUILD_LDFLAGS }}"
tags:
- "{{ .Env.GO_BUILD_TAGS }}"
goos:
- linux
goarch:
- amd64
- arm64
- ppc64le
- s390x
ldflags:
- -X main.Version={{ .Version }}
dockers:
- image_templates:
- "{{ .Env.IMAGE_REPO }}:{{ .Env.IMAGE_TAG }}-amd64"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ EXPOSE 8080

USER 65532:65532

ENTRYPOINT ["/manager"]
ENTRYPOINT ["/manager"]
29 changes: 19 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Image URL to use all building/pushing image targets
export IMAGE_REPO ?= quay.io/operator-framework/operator-controller
export IMAGE_TAG ?= devel
export GO_BUILD_TAGS ?= upstream
export CERT_MGR_VERSION ?= v1.9.0
export CATALOGD_VERSION ?= v0.2.0
export RUKPAK_VERSION=$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
Expand Down Expand Up @@ -112,17 +111,28 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into

##@ Build

BUILDCMD = sh -c 'mkdir -p $(BUILDBIN) && $(GORELEASER) build ${GORELEASER_ARGS} --single-target -o $(BUILDBIN)/manager'
BUILDDEPS = manifests generate fmt vet $(GORELEASER)
export VERSION ?= $(shell git describe --tags --always --dirty)
export CGO_ENABLED ?= 0
export GO_BUILD_ASMFLAGS ?= all=-trimpath=${PWD}
joelanford marked this conversation as resolved.
Show resolved Hide resolved
export GO_BUILD_LDFLAGS ?= -s -w -X $(shell go list -m)/version.Version=$(VERSION)
export GO_BUILD_GCFLAGS ?= all=-trimpath=${PWD}
export GO_BUILD_TAGS ?= upstream

.PHONY: build
build: BUILDBIN = bin
build: $(BUILDDEPS) ## Build manager binary using goreleaser for current GOOS and GOARCH.
BUILDCMD = go build -tags '$(GO_BUILD_TAGS)' -ldflags '$(GO_BUILD_LDFLAGS)' -gcflags '$(GO_BUILD_GCFLAGS)' -asmflags '$(GO_BUILD_ASMFLAGS)' -o $(BUILDBIN)/manager ./cmd/manager

.PHONY: build-deps
build-deps: manifests generate fmt vet

.PHONY: build go-build-local
build: build-deps go-build-local ## Build manager binary for current GOOS and GOARCH.
go-build-local: BUILDBIN = bin
go-build-local:
$(BUILDCMD)

.PHONY: build-linux
build-linux: BUILDBIN = bin/linux
build-linux: $(BUILDDEPS) ## Build manager binary using goreleaser for GOOS=linux and local GOARCH.
.PHONY: build-linux go-build-linux
build-linux: build-deps go-build-linux ## Build manager binary for GOOS=linux and local GOARCH.
go-build-linux: BUILDBIN = bin/linux
go-build-linux:
GOOS=linux $(BUILDCMD)

.PHONY: run
Expand All @@ -143,7 +153,6 @@ docker-build: build-linux ## Build docker image for operator-controller with GOO
##@ Release:
export ENABLE_RELEASE_PIPELINE ?= false
export GORELEASER_ARGS ?= --snapshot --clean
export VERSION ?= $(shell git describe --abbrev=0 --tags)

release: $(GORELEASER) ## Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
$(GORELEASER) $(GORELEASER_ARGS)
Expand Down
Loading