From 1db6a3294be2ef3b616095601aca7a168a649ad5 Mon Sep 17 00:00:00 2001 From: opyale Date: Thu, 9 Jul 2020 08:55:05 +0200 Subject: [PATCH] Using GitLab CI. (#580) Using smaller image and publishing releases. Fixing things. Merge branch 'gitlab-ci' of https://codeberg.org/opyale/GitNex into gitlab-ci Removing eclint. Merge branch 'master' into gitlab-ci Only run jobs when master changed. Using GitLab CI. Co-authored-by: opyale Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/580 Reviewed-by: M M Arif --- .drone.yml | 8 +++++- .gitlab-ci.yml | 62 +++++++++++++++++++++++++++++++++++++++++++ app/build.gradle | 5 ++-- scripts/sign-build.sh | 4 +-- 4 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.drone.yml b/.drone.yml index 836a0961..1050eb81 100644 --- a/.drone.yml +++ b/.drone.yml @@ -26,6 +26,12 @@ steps: # depends_on: [ clone ] # commands: # - /opt/intellij/bin/idea.sh inspect/format ... + # + # - name: do-or-check-formatting + # image: dlsniper/docker-intellij + # depends_on: [ clone ] + # commands: + # - /opt/intellij/bin/idea.sh format -s .idea/codeStyles/Project.xml -m *.java app/src/main/java trigger: event: @@ -65,7 +71,7 @@ steps: - name: sign image: nextcloudci/android:android-49 environment: - TOKEN: + BOT_TOKEN: from_secret: BOT_TOKEN KS_PASS: from_secret: KS_PASS diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..58f0f291 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,62 @@ +stages: + - test + - build + - sign + - publish + +test: + image: nextcloudci/android:android-49 + stage: test + script: + - ./gradlew test + +build: + image: nextcloudci/android:android-49 + stage: build + only: + - master + script: + - ./gradlew build + artifacts: + paths: + - app/build/outputs/ + expire_in: 15 minutes + +sign: + image: nextcloudci/android:android-49 + stage: sign + only: + - master + variables: + OUTPUT: "signed.apk" + GITEA: "https://gitea.com" + KS_FILE: "ci_keystore.jks" + script: + - ./scripts/sign-build.sh + artifacts: + paths: + - signed.apk + expire_in: 30 minutes + +latest: + image: tutum/curl + stage: publish + only: + - master + variables: + WEBDAV_USERNAME: "GitNexBot" + PLUGIN_FILE: "signed.apk" + PLUGIN_DESTINATION: "https://cloud.swatian.com/remote.php/dav/files/GitNexBot/GitNex-Builds/latest.apk" + script: + - curl -T "$PLUGIN_FILE" -u "$WEBDAV_USERNAME":"$WEBDAV_PASSWORD" "$PLUGIN_DESTINATION" + +release: + image: tutum/curl + stage: publish + only: + - tags + variables: + WEBDAV_USERNAME: "GitNexBot" + PLUGIN_FILE: "signed.apk" + script: + - curl -T "$PLUGIN_FILE" -u "$WEBDAV_USERNAME":"$WEBDAV_PASSWORD" 'https://cloud.swatian.com/remote.php/dav/files/GitNexBot/GitNex-Builds/releases/'"$CI_COMMIT_REF_NAME"'.apk' diff --git a/app/build.gradle b/app/build.gradle index 07e191e4..c67c7c31 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { versionName "3.0.0-rc3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } - viewBinding { - enabled = true + buildFeatures { + viewBinding = true } buildTypes { release { @@ -89,5 +89,4 @@ dependencies { annotationProcessor "androidx.room:room-compiler:2.2.5" implementation "com.eightbitlab:blurview:1.6.3" implementation "io.mikael:urlbuilder:2.0.9" - } diff --git a/scripts/sign-build.sh b/scripts/sign-build.sh index 03903f31..6b4e520d 100755 --- a/scripts/sign-build.sh +++ b/scripts/sign-build.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash #make sure needed var's are here -[ -z "${TOKEN}" ] && { echo "missing TOKEN"; exit 1; } +[ -z "${BOT_TOKEN}" ] && { echo "missing BOT_TOKEN"; exit 1; } [ -z "${KS_PASS}" ] && { echo "missing KS_PASS"; exit 1; } [ -z "${KEY_PASS}" ] && { echo "missing KEY_PASS"; exit 1; } [ -z "${GITEA}" ] && { echo "missing GITEA"; exit 1; } @@ -11,6 +11,6 @@ KEYFILE=$(mktemp) -curl -X GET "${GITEA}/api/v1/repos/${KS_REPO}/contents/${KS_FILE}?token=${TOKEN}" -H "accept: application/json" | sed 's|"content":"|#|g' | cut -d '#' -f 2 | cut -d '"' -f 1 | base64 -d > ${KEYFILE} +curl -X GET "${GITEA}/api/v1/repos/${KS_REPO}/contents/${KS_FILE}?token=${BOT_TOKEN}" -H "accept: application/json" | sed 's|"content":"|#|g' | cut -d '#' -f 2 | cut -d '"' -f 1 | base64 -d > ${KEYFILE} /opt/android-sdk-linux/build-tools/*/apksigner sign -v --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias GitNexBot --ks ${KEYFILE} --out signed.apk $(find . -name "*release*.apk")