Skip to content

Commit 70d2867

Browse files
authored
Merge pull request kosmos-io#51 from wuyingjun-lucky/main
Add release stage on makefile and fix build tag no names bug
2 parents 0c7d7b8 + a8366fb commit 70d2867

File tree

5 files changed

+47
-29
lines changed

5 files changed

+47
-29
lines changed

Makefile

+8-25
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,11 @@ update:
8989
verify:
9090
hack/verify-all.sh
9191

92-
.PHONY: release-chart
93-
release-chart:
94-
hack/release-helm-chart.sh $(VERSION)
95-
9692
.PHONY: test
9793
test:
9894
mkdir -p ./_output/coverage/
9995
go test --race --v ./pkg/... -coverprofile=./_output/coverage/coverage_pkg.txt -covermode=atomic
10096
go test --race --v ./cmd/... -coverprofile=./_output/coverage/coverage_cmd.txt -covermode=atomic
101-
# go test --race --v ./examples/... -coverprofile=./_output/coverage/coverage_examples.txt -covermode=atomic
10297

10398
upload-images: images
10499
@echo "push images to $(REGISTRY)"
@@ -112,27 +107,15 @@ endif
112107
docker push ${REGISTRY}/clusterlink-network-manager:${VERSION}
113108
docker push ${REGISTRY}/clusterlink-floater:${VERSION}
114109

115-
# Build and package binary
116-
#
117-
# Example
118-
# make release-kosmosctl
119-
RELEASE_TARGET=$(addprefix release-, $(CTL_TARGETS))
120-
.PHONY: $(RELEASE_TARGET)
121-
$(RELEASE_TARGET):
122-
@set -e;\
123-
target=$$(echo $(subst release-,,$@));\
124-
make $$target;\
125-
hack/release.sh $$target $(GOOS) $(GOARCH)
126-
127-
# Build and package binary for all platforms
128-
#
129-
# Example
130-
# make release
110+
.PHONY: release
131111
release:
132-
@make release-linkctl GOOS=linux GOARCH=amd64
133-
@make release-linkctl GOOS=linux GOARCH=arm64
134-
@make release-linkctl GOOS=darwin GOARCH=amd64
135-
@make release-linkctl GOOS=darwin GOARCH=arm64
112+
@make release-kosmosctl GOOS=linux GOARCH=amd64
113+
@make release-kosmosctl GOOS=linux GOARCH=arm64
114+
@make release-kosmosctl GOOS=darwin GOARCH=amd64
115+
@make release-kosmosctl GOOS=darwin GOARCH=arm64
116+
117+
release-kosmosctl:
118+
hack/release.sh kosmosctl ${GOOS} ${GOARCH}
136119

137120
.PHONY: lint
138121
lint: golangci-lint

hack/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ function build_binary_for_platform() {
4545
local -r os=${platform%/*}
4646
local -r arch=${platform##*/}
4747

48-
local gopkg="${CLUSTERLINK_GO_PACKAGE}/$(util::get_target_source $target)"
48+
local target_pkg="${CLUSTERLINK_GO_PACKAGE}/$(util::get_target_source "$target")"
4949
set -x
5050
CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build \
5151
-ldflags "${LDFLAGS:-}" \
5252
-o "_output/bin/${platform}/$target" \
53-
"${gopkg}"
53+
"${target_pkg}"
5454
set +x
5555

5656
if [[ "${target}" == "clusterlink-floater" ]]; then

hack/docker.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ function isCross() {
109109
fi
110110
}
111111

112-
build_images $@
112+
build_images "$@"

hack/release.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
8+
source "${REPO_ROOT}/hack/util.sh"
9+
10+
LDFLAGS="$(util::version_ldflags) ${LDFLAGS:-}"
11+
12+
function release_binary() {
13+
local -r target=$1
14+
local -r os=$2
15+
local -r arch=$3
16+
17+
release_binary_for_platform "${target}" "${os}" "${arch}"
18+
}
19+
20+
function release_binary_for_platform() {
21+
local -r target=$1
22+
local -r os=$2
23+
local -r arch=$3
24+
local -r platform="${os}-${arch}"
25+
26+
local target_pkg="${CLUSTERLINK_GO_PACKAGE}/$(util::get_target_source "$target")"
27+
set -x
28+
CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build \
29+
-ldflags "${LDFLAGS:-}" \
30+
-o "_output/release/$target-${platform}" \
31+
"${target_pkg}"
32+
set +x
33+
}
34+
35+
release_binary "$@"

hack/util.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ function util::add_routes() {
436436
}
437437

438438
function util::get_version() {
439-
git describe --tags --dirty
439+
git describe --tags --dirty --always
440440
}
441441

442442
function util::version_ldflags() {

0 commit comments

Comments
 (0)