Skip to content

Commit 5019731

Browse files
committed
[ci skip] cleanup ci yml
1 parent 03ee25d commit 5019731

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

.gitlab-ci.yml

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
image: golang:latest
22

33
stages:
4+
- prebuild
45
- build
56
- test
67
- deploy
@@ -15,42 +16,60 @@ before_script:
1516
- mkdir -p .gopath/bin
1617
- export GOPATH=$(pwd)/.gopath
1718
- export PATH=$GOPATH/bin:$PATH
18-
- go get github.com/aktau/github-release
19-
build:
19+
- |
20+
[ "${CI_COMMIT_TAG:-x}" != "x" ] && VER=${CI_COMMIT_TAG} || VER=${CI_COMMIT_SHORT_SHA}
21+
22+
.build_job_template: &build_job_definition
23+
stage: build
2024
artifacts:
2125
expire_in: 1 week
2226
paths:
2327
- binaries
24-
stage: build
28+
29+
.os_build_job_template: &os_build_job_definition
30+
<<: *build_job_definition
2531
script:
26-
- export GOARCH=amd64
2732
- declare -A extensions=()
2833
- extensions["windows"]=".exe"
29-
- |
30-
[ "${CI_COMMIT_TAG:-x}" != "x" ] && VER=${CI_COMMIT_TAG} || VER=${CI_COMMIT_SHORT_SHA}
31-
- |
32-
[ "${CI_COMMIT_TAG:-x}" != "x" ] && TAG=latest || VER=nightly
34+
- go build -o gql"${extensions[${GOOS}]}" main.go
35+
- tar zcf gql-${GOOS}-${GOARCH}-${VER}.tar.gz gql
3336
- mkdir binaries
34-
- |
35-
for os in linux windows darwin; do
36-
GOOS=$os go build -o gql"${extensions[${os}]}" main.go
37-
tar zcf gql-${os}-${GOARCH}-${VER}.tar.gz gql
38-
tar zcf gql-${os}-${GOARCH}-${TAG}.tar.gz gql
39-
done
40-
- mv gql-*.tar.gz binaries
37+
- mv gql-${GOOS}-${GOARCH}-${VER}.tar.gz binaries
38+
39+
prebuild:
40+
stage: prebuild
41+
script:
42+
- go mod download
43+
44+
build:linux:amd64:
45+
variables:
46+
GOOS: linux
47+
GOARCH: amd64
48+
<<: *os_build_job_definition
49+
50+
build:darwin:amd64:
51+
variables:
52+
GOOS: darwin
53+
GOARCH: amd64
54+
<<: *os_build_job_definition
55+
56+
build:windows:amd64:
57+
variables:
58+
GOOS: windowns
59+
GOARCH: amd64
60+
<<: *os_build_job_definition
4161

4262
test:
43-
stage: build
63+
stage: test
4464
script:
4565
- go test ./...
4666

4767
deploy:
4868
stage: deploy
49-
dependencies:
50-
- build
5169
only:
5270
- tags
5371
script:
72+
- go get github.com/aktau/github-release
5473
- |
5574
github-release release \
5675
--user slothking-online \

0 commit comments

Comments
 (0)