This repository has been archived by the owner on Jun 14, 2022. It is now read-only.
forked from mackerelio/mackerel-agent-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
79 lines (72 loc) · 2.12 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
image: golang:1.14
variables:
REPO_NAME: 'gitlab.com/kometchtech/mackerel-agent-plugins'
GIT_DEPTH: '1'
GO111MODULE: 'on'
cache:
untracked: true
key: "$CI_COMMIT_REF_NAME"
paths:
- /apt-cache
- /go/src/github.com
- /go/src/golang.org
- /go/src/google.golang.org
- /go/src/gopkg.in
stages:
- build
- test
- deploy
- cleanup
build_job:
stage: build
only:
- master
before_script:
- apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get install -y -qq devscripts debhelper rpm fakeroot binutils-aarch64-linux-gnu binutils-arm-linux-gnueabihf
- mkdir -p ${GOPATH}/src/$(dirname ${REPO_NAME})
- mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
- ln -svf ${CI_PROJECT_DIR} ${GOPATH}/src/${REPO_NAME}
- go get github.com/x-motemen/gobump/cmd/gobump
- go get github.com/mackerelio/golib/cmd/mackerel-github-release
script:
- cd ${GOPATH}/src/${REPO_NAME}
- make build rpm deb
# - mv /root/rpmbuild/RPMS/noarch/*.rpm packaging/
- mv /root/rpmbuild/RPMS/aarch64/*.rpm packaging/
- mv /root/rpmbuild/RPMS/armv7l/*.rpm packaging/
artifacts:
paths:
- packaging/*.deb
- packaging/*.rpm
when: on_success
expire_in: 1d
test_job:
stage: test
before_script:
- apt-get update
- DEBIAN_FRONTEND=noninteractive apt-get install -y -qq redis-server memcached
- mkdir -p ${GOPATH}/src/$(dirname ${REPO_NAME})
- ln -svf ${CI_PROJECT_DIR} ${GOPATH}/src/${REPO_NAME}
script:
- cd ${GOPATH}/src/${REPO_NAME}
- make lint cover testconvention
allow_failure: false
deploy_job:
stage: deploy
cache: {}
only:
- master
before_script:
- VERSION=`cat ${CI_PROJECT_DIR}/Makefile | grep VERSION | head -n 1 | awk '{print $3}'`
- rm -f packaging/config.json packaging/*.orig.tar.gz
- go get -u github.com/tcnksm/ghr
script:
- ghr -t ${GITHUB_TOKEN} -u kometchtech -r mackerel-agent-plugins -replace v${VERSION} packaging/
cleanup:
stage: cleanup
cache:
key: empty
policy: pull
script:
- rm -rf /home/gitlab/cache/kometchtech/mackerel-agent-plugins/${CI_COMMIT_REF_NAME}*