-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
184 lines (169 loc) · 6.27 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
variables:
# Configure postgres service (https://hub.docker.com/_/postgres/)
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
APT_CACHE_DIR: "$CI_PROJECT_DIR/apt-cache"
IMAGE_TAG: 'egrep -o "[0-9]\.([0-9]|[0-9][0-9])\.[0-9]" faraday_client/__init__.py'
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- when: always
cache:
paths:
- "$CI_PROJECT_DIR/.cache/pip"
- "$CI_PROJECT_DIR/apt-cache"
before_script:
- mkdir -pv $APT_CACHE_DIR
stages:
- build_faraday
- build_installers
- osx
generate_build_file:
image: registry.gitlab.com/faradaysec/devops
stage: build_faraday
script:
- "/bin/mkdir faraday_copy"
- "/usr/bin/rsync -aq --exclude 'faraday_copy' --exclude '.cache' . faraday_copy"
- "/bin/tar -zcf faraday.tar.gz faraday_copy"
artifacts:
name: 'faraday'
paths:
- "faraday.tar.gz"
expire_in: 3 days
build_nix_python3:
image: nixorg/nix
stage: build_faraday
script:
- mkdir -p ~/faraday
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/faraday-plugins.git ~/faraday/plugins
- cd ~/faraday/plugins
- git checkout dev
- cd -
- nix-build
- mkdir -p /opt/faraday-client
- cp -r $(readlink result)/* /opt/faraday-client
- tar czf /py3.tar.gz /opt/faraday-client $(nix-store --query --requisites $(readlink result))
- mv /py3.tar.gz $CI_PROJECT_DIR
artifacts:
name: python3
paths:
- py3.tar.gz
expire_in: 15 days # in the future we don't need to expire this.
generate_rpm:
stage: build_installers
image: centos:7
before_script:
- yum -y upgrade
- yum -y install which git epel-release centos-release-scl
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/faraday-linux-installers-builder.git
- mv py3.tar.gz /
- cd /; tar xf py3.tar.gz; cd -
- yum -y install gobject-introspection-devel curl zsh mailcap libffi-devel openssl-devel openldap-devel libxslt-devel libxml2-devel libxslt-devel freetype-devel libjpeg-devel gtk+-devel gtk3-devel gtk2-devel postgresql-devel
- yum groups -y install "Development Tools"
- yum -y install rh-python36 rh-ruby23 rh-ruby23-ruby-devel
- source /opt/rh/rh-ruby23/enable
- export X_SCLS="`scl enable rh-ruby23 'echo $X_SCLS'`"
- source /opt/rh/rh-python36/enable
- pip install virtualenv
- pip install virtualenv-tools3
script:
- mkdir build_installer
- cp -a faraday.tar.gz build_installer/.
- cd build_installer
- /bin/tar zxf faraday.tar.gz
- cd faraday_copy
- cp -r /nix .
- mv ../../faraday-linux-installers-builder .
- cd faraday-linux-installers-builder
- git clone https://github.com/jordansissel/fpm.git
- cd fpm
- git checkout d7b466787d17581bc723e474ecf6e18f48226031
- git apply ../fpm-patchs/fpm.virtualenv.patch
- make gem
- gem install --no-ri --no-rdoc fpm-1.11.0.gem
- cd ../../
- sh faraday-linux-installers-builder/build.sh $(eval $IMAGE_TAG) client rpm
- mv faraday-client_amd64.rpm ../../faraday-client_amd64.rpm
dependencies:
- generate_build_file
- build_nix_python3
artifacts:
name: 'faraday_$CI_COMMIT_REF_NAME.rpm'
paths:
- "faraday-client_amd64.rpm"
expire_in: 15 days
generate_deb:
image: registry.gitlab.com/faradaysec/devops
stage: build_installers
before_script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/faraday-linux-installers-builder.git
- mv py3.tar.gz /
- cd /; tar xf py3.tar.gz; cd -
script:
- mkdir build_installer
- cp -a faraday.tar.gz build_installer/.
- cd build_installer
- /bin/tar zxf faraday.tar.gz
- cd faraday_copy
- cp -r /nix .
- mv ../../faraday-linux-installers-builder .
- cd faraday-linux-installers-builder
- git clone https://github.com/jordansissel/fpm.git
- cd fpm
- git checkout d7b466787d17581bc723e474ecf6e18f48226031
- git apply ../fpm-patchs/fpm.virtualenv.patch
- make gem
- gem install --no-ri --no-rdoc fpm-1.11.0.gem
- cd ../../
- sh faraday-linux-installers-builder/build.sh $(eval $IMAGE_TAG) client deb
- mv faraday-client_amd64.deb ../../faraday-client_amd64.deb
dependencies:
- generate_build_file
- build_nix_python3
artifacts:
name: 'faraday_$CI_COMMIT_REF_NAME.deb'
paths:
- "faraday-client_amd64.deb"
expire_in: 15 days
macos_pkg:
tags:
- macos
stage: osx
allow_failure: true
before_script:
- echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
- export LDFLAGS="-L/usr/local/opt/openssl/lib"
- export CPPFLAGS="-I/usr/local/opt/openssl/include"
- export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
script:
- pip3 install virtualenv
- pip3 install virtualenv-tools3
- export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/opt/libffi/lib/pkgconfig"
- mkdir build_installer
- cp -a faraday.tar.gz build_installer/.
- cd build_installer
- /usr/bin/tar zxf faraday.tar.gz
- cd faraday_copy
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/faraday-linux-installers-builder.git
- cd faraday-linux-installers-builder
- git clone https://github.com/jordansissel/fpm.git
- cd fpm
- git checkout d7b466787d17581bc723e474ecf6e18f48226031
- git apply ../fpm-patchs/fpm.osx.patch
- make gem
- export GEM_HOME="$HOME/.gem"
- export GEM_PATH=$HOME/.gem
- export PATH=$PATH:$HOME/.gem/bin
- gem install fpm-1.11.0.gem
- cd ../../
- sh faraday-linux-installers-builder/build_osx.sh $(eval $IMAGE_TAG) client osxpkg
- mv faraday-client_amd64.pkg ../../Faraday-client.pkg
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME-binaries"
paths:
- Faraday-client.pkg
expire_in: 1 week
rules:
- when: manual
dependencies:
- generate_build_file