forked from deckhouse/deckhouse-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
146 lines (128 loc) · 3.72 KB
/
Taskfile.yml
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
version: "3"
vars:
buildDate:
sh: date -u +'%Y-%m-%dT%H:%M:%SZ'
version:
sh: git describe --tags
kubectlVersion: v1.29.3
kubectlLDFlags:
sh: |
buildDate="{{ .buildDate }}"
gitCommit="0000000000000000000000000000000000000000"
gitTreeState="archive"
gitVersion="{{ .kubectlVersion }}"
_strippedGitVersion="${gitVersion#[vV]}"
gitMajor="$(cut -d. -f1 <<< "$_strippedGitVersion")"
gitMinor="$(cut -d. -f2 <<< "$_strippedGitVersion")"
declare -a ldflags
function add_ldflag() {
local key=${1}
local val=${2}
ldflags+=(
"-X 'k8s.io/client-go/pkg/version.${key}=${val}'"
"-X 'k8s.io/component-base/version.${key}=${val}'"
)
}
for ldflag in buildDate gitCommit gitTreeState gitVersion gitMajor gitMinor; do
add_ldflag "${ldflag}" "${!ldflag}"
done
echo "${ldflags[*]-}"
ldFlags: -s -w -extldflags=-static -X 'github.com/deckhouse/deckhouse-cli/cmd.Version={{ .version }}' {{ .kubectlLDFlags }}
tasks:
_build:dist:
internal: true
cmds:
- go build -o "{{ .outputDir | default (printf "./dist/%s/%s-%s" .version .targetOS .targetArch) }}/d8"
-ldflags="{{ .ldFlags }}" {{ .CLI_ARGS }} main.go
env:
CGO_ENABLED: "0"
GOOS: "{{ .targetOS }}"
GOARCH: "{{ .targetArch }}"
build:
desc: Build d8 binary for personal usage
run: once
cmds:
- task: build:dist:{{ OS }}:{{ ARCH }}
vars:
outputDir: "."
build:dist:all:
desc: Build all d8 release binaries in parallel
deps:
- build:dist:linux:amd64
- build:dist:darwin:amd64
- build:dist:darwin:arm64
build:dist:linux:amd64:
desc: Build d8 release binary for linux/amd64
cmds:
- task: _build:dist
vars:
targetOS: "linux"
targetArch: "amd64"
outputDir: "{{ .outputDir }}"
build:dist:darwin:amd64:
desc: Build d8 release binary for darwin/amd64
cmds:
- task: _build:dist
vars:
targetOS: "darwin"
targetArch: "amd64"
outputDir: "{{ .outputDir }}"
build:dist:darwin:arm64:
desc: Build d8 release binary for darwin/arm64
cmds:
- task: _build:dist
vars:
targetOS: "darwin"
targetArch: "arm64"
outputDir: "{{ .outputDir }}"
_package:dist:
internal: true
dir: dist/{{ .version }}
cmds:
- cp ../../LICENSE ../../README.md {{ .target }}
- tar -zcf d8-{{ .version }}-{{ .target }}.tar.gz {{ .target }}
package:dist:all:
desc: Package all release assets in parallel
deps:
- package:dist:linux:amd64
- package:dist:darwin:amd64
- package:dist:darwin:arm64
package:dist:linux:amd64:
desc: Package release asset for linux/amd64
dir: dist/{{ .version }}
cmds:
- task: _package:dist
vars:
target: "linux-amd64"
package:dist:darwin:amd64:
desc: Package release asset for darwin/amd64
dir: dist/{{ .version }}
cmds:
- task: _package:dist
vars:
target: "darwin-amd64"
package:dist:darwin:arm64:
desc: Package release asset for darwin/arm64
dir: dist/{{ .version }}
cmds:
- task: _package:dist
vars:
target: "darwin-arm64"
checksum:
desc: Calculate sha256 checksum for release assets
dir: dist/{{ .version }}
cmds:
- |
for asset in *.tar.gz; do
shasum -a 256 "${asset}" > "${asset}".sha256sum
done
build-and-package:
desc: Build and package all d8 binaries
cmds:
- task: build:dist:all
- task: package:dist:all
- task: checksum
clean:
desc: Clean all binaries
cmds:
- rm -rf ./dist ./d8