forked from reteno-com/reteno-mobile-android-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
168 lines (153 loc) · 4.31 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
image: jangrewe/gitlab-ci-android
variables:
DOCKER_DRIVER: overlay2
stages:
- build_&_test
- pre-deploy
- deploy
- post-deploy
# Default actions before each job
default:
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
- chmod +x ./gradlew
- mkdir keystore
- base64 -d $DEBUG_KEYSTORE > keystore/debug.keystore
- base64 -d $KEYSTORE_CONFIG_GRADLE > keystore/keystore_config.gradle
- base64 -d $FIREBASE_JSON > keystore/firebase_app_distribution.json
- base64 -d $RELEASE_KEYSTORE > keystore/release.keystore
- base64 -d $LOCAL_PROPERTIES > local.properties
- base64 -d $KEYS_PROPERTIES > RetenoSdkCore/keys.properties
cache:
- key: "build-number"
paths:
- build-number
- key: "$CI_COMMIT_REF_SLUG"
paths:
- last-build-hash
- key: ${CI_PROJECT_ID}
paths:
- .gradle/
# Run for merge requests/web/trigger only
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "trigger"
# Make Project (Debug)
assemble:Debug:
stage: build_&_test
interruptible: true
script:
- ./gradlew assembleDebug
artifacts:
paths:
- app/build/outputs/
tags:
- docker
# Make Project (Qa)
assemble:Qa:
stage: build_&_test
interruptible: true
script:
- ./gradlew assembleQa
artifacts:
paths:
- app/build/outputs/
tags:
- docker
# Run all SdkCore tests, if any fails, interrupt the pipeline(fail it)
tests_SDK:Core:
stage: build_&_test
interruptible: true
script:
- ./gradlew --no-daemon -s RetenoSdkCore:testDebugUnitTest
artifacts:
paths:
- ./RetenoSdkCore/build/reports/tests/testDebugUnitTest
when: always
expire_in: 2 week
tags:
- docker
# Run all SdkFcm tests, if any fails, interrupt the pipeline(fail it)
tests_SDK:Fcm:
stage: build_&_test
interruptible: true
script:
- ./gradlew --no-daemon -s RetenoSdkFcm:testDebugUnitTest
artifacts:
paths:
- ./RetenoSdkFcm/build/reports/tests/testDebugUnitTest
when: always
expire_in: 2 week
tags:
- docker
# Run all SdkPush tests, if any fails, interrupt the pipeline(fail it)
tests_SDK:Push:
stage: build_&_test
interruptible: true
script:
- ./gradlew --no-daemon -s RetenoSdkPush:testDebugUnitTest
artifacts:
paths:
- ./RetenoSdkPush/build/reports/tests/testDebugUnitTest
when: always
expire_in: 2 week
tags:
- docker
incrementVersion:
stage: pre-deploy
script:
- touch build-number
- BUILD_NUMBER_CACHE=0
- BUILD_NUMBER_VARIABLE=$BUILD_NUMBER
- test -s build-number && BUILD_NUMBER_CACHE=$(<build-number)
- >
test $BUILD_NUMBER_CACHE -lt $BUILD_NUMBER_VARIABLE
&& echo $((++BUILD_NUMBER_VARIABLE))> build-number
|| echo $((++BUILD_NUMBER_CACHE))> build-number
- export BUILD_NUMBER=$(<build-number)
- echo "BUILD_NUMBER = $BUILD_NUMBER"
- touch last-build-hash
- export VERSION_NAME_APP=$(grep -E "VERSION_NAME" gradle.properties | cut -d "=" -f2)
- export VERSION_SDK=$(grep -E "VERSION_NAME" gradle.properties | cut -d "=" -f2)
- export AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
- export AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
- echo "" > release-notes.txt
- sed -i 's|^|Environment - Qa\n|' release-notes.txt
- git rev-parse --short HEAD> last-build-hash
- sed -i '1s|^|Version Sdk - '"$VERSION_SDK"'\n|' release-notes.txt
- sed -i '1s|^|Author - '"$AUTHOR_NAME($AUTHOR_EMAIL)"'\n|' release-notes.txt
- sed -i '1s|^|Version App - '"$VERSION_NAME_APP ($BUILD_NUMBER)"'\n|' release-notes.txt
- sed -i '1s|^|Branch - '"$CI_COMMIT_REF_NAME"'\n|' release-notes.txt
artifacts:
paths:
- release-notes.txt
when: on_success
expire_in: 2 week
when: manual
allow_failure: false
tags:
- docker
deployQaToFirebase:
stage: deploy
script:
- export BUILD_NUMBER=$(<build-number)
- ./gradlew assembleQa appDistributionUploadQa --artifactType="APK"
artifacts:
paths:
- ./app/build/outputs/apk/qa/app-qa.apk
when: on_success
expire_in: 2 week
when: on_success
tags:
- docker
notifySlack:
stage: post-deploy
script:
- RELEASE_NOTES=$(<release-notes.txt)
- echo "$RELEASE_NOTES"
- ./notify-slack.sh "$RELEASE_NOTES"
when: on_success
tags:
- docker