-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
121 lines (113 loc) · 2.24 KB
/
.gitlab-ci.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
image: golang:1.11-alpine
stages:
- test
- build
variables:
LDFLAGS_GITVERSION: -X main.git_version=${CI_COMMIT_SHA}
LDFLAGS_WEBHOOK: -X main.build_webhook_url=${BUILD_WEBHOOK_URL}
# Overwrite LDFLAGS_WEBHOOK back to LDFLAGS if there is no BUILD_WEBHOOK_URL.
before_script:
- >
[ -z "${BUILD_WEBHOOK_URL}" ] && {
>&2 echo "BUILD_WEBHOOK_URL empty, clearing LDFLAGS_WEBHOOK."
unset LDFLAGS_WEBHOOK
}
Syntax Check:
stage: test
script:
- gofmt -e *.go
Test Message to Slackbot:
stage: test
script:
- >
go run slackr.go
-target @slackbot
-message "Test"
-verbose
Test Call to Version Command:
stage: test
script:
- go run slackr.go -version
- >
go run
-ldflags="${LDFLAGS_GITVERSION}"
slackr.go
-version
Golang Compile - Native:
stage: build
script:
- >
go build
-ldflags="${LDFLAGS_GITVERSION} ${LDFLAGS_WEBHOOK}"
-o slackr
artifacts:
paths:
- slackr
expire_in: 1 year
# Cross platform compiles - Valid GOOS and GOOARCH values are located at:
# https://github.com/golang/go/blob/master/src/go/build/syslist.go
Golang Compile - linux_amd64:
stage: build
variables:
GOOS: linux
GOARCH: amd64
script:
- >
go build
-ldflags="${LDFLAGS_GITVERSION} ${LDFLAGS_WEBHOOK}"
-o slackr
artifacts:
paths:
- slackr
expire_in: 1 year
only:
- main
Golang Compile - linux_mips64:
stage: build
variables:
GOOS: linux
GOARCH: mips64
script:
- >
go build
-ldflags="${LDFLAGS_GITVERSION} ${LDFLAGS_WEBHOOK}"
-o slackr
artifacts:
paths:
- slackr
expire_in: 1 year
only:
- main
Golang Compile - linux_armv7l:
stage: build
variables:
GOOS: linux
GOARCH: arm
GOARM: "7"
script:
- >
go build
-ldflags="${LDFLAGS_GITVERSION} ${LDFLAGS_WEBHOOK}"
-o slackr
artifacts:
paths:
- slackr
expire_in: 1 year
only:
- main
Golang Compile - darwin_amd64:
stage: build
variables:
GOOS: darwin
GOARCH: amd64
script:
- >
go build
-ldflags="${LDFLAGS_GITVERSION} ${LDFLAGS_WEBHOOK}"
-o slackr
artifacts:
paths:
- slackr
expire_in: 1 year
only:
- main