forked from TheHive-Project/TheHive
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.drone.yml
147 lines (126 loc) · 3.7 KB
/
.drone.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
147
---
kind: pipeline
name: default
# Disable default clone
clone:
disable: true
steps:
# This clone step doesn't use "root" user
- name: clone
image: plugins/git:next
# Restore cache of downloaded dependencies
- name: restore-cache
image: drillster/drone-volume-cache
settings:
restore: true
mount:
- .sbt
- .ivy2
- ui/node_modules
- ui/bower_components
volumes: [{name: cache, path: /cache}]
# Run project tests
- name: run-tests
image: tooom/docker-scala-node
commands:
- . ~/.nvm/nvm.sh
- sbt -Duser.home=$PWD test
# Build packages
- name: build-packages
image: tooom/docker-scala-node
settings:
pgp_key: {from_secret: pgp_key}
commands:
- |
. ~/.nvm/nvm.sh
[ -n "$PLUGIN_PGP_KEY" ] && gpg --batch --import - <<< $PLUGIN_PGP_KEY
sbt -Duser.home=$PWD docker:stage debian:packageBin rpm:packageBin universal:packageBin
when:
event: [tag]
# Save external libraries in cache
- name: save-cache
image: drillster/drone-volume-cache
settings:
rebuild: true
mount:
- .sbt
- .ivy2
- ui/node_modules
- ui/bower_components
volumes: [{name: cache, path: /cache}]
- name: publish-package
image: tooom/docker-bintray
settings:
user: {from_secret: bintray_user}
key: {from_secret: bintray_key}
subject: thehive-project-staging
package: thehive
commands:
- |
export PLUGIN_USER
export PLUGIN_KEY
export PLUGIN_SUBJECT
export PLUGIN_PACKAGE
export PLUGIN_VERSION=$(cut -d\" -f2 version.sbt)
echo "Publishing package version $PLUGIN_VERSION"
if echo $PLUGIN_VERSION | grep -qvi -E \
-e '^[0-9]+\.[0-9]+\.[0-9]+$' \
-e '^[0-9]+\.[0-9]+\.[0-9]+-[0-9]+$' \
-e '^[0-9]+\.[0-9]+\.[0-9]+-RC[0-9]+$'; then
echo The version $PLUGIN_VERSION has invalid format
exit 1
fi
CHANNEL=stable
echo $PLUGIN_VERSION | grep -qi rc && CHANNEL=beta
DEB_FILE=target/thehive_$${PLUGIN_VERSION}_all.deb
RPM_FILE=target/rpm/RPMS/noarch/thehive-$${PLUGIN_VERSION}.noarch.rpm
ZIP_FILE=target/universal/thehive-$${PLUGIN_VERSION}.zip
upload \
--file $DEB_FILE \
--repo debian-beta \
--extra-param deb_distribution=any \
--extra-param deb_component=main \
--extra-param deb_architecture=all
[ $CHANNEL = stable ] && upload \
--file $DEB_FILE \
--repo debian-stable \
--extra-param deb_distribution=any \
--extra-param deb_component=main \
--extra-param deb_architecture=all
upload \
--file $RPM_FILE \
--repo rpm-beta
[ $CHANNEL = stable ] && upload \
--file $RPM_FILE \
--repo rpm-stable
upload \
--file $ZIP_FILE \
--repo binary
LATEST_VERSION=latest
[ $CHANNEL = beta ] && LATEST_VERSION=latest-beta
removeVersion \
--repo binary \
--version $LATEST_VERSION
upload \
--file $ZIP_FILE \
--repo binary \
--version $LATEST_VERSION \
--dest-file thehive-$${LATEST_VERSION}.zip
when:
event: [tag]
# Publish docker image
- name: docker
image: plugins/docker
settings:
context: target/docker/stage
dockerfile: target/docker/stage/Dockerfile
repo: tooom/thehive
auto_tag: true
username: {from_secret: docker_username}
password: {from_secret: docker_password}
when:
event: [tag]
volumes:
- name: cache
host:
path: /opt/drone/cache