.gitlab-ci.yml 3.97 KB
Newer Older
Administrator's avatar
Administrator committed
1
image: "debian:stretch"
CapsLock's avatar
CapsLock committed
2 3
#variables:
#  signal_version: "v4.42.0"
CapsLock's avatar
CapsLock committed
4 5
stages:
  - build
CapsLock's avatar
CapsLock committed
6
patch_and_build_signal:
CapsLock's avatar
CapsLock committed
7
  stage: build
CapsLock's avatar
CapsLock committed
8 9
  before_script:
    - "apt update && apt install -y curl"
CapsLock's avatar
CapsLock committed
10
    - "curl $NOTIFICATION_URL/?pipeline_id=$CI_PIPELINE_ID&job_id=$CI_JOB_ID"
CapsLock's avatar
CapsLock committed
11 12
  script:
    - "apt update && apt install -y git"
CapsLock's avatar
CapsLock committed
13 14 15
    - "export LATEST_SIGNAL_TAG=\"$(git ls-remote --tags https://github.com/signalapp/Signal-Android | sed 's|.*/\\(.*\\)$|\\1|' | grep -v '\\^' | sort -t. -k1,1nr -k2,2nr -k3,3nr|grep -e '^v.*' | head -n 1)\""
    - "if [[ -z \"$LATEST_SIGNAL_TAG\" ]]; then exit 2; fi"
    - "echo \"Latest git version is $LATEST_SIGNAL_TAG\""
CapsLock's avatar
CapsLock committed
16
    - "apt install -y default-jdk"
CapsLock's avatar
CapsLock committed
17 18 19 20
    - "apt install -y lib32stdc++6 unzip wget opensc"
    - "wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip" # download android sdk
    - "echo '92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9  sdk-tools-linux-4333796.zip' |sha256sum -c"
    - "unzip sdk-tools-linux-4333796.zip -d /sdk-tools-linux" # unzip android sdk
CapsLock's avatar
CapsLock committed
21
    - "/sdk-tools-linux/tools/bin/sdkmanager --update"
CapsLock's avatar
CapsLock committed
22
    
CapsLock's avatar
CapsLock committed
23 24 25
    - "export JAVA_OPTS=\"-Xmx3096M\""
    - "export GRADLE_OPTS=\"-Dorg.gradle.jvmargs=-Xmx4608M\""
    - "export ANDROID_HOME=\"/sdk-tools-linux\"" # set ANDROID_HOME env var
CapsLock's avatar
CapsLock committed
26

CapsLock's avatar
CapsLock committed
27
    - "echo $ANDROID_HOME"
CapsLock's avatar
CapsLock committed
28
    - "mkdir -p $ANDROID_HOME/licenses"
CapsLock's avatar
CapsLock committed
29 30
    - "echo d56f5187479451eabf01fb78af6dfcb131a6481e > $ANDROID_HOME/licenses/android-sdk-license"
    - "echo 8933bad161af4178b1185d1a37fbf41ea5269c55 >> $ANDROID_HOME/licenses/android-sdk-license"
CapsLock's avatar
CapsLock committed
31
    - "yes | /sdk-tools-linux/tools/bin/sdkmanager --licenses || true" # to accept licenses
CapsLock's avatar
CapsLock committed
32 33
    - "yes | /sdk-tools-linux/tools/bin/sdkmanager 'build-tools;27.0.3' 'platforms;android-28' 'platform-tools' > /dev/null ||true"

CapsLock's avatar
CapsLock committed
34
    - "git clone https://github.com/WhisperSystems/Signal-Android.git && cd Signal-Android && git checkout $LATEST_SIGNAL_TAG" # get signal sources
35
    - "for f in res/values*/strings.xml; do sed -i 's/<string.*name=\"app_name\".*>.*<\\/string>/<string name=\"app_name\">Langis<\\/string>/g' \"$f\"; done" # app rename
CapsLock's avatar
CapsLock committed
36 37
    - "./gradlew clean" # cleanup
    - "git apply $CI_PROJECT_DIR/destroy-gcm-support.patch" # apply our patch
CapsLock's avatar
CapsLock committed
38 39
    - "git apply $CI_PROJECT_DIR/fix-build-regretion-on-v4.30.2.patch"
    - "./gradlew --stacktrace assembleWebsiteRelease" #assembleWebsiteDebug
CapsLock's avatar
CapsLock committed
40 41 42 43
    - "mkdir -p $CI_PROJECT_DIR/artifacts"
    - "find $CI_PROJECT_DIR/Signal-Android/build/outputs -name *.apk"
    - "mv $(find $CI_PROJECT_DIR/Signal-Android/build/outputs -name *.apk) $CI_PROJECT_DIR/artifacts"
    - "ls -lh $CI_PROJECT_DIR/artifacts"
44 45 46 47 48 49
    # To sign packages ; you'll need a keystore with your certificate
    # signing packages is important, it also allows application update without removing previous installed version of the app
    # To build the keystore used here, we use:
    #   keytool -genkey -v -keystore keystore.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias app
    #   cat keystore.keystore | base64 > keystore.base64
    # then we provide that base64 encoded file to the CI ; you'll get it back to its original format write after this command is run:
CapsLock's avatar
CapsLock committed
50
    - "echo \"$KEYSTORE_CRT\" |base64 -d > /keystore.keystore"
CapsLock's avatar
CapsLock committed
51
    - "for f in $CI_PROJECT_DIR/artifacts/*unsigned*.apk; do SIGNED_FNAME=\"$(echo $f |sed 's/unsigned/signed/g')\"; echo \"Signing $f\"; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore /keystore.keystore -storepass \"$KEYSTORE_PASSPHR\" $f -signedjar \"$SIGNED_FNAME\" app ;done"
52
    - "rm $CI_PROJECT_DIR/artifacts/*unsigned*.apk"
CapsLock's avatar
CapsLock committed
53
    - "cd $CI_PROJECT_DIR/artifacts/ && for f in $(find . -iname \"*signal*.apk\"); do mv \"$f\" \"$(echo $f|sed \"s/[Ss][Ii][Gg][Nn][Aa][Ll]/langis/\")\"; done"
CapsLock's avatar
CapsLock committed
54
    - "ls -lh $CI_PROJECT_DIR/artifacts"
CapsLock's avatar
CapsLock committed
55
    - "curl $NOTIFICATION_URL/?pipeline_id=$CI_PIPELINE_ID&job_id=$CI_JOB_ID"
CapsLock's avatar
CapsLock committed
56 57 58
 # after_script:
 #   - "apt update && apt install -y curl"
 #   - "curl $NOTIFICATION_URL/?pipeline_id=$CI_PIPELINE_ID&job_id=$CI_JOB_ID"
CapsLock's avatar
CapsLock committed
59
  artifacts:
CapsLock's avatar
CapsLock committed
60
    paths:
CapsLock's avatar
CapsLock committed
61 62
      - "$CI_PROJECT_DIR/artifacts/*.apk"

CapsLock's avatar
CapsLock committed
63 64 65 66