forked from airgap-it/airgap-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
280 lines (264 loc) · 9.77 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
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
image: docker:latest
variables:
TEST_TAG: test_$CI_COMMIT_SHA
GOOGLE_TAG: eu.gcr.io/papers-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA
GOOGLE_TAG_LATEST: eu.gcr.io/papers-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
GOOGLE_TAG_DEV: eu.gcr.io/papers-dev-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAMESPACE:$CI_COMMIT_SHA
GOOGLE_TAG_LATEST_DEV: eu.gcr.io/papers-dev-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAMESPACE:latest
GOOGLE_TAG_ANDROID_CURRENT: eu.gcr.io/papers-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:android-$CI_COMMIT_SHA
GOOGLE_TAG_ELECTRON_LINUX_CURRENT: eu.gcr.io/papers-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:electron-linux-$CI_COMMIT_SHA
GOOGLE_TAG_ELECTRON_WINDOWS_CURRENT: eu.gcr.io/papers-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:electron-windows-$CI_COMMIT_SHA
stages:
- build
- test
- qa
- platform_build
- publish
- deploy
build_ionic:
stage: build
script:
- docker build -t $TEST_TAG .
tags:
- docker
unit:
allow_failure: true
stage: test
script:
- docker run --name unit-$CI_COMMIT_SHA $TEST_TAG npm run test-ci
- docker run --name lint-$CI_COMMIT_SHA $TEST_TAG npm run lint-ci
- docker cp unit-$CI_COMMIT_SHA:/app/src/coverage/report-lcov/lcov.info lcov.info
- docker cp lint-$CI_COMMIT_SHA:/app/lintReport.json lintReport.json
after_script:
- docker rm unit-$CI_COMMIT_SHA
- docker rm lint-$CI_COMMIT_SHA
tags:
- docker
artifacts:
paths:
- lcov.info
- lintReport.json
qa:
stage: qa
script:
- docker create --name qa-$CI_PIPELINE_ID $TEST_TAG npm run sonar-scanner -- -X
-Dsonar.typescript.lcov.reportPaths=lcov.info
-Dsonar.typescript.tslint.reportPaths=lintReport.json
-Dsonar.test.inclusions=**/*.spec.ts
-Dsonar.tests=src/
-Dsonar.exclusions=**/node_modules/**,**/*.spec.ts,src/assets/libs/**
-Dsonar.sources=src/
-Dsonar.host.url=$SONAR_URL
-Dsonar.login=$SONAR_LOGIN
-Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
-Dsonar.gitlab.project_id=$CI_PROJECT_ID
-Dsonar.branch.name=$CI_BUILD_REF_NAME
- docker cp lcov.info qa-$CI_PIPELINE_ID:/app/lcov.info
- docker cp lintReport.json qa-$CI_PIPELINE_ID:/app/lintReport.json
- docker start -a qa-$CI_PIPELINE_ID
after_script:
- docker rm -f qa-$CI_PIPELINE_ID || true
tags:
- docker
build-android:
stage: platform_build
when: manual
tags:
- docker
variables:
LOCAL_ANDROID: 'android-$CI_PIPELINE_ID'
script:
- sed -i -e "s/versionName \"0.0.0\"/versionName \"$VERSION\"/g" android/app/build.gradle
- docker build -f build/android/Dockerfile -t $GOOGLE_TAG_ANDROID_CURRENT --build-arg BUILD_NR="$CI_PIPELINE_ID" --build-arg VERSION="$VERSION" .
- docker run --name $LOCAL_ANDROID $GOOGLE_TAG_ANDROID_CURRENT echo "container ran."
- docker cp $LOCAL_ANDROID:/app/android-release-unsigned.apk airgap-wallet-release-unsigned-$CI_PIPELINE_ID.apk
- docker cp $LOCAL_ANDROID:/app/android-debug.apk airgap-wallet-debug-$CI_PIPELINE_ID.apk
after_script:
- docker rm -f $LOCAL_ANDROID || true
artifacts:
paths:
- airgap-wallet-release-unsigned-$CI_PIPELINE_ID.apk
- airgap-wallet-debug-$CI_PIPELINE_ID.apk
build-ios:
stage: platform_build
when: manual
before_script:
- echo "$IOS_BUILD_JSON" > build.json
script:
- export DEVELOPER_DIR=$XCODE_PATH
- nvm use 16
- npm install
- npm run prepare-prod-build
- npm run apply-diagnostic-modules # manually remove unused cordova-diagnostic-plugin modules
- npx ionic build --prod
- npx cap sync ios
- xcodebuild -workspace ios/App/App.xcworkspace -scheme "App" -destination generic/platform=iOS -configuration Release archive -archivePath ios/airgap-wallet-$VERSION-$CI_PIPELINE_ID.xcarchive MARKETING_VERSION=$VERSION CURRENT_PROJECT_VERSION=$CI_PIPELINE_ID -allowProvisioningUpdates
artifacts:
paths:
- ios/airgap-wallet-$VERSION-$CI_PIPELINE_ID.xcarchive
tags:
- ios
build-mac:
stage: platform_build
when: manual
script:
- 'sed -i -e "s/\"version\": \"0.0.1\"/\"version\": \"${VERSION}\"/g" electron/package.json'
- nvm use 16
- npm install
- npm run prepare-prod-build
- npm --prefix electron/ install
- npm run build:electron:prod
- npx cap sync electron
- npm --prefix electron/ run build:mac
artifacts:
name: 'electron_macos'
paths:
- electron/build/airgap-wallet-$VERSION.dmg
- electron/build/airgap-wallet-$VERSION.dmg.blockmap
- electron/build/airgap-wallet-$VERSION-mac.zip
tags:
- ios
build-linux:
stage: platform_build
when: manual
tags:
- docker
variables:
LOCAL_LINUX: 'linux-$CI_PIPELINE_ID'
script:
- docker build -f build/electron/linux/Dockerfile -t $GOOGLE_TAG_ELECTRON_LINUX_CURRENT --build-arg VERSION="$VERSION" .
- docker run --name $LOCAL_LINUX $GOOGLE_TAG_ELECTRON_LINUX_CURRENT echo "container ran."
- docker cp $LOCAL_LINUX:/app/electron/build/airgap-wallet-$VERSION.AppImage electron/airgap-wallet-$VERSION.AppImage
after_script:
- docker rm -f $LOCAL_LINUX || true
artifacts:
name: 'electron_linux'
paths:
- electron/airgap-wallet-$VERSION.AppImage
build-windows:
stage: platform_build
when: manual
tags:
- docker
variables:
LOCAL_WINDOWS: 'windows-$CI_PIPELINE_ID'
script:
- docker build -f build/electron/windows/Dockerfile -t $GOOGLE_TAG_ELECTRON_WINDOWS_CURRENT --build-arg VERSION="$VERSION" .
- docker run --name $LOCAL_WINDOWS $GOOGLE_TAG_ELECTRON_WINDOWS_CURRENT echo "container ran."
- docker cp $LOCAL_WINDOWS:/app/electron/build/airgap-wallet-$VERSION.exe electron/airgap-wallet-$VERSION.exe
- docker cp $LOCAL_WINDOWS:/app/electron/build/airgap-wallet-$VERSION.exe.blockmap electron/airgap-wallet-$VERSION.exe.blockmap
after_script:
- docker rm -f $LOCAL_WINDOWS || true
artifacts:
name: 'electron_windows'
paths:
- electron/airgap-wallet-$VERSION.exe
- electron/airgap-wallet-$VERSION.exe.blockmap
build-web:
stage: platform_build
when: manual
tags:
- docker
script:
- docker build -f build/web/Dockerfile -t $GOOGLE_TAG -t $GOOGLE_TAG_DEV .
tags:
- docker
publish-ios:
stage: publish
when: manual
before_script:
- echo "$IOS_EXPORT_OPTIONS" > exportOptions.plist
script:
- export DEVELOPER_DIR=$XCODE_PATH
- xcodebuild -exportArchive -archivePath ios/airgap-wallet-$VERSION-$CI_PIPELINE_ID.xcarchive -exportOptionsPlist exportOptions.plist -exportPath ios/ -allowProvisioningUpdates
- xcrun altool --upload-app -f ios/App.ipa -t ios -u $IOS_USERNAME -p $IOS_PASSWORD
tags:
- ios
publish-web-dev:
stage: publish
when: manual
needs:
- build-web
image: google/cloud-sdk
before_script:
- echo $GCLOUD_GOOGLE_KEY_DEV > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT_DEV --key-file key.json
- gcloud config set account $GCLOUD_ACCOUNT_DEV
- gcloud config set project $GCLOUD_PROJECT_DEV
- gcloud config set compute/zone $GCLOUD_ZONE
- gcloud auth configure-docker
script:
- docker tag $GOOGLE_TAG_DEV $GOOGLE_TAG_LATEST_DEV
- docker push $GOOGLE_TAG_DEV
- docker push $GOOGLE_TAG_LATEST_DEV
tags:
- docker
publish-web-prod:
stage: publish
needs:
- build-web
image: google/cloud-sdk
before_script:
- echo $GCLOUD_GOOGLE_KEY > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT --key-file key.json
- gcloud config set project $GCLOUD_PROJECT
- gcloud config set account $GCLOUD_ACCOUNT
- gcloud config set compute/zone $GCLOUD_ZONE
- gcloud auth configure-docker
script:
- docker tag $GOOGLE_TAG $GOOGLE_TAG_LATEST
- docker push $GOOGLE_TAG
- docker push $GOOGLE_TAG_LATEST
only:
- master
tags:
- docker
deploy-web-dev:
stage: deploy
needs:
- publish-web-dev
when: manual
image: google/cloud-sdk
before_script:
- echo $GCLOUD_GOOGLE_KEY_DEV > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT_DEV --key-file key.json
- gcloud config set account $GCLOUD_ACCOUNT_DEV
- gcloud config set project $GCLOUD_PROJECT_DEV
- gcloud config set compute/zone $GCLOUD_ZONE
- gcloud container clusters get-credentials papers-cluster-development
script:
- find k8s -type f -name \*.yaml -exec sed -i "s|__NAMESPACE__|"$NAMESPACE"|g" {} +
- find k8s -type f -name \*.yaml -exec sed -i "s|__CI_PROJECT_NAME__|"$CI_PROJECT_NAME"|g" {} +
- find k8s -type f -name \*.yaml -exec sed -i "s|__TO_BE_REPLACED_BY_IMAGE_TAG__|"$GOOGLE_TAG_DEV"|g" {} +
- kubectl apply -f k8s/airgap-wallet/common/namespace.yaml
- kubectl apply -f k8s/airgap-wallet/development/ --recursive
- kubectl apply -f k8s/airgap-wallet/common/ --recursive
only:
- develop
tags:
- docker
deploy-web-prod:
stage: deploy
needs:
- publish-web-prod
when: manual
image: google/cloud-sdk
before_script:
- echo $GCLOUD_GOOGLE_KEY > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT --key-file key.json
- gcloud config set account $GCLOUD_ACCOUNT
- gcloud config set project $GCLOUD_PROJECT
- gcloud config set compute/zone $GCLOUD_ZONE
- gcloud container clusters get-credentials papers-cluster-production
script:
- find k8s -type f -name \*.yaml -exec sed -i "s|__NAMESPACE__|"$NAMESPACE"|g" {} +
- find k8s -type f -name \*.yaml -exec sed -i "s|__CI_PROJECT_NAME__|"$CI_PROJECT_NAME"|g" {} +
- find k8s -type f -name \*.yaml -exec sed -i "s|__TO_BE_REPLACED_BY_IMAGE_TAG__|"$GOOGLE_TAG"|g" {} +
- kubectl apply -f k8s/airgap-wallet/common/namespace.yaml
- kubectl apply -f k8s/airgap-wallet/production/ --recursive
- kubectl apply -f k8s/airgap-wallet/common/ --recursive
only:
- master
tags:
- docker