github.com/crossplane-contrib/function-cue@v0.2.2-0.20240508161918-5100fcb5a058/Makefile (about) 1 # Licensed to Elasticsearch B.V. under one or more contributor 2 # license agreements. See the NOTICE file distributed with 3 # this work for additional information regarding copyright 4 # ownership. Elasticsearch B.V. licenses this file to you under 5 # the Apache License, Version 2.0 (the "License"); you may 6 # not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http:#www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, 12 # software distributed under the License is distributed on an 13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 # KIND, either express or implied. See the License for the 15 # specific language governing permissions and limitations 16 # under the License. 17 18 image?=xpkg.upbound.io/crossplane-contrib/function-cue 19 20 build_date:=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") 21 commit:=$(shell git rev-parse --short HEAD 2> /dev/null) 22 bdate:=$(shell date -u +%Y%m%d%H%M%S) 23 bver:=$(shell git rev-parse --short=12 HEAD) 24 version:=$(shell git describe --tags --exact-match --match='v*' 2> /dev/null || echo "$(bdate)-$(bver)") 25 ldflags?=-X 'main.BuildDate=$(build_date)' -X 'main.Commit=$(commit)' -X 'main.Version=$(version)' 26 27 .PHONY: local 28 local: build test lint 29 30 .bin/gofumpt: 31 mkdir -p ./.bin 32 GOBIN="$$(pwd)/.bin" go install mvdan.cc/gofumpt@v0.5.0 33 34 .bin/golangci-lint: 35 mkdir -p ./.bin 36 GOBIN="$$(pwd)/.bin" go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 37 38 .PHONY: build 39 build: 40 CGO_ENABLED=0 go generate ./... 41 CGO_ENABLED=0 go install -ldflags="$(ldflags)" ./... 42 43 .PHONY: test 44 test: 45 go test -race ./... 46 47 .PHONY: lint 48 lint: .bin/golangci-lint 49 ./.bin/golangci-lint run 50 51 .PHONY: docker-build 52 docker-build: 53 docker build --tag $(image):$(version) --build-arg "ldflags=$(ldflags)" . 54 55 .PHONY: docker 56 docker: 57 make -C . docker-build 58 59 .PHONY: docker-push 60 docker-push: docker 61 docker push $(image):$(version) 62 63 .PHONY: fmt 64 fmt: .bin/gofumpt 65 ./.bin/gofumpt -w . 66 67 .PHONY: ci 68 ci: local 69 70 .PHONY: ci-print-ldflags 71 ci-print-ldflags: 72 @echo $(ldflags) 73 74 .PHONY: ci-print-version 75 ci-print-version: 76 @echo $(version) 77 78 .PHONY: ci-check-dirty 79 ci-check-dirty: 80 git status || true 81 git diff --quiet || (echo 'dirty files found' && exit 1)