-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathgo.hlb
More file actions
70 lines (63 loc) · 1.79 KB
/
go.hlb
File metadata and controls
70 lines (63 loc) · 1.79 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
export binary
export crossBinaries
export lint
string versionCmd() {
format "git describe --match 'v[0-9]*' --tags --dirty='.dirty' --always | sed 's/^v//'"
}
fs build(fs src, string package, string verPackage) {
image "golang:1.13.10-alpine"
run "apk add -U git gcc libc-dev"
env "GO111MODULE" "on"
dir "/go/src/hlb"
run string {
format "v=$(%s) && /usr/local/go/bin/go build -o /out/binary -ldflags \"-linkmode external -extldflags -static -X %s.Version=$v\" -a %s" versionCmd package verPackage
} with option {
cacheMounts src
mount scratch "/out" as binary
}
}
fs crossBuild(fs src, string package, string verPackage) {
image "dockercore/golang-cross:1.13.10" with option { resolve; }
env "GOPATH" "/root/go"
env "GO111MODULE" "on"
dir "/go/src/hlb"
run string {
format "v=$(%s) && LDFLAGS=\"-X %s.Version=$v\" /cross/build %q" versionCmd verPackage package
} with option {
cacheMounts src
mount fs { git "https://github.com/hinshun/go-cross.git" ""; } "/cross" with option {
sourcePath "/scripts"
readonly
}
mount scratch "/root/go/bin" as crossBinaries
}
}
fs lint(fs src) {
image "golang:1.13.10-alpine"
run "apk add -U git gcc libc-dev"
run "sh /golangci/install.sh -b /usr/bin v1.23.8" with option {
mount fs {
http "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh"
} "/golangci"
}
env "GO111MODULE" "on"
env "PATH" "/usr/bin:/bin:/usr/local/go/bin"
dir "/go/src/hlb"
run "go get" with option {
cacheMounts src
}
run "/usr/bin/golangci-lint run" with option {
cacheMounts src
}
}
option::run cacheMounts(fs src) {
mount src "/go/src/hlb" with option {
readonly
}
mount scratch "/root/.cache/go-build" with option {
cache "hlb/go-build" "private"
}
mount scratch "/go/pkg/mod" with option {
cache "hlb/go-mod" "private"
}
}