-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
85 lines (77 loc) · 1.92 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
image: openjdk:8-jdk
stages:
- test
- build
- deploy
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- apt update && apt install gettext-base
###########################
# Tests
###########################
unit-tests:
stage: test
image: openjdk:8-jdk
variables:
VERSION: test
OSSRHUSERNAME: ossrhusername
OSSRHPASSWORD: ossrhpassword
script:
- envsubst '${VERSION}','${OSSRHUSERNAME}','${OSSRHPASSWORD}' < build.gradle > build.gradle.new
- mv build.gradle.new build.gradle
- ./gradlew check
after_script:
- cat build/reports/jacoco/test/html/index.html
coverage: '/Total.*?([0-9]{1,3})%/'
cache:
paths:
- .gradle/wrapper
- .gradle/caches
artifacts:
when: always
paths:
- build/reports/
expire_in: 1 day
###################
# Build
###################
build-jar:
stage: build
variables:
VERSION: build
OSSRHUSERNAME: ossrhusername
OSSRHPASSWORD: ossrhpassword
script:
- envsubst '${VERSION}','${OSSRHUSERNAME}','${OSSRHPASSWORD}' < build.gradle > build.gradle.new
- mv build.gradle.new build.gradle
- ./gradlew assemble
artifacts:
paths:
- build/libs/*.jar
expire_in: 1 day
only:
- master
except:
- tags
###################
# Deploy
###################
deploy-jar:
stage: deploy
variables:
OSSRHUSERNAME: ${OSSRH_LOGIN}
OSSRHPASSWORD: ${OSSRH_PASS}
script:
- VERSION=$(echo ${CI_COMMIT_REF_NAME} | sed "s/v//")
- export VERSION=$VERSION
- envsubst '${VERSION}','${OSSRHUSERNAME}','${OSSRHPASSWORD}' < build.gradle > build.gradle.new
- mv build.gradle.new build.gradle
- mkdir .gradle
- echo "$GPG_KEY_PRIVATE" > private.key
- gpg --import private.key
- gpg --export-secret-keys -o secring.gpg
- echo "$GRADLE_PROPERTIES" > $GRADLE_USER_HOME/gradle.properties
- ./gradlew -Psign uploadArchives
- ./gradlew closeAndReleaseRepository
only:
- tags