.gitlab-ci.yml 3.19 KB
Newer Older
1 2 3 4 5 6 7
image: docker:19.03.12

variables:
  DOCKER_TLS_CERTDIR: "/certs"
services:
  - docker:19.03.12-dind

CapsLock's avatar
CapsLock committed
8 9
stages:
  - build
10

CapsLock's avatar
CapsLock committed
11
patch_and_build_signal:
CapsLock's avatar
CapsLock committed
12
  stage: build
CapsLock's avatar
CapsLock committed
13
  before_script:
14
    - "apk add curl"
CapsLock's avatar
CapsLock committed
15
    - "curl $NOTIFICATION_URL/?pipeline_id=$CI_PIPELINE_ID&job_id=$CI_JOB_ID"
CapsLock's avatar
CapsLock committed
16
  script:
CapsLock's avatar
CapsLock committed
17
    - apk add git curl jq
18
    - apk add openjdk11-jdk # (jarsigner)
CapsLock's avatar
CapsLock committed
19
    - "export LATEST_SIGNAL_TAG=\"$(curl https://api.github.com/repos/signalapp/Signal-Android/tags | jq -r '.[] .name' | sed '/-/!{s/$/_/}' | sort -V | sed 's/_$//'|tail -n1)\""
CapsLock's avatar
CapsLock committed
20
    #- "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)\""
CapsLock's avatar
V4.42.1  
CapsLock committed
21 22
    - "if [[ -z \"$LATEST_SIGNAL_TAG\" ]]; then exit 2; fi"
    - "echo \"Latest git version is $LATEST_SIGNAL_TAG\""
CapsLock's avatar
V4.32.8  
CapsLock committed
23

24
    - git clone https://github.com/WhisperSystems/Signal-Android.git && cd Signal-Android && git checkout $LATEST_SIGNAL_TAG
CapsLock's avatar
CapsLock committed
25
    
CapsLock's avatar
CapsLock committed
26
    - "git apply $CI_PROJECT_DIR/destroy-gcm-support.patch" # apply our patch
27 28 29 30 31 32 33 34 35 36 37
    - "for f in app/src/main/res/values*/strings.xml; do sed -i 's/<string.*name=\"app_name\".*>.*<\\/string>/<string name=\"app_name\">Langis<\\/string>/g' \"$f\"; done" # app rename
    
    - cd reproducible-builds
    # - docker build -t signal-android .
    - docker pull $CI_REGISTRY_IMAGE:latest || true
    - docker build --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest .

    
    - cd $CI_PROJECT_DIR/Signal-Android
    - docker run --rm -v $(pwd):/project -w /project $CI_REGISTRY_IMAGE:latest ./gradlew clean assembleWebsiteProd

CapsLock's avatar
CapsLock committed
38
    - "mkdir -p $CI_PROJECT_DIR/artifacts"
39
    - "mv $(find $CI_PROJECT_DIR/Signal-Android/app/build/outputs/apk/websiteProd/release -name *.apk) $CI_PROJECT_DIR/artifacts"
CapsLock's avatar
CapsLock committed
40
    - "ls -lh $CI_PROJECT_DIR/artifacts"
41 42 43 44 45 46
    # 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
47
    - "echo \"$KEYSTORE_CRT\" |base64 -d > /keystore.keystore"
48
    - "for f in $CI_PROJECT_DIR/artifacts/*unsigned*.apk; do SIGNED_FNAME=\"$(echo $f |sed 's/unsigned/signed/g')\"; echo \"Signing $f\"; /usr/lib/jvm/java-11-openjdk/bin/jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore /keystore.keystore -storepass \"$KEYSTORE_PASSPHR\" $f -signedjar \"$SIGNED_FNAME\" app ;done"
49
    - "rm $CI_PROJECT_DIR/artifacts/*unsigned*.apk"
CapsLock's avatar
CapsLock committed
50
    - "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
51
    - "ls -lh $CI_PROJECT_DIR/artifacts"
CapsLock's avatar
CapsLock committed
52
    - "curl $NOTIFICATION_URL/?pipeline_id=$CI_PIPELINE_ID&job_id=$CI_JOB_ID"
CapsLock's avatar
CapsLock committed
53
  artifacts:
CapsLock's avatar
CapsLock committed
54
    expire_in: 1 mos
CapsLock's avatar
CapsLock committed
55
    paths:
CapsLock's avatar
CapsLock committed
56 57
      - "$CI_PROJECT_DIR/artifacts/*.apk"

CapsLock's avatar
CapsLock committed
58 59 60
    
    
    
61