-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (100 loc) · 3.72 KB
/
Makefile
File metadata and controls
120 lines (100 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Copyright 2024 Red Hat Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PKG := github.com/openshift/hypershift-oadp-plugin
BIN := hypershift-oadp-plugin
IMG ?= quay.io/hypershift/hypershift-oadp-plugin:latest
VERSION ?= $(shell git describe --tags --always)
# Supported architectures and platforms
ARCHS ?= amd64 arm64
DOCKER_BUILD_ARGS ?= --platform=linux/$(ARCH)
GO=GO111MODULE=on GOWORK=off GOFLAGS=-mod=vendor go
DEPS_UPSTREAM_BRANCH ?= release-4.22
.PHONY: install-goreleaser
install-goreleaser:
## Using goreleaser v2 compatible with go 1.25
@echo "Installing goreleaser v2..."
@mkdir -p ./bin
@GOBIN=$(PWD)/bin GOFLAGS= go install github.com/goreleaser/goreleaser/v2@v2.13.3
@echo "Goreleaser installed successfully!"
.PHONY: local
local: verify build-dirs
CGO_ENABLED=0 $(GO) build \
-ldflags "-s -w -extldflags '-static' \
-X $(PKG)/pkg/version.Version=$(VERSION) \
-X $(PKG)/pkg/version.Commit=$(shell git rev-parse HEAD) \
-X $(PKG)/pkg/version.Date=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o dist/$(BIN) ./main.go
@echo "Binary built at dist/$(BIN)"
.PHONY: release
release: verify install-goreleaser
./bin/goreleaser release --clean
.PHONY: release-local
release-local: verify install-goreleaser build-dirs
GORELEASER_CURRENT_TAG=$(VERSION) ./bin/goreleaser build --clean
.PHONY: release-snapshot
release-snapshot: verify install-goreleaser build-dirs
./bin/goreleaser build --snapshot --clean
@mkdir -p dist/$(BIN)_$(VERSION)
@find dist/default_*/ -name "$(BIN)-*" -exec cp {} dist/$(BIN)_$(VERSION)/ \;
@echo "Binaries copied to dist/$(BIN)_$(VERSION)/"
@ls -la dist/$(BIN)_$(VERSION)/
.PHONY: tests
test:
DEPS_UPSTREAM_BRANCH=$(DEPS_UPSTREAM_BRANCH) $(GO) test -v -timeout 60s ./...
# test-renovate validates the renovate.json config structure and runs the official
# renovate-config-validator. Requires: npx (Node.js)
.PHONY: test-renovate
test-renovate:
@command -v npx >/dev/null 2>&1 || { echo "Error: npx is required but not found. Install Node.js to get it."; exit 1; }
$(GO) test -v -tags renovate -timeout 120s ./tests/integration/renovate/
.PHONY: cover
cover:
$(GO) test --cover -timeout 60s ./...
.PHONY: deps
deps:
$(GO) mod tidy && $(GO) mod vendor
.PHONY: update-deps
update-deps:
@echo "Running dependency update script..."
DEPS_UPSTREAM_BRANCH=$(DEPS_UPSTREAM_BRANCH) $(GO) run scripts/update-dependencies.go
.PHONY: verify
verify: verify-modules test
.PHONY: verify-goreleaser
verify-goreleaser: install-goreleaser
@echo "Verifying GoReleaser CI configuration..."
./bin/goreleaser check --config .goreleaser.ci.yaml
.PHONY: verify-goreleaser-dev
verify-goreleaser-dev: install-goreleaser
@echo "Verifying GoReleaser development configuration..."
./bin/goreleaser check
.PHONY: docker-build
docker-build:
docker build -t ${IMG} .
.PHONY: docker-push
docker-push:
docker push ${IMG}
# verify-modules ensures Go module files are up to date
.PHONY: verify-modules
verify-modules: deps
@if !(git diff --quiet HEAD -- go.sum go.mod); then \
echo "go module files are out of date, please commit the changes to go.mod and go.sum"; exit 1; \
fi
.PHONY: build-dirs
build-dirs:
@mkdir -p dist
# clean removes build artifacts from the local environment.
.PHONY: clean
clean:
@echo "cleaning"
rm -rf _output dist bin