forked from airgap-it/airgap-vault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
executable file
·103 lines (97 loc) · 4.43 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
image: docker:latest
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE
IMAGE_TAG_CURRENT: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
IMAGE_TAG_ANDROID_CURRENT: $CI_REGISTRY_IMAGE:android-$CI_COMMIT_SHA
IMAGE_TAG_ANDROID_LATEST: $CI_REGISTRY_IMAGE:android-latest
stages:
- build
- test
- native_build
- qa
build_ionic:
stage: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build --cache-from $IMAGE_TAG_LATEST -t $IMAGE_TAG .
- docker tag $IMAGE_TAG $IMAGE_TAG_CURRENT
- docker tag $IMAGE_TAG $IMAGE_TAG_LATEST
- docker push $IMAGE_TAG_CURRENT
- docker push $IMAGE_TAG_LATEST
tags:
- docker
unit:
stage: test
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker run --name unit-$CI_COMMIT_SHA $IMAGE_TAG_CURRENT npm run test-ci
- docker run --name lint-$CI_COMMIT_SHA $IMAGE_TAG_CURRENT npm run lint-ci
- docker cp unit-$CI_COMMIT_SHA:/app/coverage/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
build_android:
stage: native_build
when: manual
tags:
- docker
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- sed -i -e "s/version=\"0.0.0\"/version=\"$VERSION\"/g" config.xml
- docker build -f build/android/Dockerfile -t $IMAGE_TAG_ANDROID_CURRENT --build-arg KEYSTORE_PASSWORD="$KEYSTORE_PASSWORD" --build-arg KEYSTORE_ALIAS="$KEYSTORE_ALIAS" --build-arg BUILD_NR="$CI_PIPELINE_ID" .
- docker run --name $CI_PIPELINE_ID $IMAGE_TAG_ANDROID_CURRENT echo "container ran."
- docker cp $CI_PIPELINE_ID:/app/android-release-unsigned.apk android-release-unsigned-$CI_PIPELINE_ID.apk
- docker cp $CI_PIPELINE_ID:/app/android-debug.apk android-debug-$CI_PIPELINE_ID.apk
after_script:
- docker rm -f $CI_PIPELINE_ID || true
artifacts:
paths:
- android-release-unsigned-$CI_PIPELINE_ID.apk
- android-debug-$CI_PIPELINE_ID.apk
build_ios:
stage: native_build
when: manual
before_script:
- echo "$IOS_BUILD_JSON" > build.json
- echo "$IOS_EXPORT_OPTIONS" > exportOptions.plist
script:
- sudo xcode-select -s /Applications/Xcode_9.4.app/Contents/Developer
- sed -i -e "s/ios-CFBundleVersion=\"0.0.0\"/ios-CFBundleVersion=\"1.0.$CI_PIPELINE_ID\"/g" config.xml
- sed -i -e "s/version=\"0.0.0\"/version=\"$VERSION\"/g" config.xml
- nvm use v10.13.0
- npm install
- ionic cordova build ios --prod --release
- find ./resources/ -name "*.png" -exec convert "{}" -alpha off "{}" \;
- xcodebuild -workspace platforms/ios/AirGap\ Vault.xcworkspace -scheme "AirGap Vault" -destination generic/platform=iOS build -allowProvisioningUpdates
- xcodebuild -workspace platforms/ios/AirGap\ Vault.xcworkspace -scheme "AirGap Vault" -sdk iphoneos -configuration AppStoreDistribution archive -archivePath platforms/ios/AirGap\ Vault.xcarchive
- xcodebuild -exportArchive -archivePath platforms/ios/AirGap\ Vault.xcarchive -exportOptionsPlist exportOptions.plist -exportPath platforms/ios/ -allowProvisioningUpdates
- /Applications/Xcode_9.4.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool --upload-app -f platforms/ios/AirGap\ Vault.ipa -u $IOS_USERNAME -p $IOS_PASSWORD
artifacts:
paths:
- AirGap\ Vault.ipa
tags:
- ios
qa:
stage: qa
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker create --name qa-$CI_PIPELINE_ID $IMAGE_TAG_CURRENT 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 -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
- 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