forked from making/yavi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline.yml
500 lines (495 loc) · 11.8 KB
/
pipeline.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
---
params:
git: &GIT_PARAMS
GIT_EMAIL: ((git-email))
GIT_NAME: ((git-name))
SRC_BRANCH: develop
java_opts: &JAVA_OPS
_JAVA_OPTIONS: -Duser.timezone=Asia/Tokyo -Duser.language=ja -Duser.country=JP -Djava.security.egd=file:/dev/./urandom
slack_on_success_params: &SLACK_SUCCESS
channel: '#concourse'
text: |
<!here> :white_check_mark: *$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME* succeeded with build <$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME|$BUILD_NAME>!
slack_on_failure_params: &SLACK_FAILURE
channel: '#concourse'
text: |
<!here> :rotating_light: *$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME* failed with build <$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME|$BUILD_NAME>!
resource_types:
- name: slack-notification
type: docker-image
source:
repository: cfcommunity/slack-notification-resource
tag: v1.1.3
- name: maven
type: docker-image
source:
repository: nulldriver/maven-resource
tag: latest
resources:
- name: repo-master
type: git
source:
uri: [email protected]:making/yavi.git
branch: master
private_key: ((github-private-key))
- name: repo-develop
type: git
source:
uri: [email protected]:making/yavi.git
branch: develop
private_key: ((github-private-key))
- name: repo-version
type: semver
source:
uri: [email protected]:making/yavi.git
branch: version
private_key: ((github-private-key))
file: version
driver: git
- name: gpg
type: git
source:
uri: https://github.com/maki-home/encrypted-gpg
branch: master
- name: sonatype-snapshots
type: maven
source:
url: https://oss.sonatype.org/service/local/staging/deploy/maven2
snapshot_url: https://oss.sonatype.org/content/repositories/snapshots/
artifact: am.ik.yavi:yavi:jar
username: ((sonatype-username))
password: ((sonatype-password))
- name: slack-alert
type: slack-notification
source:
url: ((slack-webhook-url))
jobs:
### Dev
- name: unit-test-develop
plan:
- in_parallel:
- get: repo
resource: repo-develop
trigger: true
- task: mvn-test
params:
<<: *JAVA_OPS
config: &MVN_TEST_CONFIG
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: 3.8.1-jdk-8
inputs:
- name: repo
caches:
- path: repo/m2
run:
path: bash
args:
- -c
- |
set -e
cd repo
rm -rf ~/.m2
ln -fs $(pwd)/m2 ~/.m2
mvn -V test
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- name: upload-to-nexus-snapshots
public: true
plan:
- get: repo
resource: repo-develop
passed:
- unit-test-develop
trigger: true
- task: mvn-package
config: &NEXUS_PACKAGE_CONFIG
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: 3.8.1-jdk-8
inputs:
- name: repo
outputs:
- name: build
caches:
- path: repo/m2
run:
path: bash
args:
- -c
- |
set -e
cd repo
rm -rf ~/.m2
ln -fs $(pwd)/m2 ~/.m2
mvn package -DskipTests=true
cp target/*.jar ../build/
- in_parallel:
- put: sonatype-snapshots
params:
file: build/*.jar
pom_file: repo/pom.xml
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
### Prod
- name: merge-develop-to-master
plan:
- in_parallel:
- get: repo-src
resource: repo-develop
passed:
- upload-to-nexus-snapshots
- get: repo-dest
resource: repo-master
- task: merge-develop-to-master
params:
<<: *GIT_PARAMS
SRC_BRANCH: develop
config: &MERGE_SRC_TO_DEST
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: 3.8.1-jdk-8
inputs:
- name: repo-src
- name: repo-dest
outputs:
- name: merged
run:
path: bash
args:
- -c
- |
set -e
shopt -s dotglob
mv -f repo-dest/* merged/
cd merged
git config --global user.email "${GIT_EMAIL}"
git config --global user.name "${GIT_NAME}"
git remote add -f src ../repo-src
git merge --no-edit src/${SRC_BRANCH}
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- put: repo-master
params:
repository: merged
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- name: unit-test-master
plan:
- get: repo
resource: repo-master
trigger: true
passed:
- merge-develop-to-master
- task: mvn-test
params:
<<: *JAVA_OPS
config:
<<: *MVN_TEST_CONFIG
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- name: tag-master
plan:
- in_parallel:
- get: repo
resource: repo-master
trigger: true
passed:
- unit-test-master
- get: repo-version
- task: mvn-versions-set
params:
<<: *GIT_PARAMS
config:
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: 3.8.1-jdk-8
inputs:
- name: repo
- name: repo-version
outputs:
- name: output
caches:
- path: repo/m2
run:
path: bash
args:
- -c
- |
set -e
VERSION=`cat repo-version/number`
cd repo
rm -rf ~/.m2
ln -fs $(pwd)/m2 ~/.m2
mvn versions:set -DnewVersion=${VERSION}
sed -i "s|<version>.*</version>|<version>${VERSION}</version>|" README.md
rm -f pom.xml.versionsBackup
shopt -s dotglob
shopt -s extglob
mv -f !(m2) ../output/
cd ../output
git config --global user.email "${GIT_EMAIL}"
git config --global user.name "${GIT_NAME}"
git add -A
git commit -m "Release ${VERSION}"
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- put: repo-master
params:
repository: output
tag: repo-version/number
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- name: upload-to-sonatype-releases
plan:
- in_parallel:
- get: repo
resource: repo-master
passed:
- tag-master
trigger: true
- get: gpg
- task: mvn-deploy
params:
SONATYPE_USERNAME: ((sonatype-username))
SONATYPE_PASSWORD: ((sonatype-password))
GPG_KEYNAME: ((gpg-keyname))
GPG_PASSPHRASE: ((gpg-passphrase))
ENCRYPTION_PASSWORD: ((gpg-encryption-password))
GPG_DIR: .
config:
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: 3.3.9-jdk-8 # openssl 1.0.1 needed
inputs:
- name: repo
- name: gpg
outputs:
- name: signed
caches:
- path: repo/m2
run:
path: bash
args:
- -c
- |
set -e
mkdir -p ~/.gnupg
openssl version
gpg/deceypt-pgp.sh repo
cd repo
rm -rf ~/.m2
ln -fs $(pwd)/m2 ~/.m2
cat > settings.xml <<EOF
<settings>
<servers>
<server>
<id>repo</id>
<username>${SONATYPE_USERNAME}</username>
<password>${SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
EOF
mvn javadoc:jar \
source:jar \
package \
org.apache.maven.plugins:maven-gpg-plugin:1.6:sign \
org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy \
-s settings.xml \
-Dgpg.executable=gpg \
-Dgpg.keyname=${GPG_KEYNAME} \
-Dgpg.passphrase=${GPG_PASSPHRASE} \
-Dgpg.defaultKeyring=false \
-Dgpg.publicKeyring=./pubring.gpg \
-Dgpg.secretKeyring=./secring.gpg \
-DserverId=repo \
-DnexusUrl=https://oss.sonatype.org \
-DautoReleaseAfterClose=true \
-DaltDeploymentRepository=repo::default::https://oss.sonatype.org/service/local/staging/deploy/maven2 \
-DskipTests=true
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- name: bump-to-next-patch-version
plan:
- in_parallel:
- get: repo-src
resource: repo-master
passed:
- upload-to-sonatype-releases
trigger: true
- get: repo-dest
resource: repo-develop
- get: repo-version
params:
bump: patch
- task: merge-master-to-develop
params:
<<: *GIT_PARAMS
SRC_BRANCH: master
config:
<<: *MERGE_SRC_TO_DEST
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- task: just-move
config:
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: 3.8.1-jdk-8
inputs:
- name: merged
outputs:
- name: repo
run:
path: bash
args:
- -c
- |
set -e
shopt -s dotglob
cp -r merged/* repo/
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- task: mvn-versions-set
params:
<<: *GIT_PARAMS
config: &MVN_VERSIONS_SET_CONFIG
platform: linux
image_resource:
type: docker-image
source:
repository: maven
tag: 3.8.1-jdk-8
inputs:
- name: repo
- name: repo-version
outputs:
- name: output
caches:
- path: repo/m2
run:
path: bash
args:
- -c
- |
set -e
VERSION=`cat repo-version/number`-SNAPSHOT
cd repo
rm -rf ~/.m2
ln -fs $(pwd)/m2 ~/.m2
mvn versions:set -DnewVersion=${VERSION} -DallowSnapshots
rm -f pom.xml.versionsBackup
shopt -s dotglob
shopt -s extglob
mv -f !(m2) ../output/
cd ../output
git config --global user.email "${GIT_EMAIL}"
git config --global user.name "${GIT_NAME}"
git add -A
git commit -m "Bump to ${VERSION}"
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- put: repo-develop
params:
repository: output
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
- put: repo-version
params:
file: repo-version/number
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
on_success:
put: slack-alert
params:
<<: *SLACK_SUCCESS
- name: bump-to-next-minor-version
plan:
- in_parallel:
- get: repo
resource: repo-develop
- get: repo-version
params:
bump: minor
- task: mvn-versions-set
params:
<<: *GIT_PARAMS
config:
<<: *MVN_VERSIONS_SET_CONFIG
- put: repo-develop
params:
repository: output
- put: repo-version
params:
file: repo-version/number
- name: bump-to-next-major-version
plan:
- in_parallel:
- get: repo
resource: repo-develop
- get: repo-version
params:
bump: major
- task: mvn-versions-set
params:
<<: *GIT_PARAMS
config:
<<: *MVN_VERSIONS_SET_CONFIG
- put: repo-develop
params:
repository: output
- put: repo-version
params:
file: repo-version/number
on_failure:
put: slack-alert
params:
<<: *SLACK_FAILURE
on_success:
put: slack-alert
params:
<<: *SLACK_SUCCESS