-
Notifications
You must be signed in to change notification settings - Fork 16
/
.gitlab-ci.yml
166 lines (154 loc) · 6.64 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
image: $CI_REGISTRY_IMAGE
variables:
LC_ALL: "en_US.UTF-8"
LANG: "en_US.UTF-8"
GIT_STRATEGY: clone
CHANGE_LOG_PATH: "${CI_PROJECT_DIR}/fastlane/metadata/android/en-US/changelogs/"
SIGN_KEY_NAME: "release.jks"
SIGN_KEY_PATH: "${CI_PROJECT_DIR}/${SIGN_KEY_NAME}"
GCM_KEY_PATH: "${CI_PROJECT_DIR}/gcm_key.json"
BUILD_PROPERTIES_PATH: "${CI_PROJECT_DIR}/config/build.properties"
SIGN_PROPERTIES_PATH: "${CI_PROJECT_DIR}/config/sign.properties"
MOBILE_APK_PATH: "${CI_PROJECT_DIR}/mobile/build/outputs/apk/google/release/mobile-google-release.apk"
TV_APK_PATH: "${CI_PROJECT_DIR}/tv/build/outputs/apk/google/release/tv-google-release.apk"
stages:
- Test
- Deploy
#Upload to play store
UploadToPlayStoreInternalChannel:
stage: Deploy
when: manual
extends:
- ".signUpdateBuildNumber"
script:
- echo "VERSION_CODE=$VERSION_CODE" >> build.env
- echo "VERSION_NAME=$VERSION_NAME" >> build.env
- export DIRECTORY=${VERSION_NAME}
- fastlane publishToInternal
artifacts:
reports:
dotenv: build.env
#Upload binaries to nexus private channel.
UploadToNexusPrivate:
stage: Deploy
when: on_success
dependencies:
- UploadToPlayStoreInternalChannel
needs:
- UploadToPlayStoreInternalChannel
extends:
- ".signKeepBuildNumber"
script:
- echo "VERSION_CODE=$VERSION_CODE" >> build.env
- echo "VERSION_NAME=$VERSION_NAME" >> build.env
- export DIRECTORY=${VERSION_NAME}
- fastlane buildReleaseApk
- curl --retry 5 --show-error --fail -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" --cacert config/cacert.pem --upload-file ${MOBILE_APK_PATH} "${NEXUS_SERVER_PRIVATE}${DIRECTORY}/windscribe-mobile.apk"
- curl --retry 5 --show-error --fail -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" --cacert config/cacert.pem --upload-file ${TV_APK_PATH} "${NEXUS_SERVER_PRIVATE}${DIRECTORY}/windscribe-tv.apk"
#Upload binaries to nexus public channel.
UploadToNexusPublic:
stage: Deploy
extends:
- ".signKeepBuildNumber"
only:
- tags
except:
- branches
script:
- if [ "$DEV" == "true" ]; then NEXUS_SERVER=$NEXUS_SERVER_PRIVATE; fi
- echo "VERSION_CODE=$VERSION_CODE" >> build.env
- echo "VERSION_NAME=$VERSION_NAME" >> build.env
- export DIRECTORY=${VERSION_NAME}
- echo $NEXUS_SERVER
- fastlane buildReleaseApk
- curl --retry 5 --show-error --fail -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" --cacert config/cacert.pem --upload-file ${MOBILE_APK_PATH} "${NEXUS_SERVER}${DIRECTORY}/windscribe-mobile.apk"
- curl --retry 5 --show-error --fail -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" --cacert config/cacert.pem --upload-file ${TV_APK_PATH} "${NEXUS_SERVER}${DIRECTORY}/windscribe-tv.apk"
artifacts:
reports:
dotenv: build.env
# update build number.
".signUpdateBuildNumber":
stage: Deploy
before_script:
- apk -U upgrade
- apk --no-cache add curl
- apk add patch
- apk add flock
- apk --no-cache add git make musl-dev build-base cmake ninja zip unzip git perl
- apk --no-cache add go=1.21.10-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.19/community
- apk add jq
- authToken=$(curl -X POST https://pki.int.windscribe.com:8200/v1/auth/approle/login -d "role_id=$role_id&secret_id=$secret_id" | jq --raw-output '.auth.client_token')
- secretData=$(curl -H "X-Vault-Token:$authToken" -X GET https://pki.int.windscribe.com:8200/v1/kv/cicd/client-android)
- echo $secretData
- signProperties=$(echo "$secretData" | jq '.data."sign.properties"')
- echo $signProperties
- echo "$signProperties" | base64 -d -i > $SIGN_PROPERTIES_PATH
- uploadKey=$(echo "$secretData" | jq '.data.android_play_store_upload_key')
- echo "$uploadKey" | base64 -d -i > $GCM_KEY_PATH
- signKey=$(echo "$secretData" | jq '.data.android_play_store_sign_key')
- echo "$signKey" | base64 -d -i > $SIGN_KEY_PATH
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
- extras ndk -n 23.2.8568313 -c 3.22.1
- extras fastlane
- apk --no-cache add swig
- fastlane updateBuildVersion
- export VERSION_CODE=$(grep -E "versionCode" mobile/build.gradle | cut -d '"' -f2
| tr -d '"' | tr -d 'versionCode ')
- export VERSION_NAME=${MAJOR}.${MINOR}.${VERSION_CODE}
- touch ${CHANGE_LOG_PATH}${VERSION_CODE}.txt
- export ANDROID_NDK=$(ls -d $ANDROID_SDK_ROOT/ndk/*/ | head -n 1)
- tools/build_wstunnel.sh
# update build version to same as play store.
".signKeepBuildNumber":
stage: Deploy
before_script:
- apk -U upgrade
- apk --no-cache add curl
- apk add flock
- apk --no-cache add git make musl-dev build-base cmake ninja zip unzip git perl
- apk --no-cache add go=1.21.10-r0 --repository=http://dl-cdn.alpinelinux.org/alpine/v3.19/community
- apk add jq
- authToken=$(curl -X POST https://pki.int.windscribe.com:8200/v1/auth/approle/login -d "role_id=$role_id&secret_id=$secret_id" | jq --raw-output '.auth.client_token')
- secretData=$(curl -H "X-Vault-Token:$authToken" -X GET https://pki.int.windscribe.com:8200/v1/kv/cicd/client-android)
- signProperties=$(echo "$secretData" | jq '.data."sign.properties"')
- echo "$signProperties" | base64 -d -i > $SIGN_PROPERTIES_PATH
- buildProperties=$(echo "$secretData" | jq '.data."build.properties"')
- echo "$buildProperties" | base64 -d -i > $BUILD_PROPERTIES_PATH
- uploadKey=$(echo "$secretData" | jq '.data.android_play_store_upload_key')
- echo "$uploadKey" | base64 -d -i > $GCM_KEY_PATH
- signKey=$(echo "$secretData" | jq '.data.android_play_store_sign_key')
- echo "$signKey" | base64 -d -i > $SIGN_KEY_PATH
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
- extras ndk -n 23.2.8568313 -c 3.22.1
- extras fastlane
- apk --no-cache add swig
- fastlane keepBuildVersion
- export VERSION_CODE=$(grep -E "versionCode" mobile/build.gradle | cut -d '"' -f2
| tr -d '"' | tr -d 'versionCode ')
- export VERSION_NAME=${MAJOR}.${MINOR}.${VERSION_CODE}
- touch ${CHANGE_LOG_PATH}${VERSION_CODE}.txt
- export ANDROID_NDK=$(ls -d $ANDROID_SDK_ROOT/ndk/*/ | head -n 1)
- tools/build_wstunnel.sh
Slack:
stage: Deploy
when: on_success
dependencies:
- UploadToNexusPrivate
needs:
- UploadToNexusPrivate
extends:
- ".curl"
script:
- export TITLE="Available on play store Release $VERSION_NAME"
- export CHANGE_LOG=$(cat $CHANGE_LOG_PATH${VERSION_CODE}.txt)
- export SPACE=$'\n\n'
- export MESSAGE=$TITLE$SPACE$CHANGE_LOG
- export PAYLOAD={\"text\":\"$MESSAGE\"}
- curl --retry 5 -X POST $SLACK_URL --show-error --fail -d "$PAYLOAD"
".curl":
stage: Deploy
before_script:
- extras fastlane
- apk --no-cache add curl