From acf018b19b202abedb082020a121cf368b6fb877 Mon Sep 17 00:00:00 2001
From: Martin/Geno <geno+dev@fireorbit.de>
Date: Mon, 12 Aug 2019 14:05:57 +0200
Subject: [PATCH] .gitlab-ci.yml: Update nightly F-Droid repo at
 https://git.card10.badge.events.ccc.de/card10/companion-app-android-nightly/raw/master/fdroid/repo

---
 .gitlab-ci.yml | 22 +++++++++++++++++++++-
 README.md      |  4 ++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 10c18f7..58d6a1b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: openjdk:8-jdk
+image: registry.gitlab.com/fdroid/ci-images-client:latest
 
 variables:
   ANDROID_SDK_TOOLS:   "4333796"
@@ -26,8 +26,28 @@ stages:
 
 assembleDebug:
   stage: build
+  except:
+  - master
   script:
     - ./gradlew assembleDebug
   artifacts:
+    expire_in: 3 days
     paths:
     - app/build/outputs/
+
+publish:
+  stage: build
+  only:
+  - master
+  script:
+  # generate new version
+  - export versionCode="$CI_JOB_ID"
+  - export versionName="$(git describe --tag --abbrev=0)-${CI_JOB_ID}_${CI_COMMIT_REF_NAME}"
+  - echo "set VersionCode '${versionCode}' and VersonName '${versionName}'"
+  - sed -i "s/^\(\s*versionCode\s*\).*$/\1$versionCode/" app/build.gradle
+  - sed -i "0,/versionName/s/^\(\s*versionName\).*/\1 \"$versionName\"/" app/build.gradle
+  - cat -n app/build.gradle
+  # build free version
+  - ./gradlew assembleDebug
+  # publish on nightly fdroid repo
+  - fdroid nightly -v
diff --git a/README.md b/README.md
index 2368df8..a0e7893 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,6 @@
 
 ## Download
 
-Latest Build binary from ci here:
+Per F-Droid nightly repository:
 
-[Debug-Binary](https://git.card10.badge.events.ccc.de/card10/companion-app-android/-/jobs/artifacts/master/raw/app/build/outputs/apk/debug/app-debug.apk?inline=false&job=assembleDebug)
+[![https://git.card10.badge.events.ccc.de/card10/companion-app-android-nightly/raw/master/fdroid/repo](https://git.card10.badge.events.ccc.de/card10/companion-app-android-nightly/raw/master/icon.png)](https://git.card10.badge.events.ccc.de/card10/companion-app-android-nightly/raw/master/fdroid/repo)
-- 
GitLab