2018-11-24 15:56:54 +01:00
image : hatsoftwares/mastalab-ci:latest
before_script :
- export ANDROID_HOME=/opt/android-sdk-linux
- export PATH=$PATH:/opt/android-sdk-linux/platform-tools/
- chmod +x gradlew
stages :
2018-11-25 13:34:53 +01:00
- build-and-test
2018-11-25 14:27:17 +01:00
- tag
2018-12-11 22:03:23 +01:00
- toot
2018-11-24 15:56:54 +01:00
2018-11-25 14:27:17 +01:00
.no-upload : &no-upload
2018-11-25 13:34:53 +01:00
stage : build-and-test
2018-11-25 14:27:17 +01:00
retry : 2
2019-12-14 16:31:26 +01:00
2018-11-25 14:27:17 +01:00
assembleDebug :
<< : *no-upload
cache :
key : "${CI_COMMIT_TAG}"
paths :
- app/build/outputs/apk/fdroid/debug/app-fdroid-debug.apk
- app/build/outputs/apk/playstore/debug/app-playstore-debug.apk
policy : push
2018-11-24 15:56:54 +01:00
script :
- ./gradlew assembleDebug
lintDebug :
2018-11-25 14:27:17 +01:00
<< : *no-upload
2018-11-24 15:56:54 +01:00
script :
2018-11-25 13:00:45 +01:00
- ./gradlew -Pci --console=plain :app:lintFdroidDebug -PbuildDir=lint
2018-11-25 14:27:17 +01:00
except :
- tags
2018-11-24 15:56:54 +01:00
debugTests :
2018-11-25 14:27:17 +01:00
<< : *no-upload
2018-11-24 15:56:54 +01:00
script :
2018-11-25 13:00:45 +01:00
- ./gradlew -Pci --console=plain :app:testFdroidDebugUnitTest
2018-11-25 14:27:17 +01:00
except :
- tags
2019-12-14 11:50:26 +01:00
2018-11-25 14:27:17 +01:00
## PROTECTED VARIABLES TO SET IN GITLAB:
# - GITLAB_API_TOKEN: token you create on Gitlab
# - NC_REMOTE_DIR: like https://YOUR_NEXTCLOUD/remote.php/dav/files/YOUR_USER/mastalab (no trailing slash)
# - NC_SHARE_URL: share the folder in Nextcloud with public link and put your public link here (no trailing slash)
# - NC_USER: nextcloud user
# - NC_PASSWORD: nextcloud password
## Protect all tags in Gitlab repo settings (do a wildcard, ie '*')
# For now, it uses the assembleDebug builds, you'll need to create a job in build-and-test to create the apks, with only: - tags and add except: - tags to assembleDebug (like in debugTests)
# In it, put something like this to get your signature key file:
# - curl -s --output signature.jsk -u "${NC_USER}:${NC_PASSWORD}" "https://YOUR_NEXTCLOUD/remote.php/dav/files/YOUR_USER/signature.jsk"
putApkOnTags :
image : hatsoftwares/curl-jq:latest
stage : tag
retry : 2
cache :
key : "${CI_COMMIT_TAG}"
paths :
- app/build/outputs/apk/fdroid/debug/app-fdroid-debug.apk
- app/build/outputs/apk/playstore/debug/app-playstore-debug.apk
policy : pull
script :
2019-10-30 19:38:07 +01:00
- export PROJECT_API_URL="https://framagit.org/api/v4/projects/${CI_PROJECT_ID}"
2018-11-25 14:27:17 +01:00
- export DESCRIPTION_URL="${PROJECT_API_URL}/repository/tags/${CI_COMMIT_TAG}"
- export RELEASE_URL="${DESCRIPTION_URL}/release"
- export NC_UPLOAD_URL="${NC_REMOTE_DIR}/${CI_COMMIT_TAG}"
- export NC_DOWNLOAD_URL="${NC_SHARE_URL}/download?path=%2F${CI_COMMIT_TAG}%2F&files="
- 'export HEADER="Private-Token: ${GITLAB_API_TOKEN}"'
- export fdroidUrl="${NC_DOWNLOAD_URL}app-fdroid-debug.apk"
- export playstoreUrl="${NC_DOWNLOAD_URL}app-playstore-debug.apk"
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -X MKCOL "${NC_UPLOAD_URL}"'
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -T app/build/outputs/apk/fdroid/debug/app-fdroid-debug.apk "${NC_UPLOAD_URL}/app-fdroid-debug.apk"'
- 'curl -s -u "${NC_USER}:${NC_PASSWORD}" -T app/build/outputs/apk/playstore/debug/app-playstore-debug.apk "${NC_UPLOAD_URL}/app-playstore-debug.apk"'
- export description=$(curl -s --header "${HEADER}" "${DESCRIPTION_URL}" | jq .release.description | sed -e 's@"@@g')
- if [[ $description == 'null' ]]; then export METHOD="POST"; echo -e "[Get the fdroid apk](${fdroidUrl})\n\n[Get the play store apk](${playstoreUrl})" > /tmp/text; fi
- if [[ $description != 'null' ]]; then export METHOD="PUT"; echo -e "${description}\n\n[Get the fdroid apk](${fdroidUrl})\n\n[Get the play store apk](${playstoreUrl})" > /tmp/text; fi
- curl -s --request $METHOD --data-urlencode "description@/tmp/text" --header "${HEADER}" "${RELEASE_URL}"
only :
- tags
2018-12-08 10:54:27 +01:00
pouet-it :
image : hatsoftwares/pouet-it-from-ci:latest
2018-12-11 22:03:23 +01:00
stage : toot
dependencies :
- putApkOnTags
2018-12-08 10:54:27 +01:00
script :
- cd /opt/pouet-it-from-ci
2018-12-09 12:06:57 +01:00
# Make the project name first letter uppercase
2018-12-15 19:09:01 +01:00
- export NC_DOWNLOAD_URL="${NC_SHARE_URL}?path=%2F${CI_COMMIT_TAG}%2F"
2018-12-09 12:06:57 +01:00
- export project="$(tr '[:lower:]' '[:upper:]' <<< ${CI_PROJECT_NAME:0:1})${CI_PROJECT_NAME:1}"
2019-03-15 18:17:41 +01:00
- export MESSAGE=$(echo -e "I just released a new version of "'#'"${APP_NAME}!""\n${CI_PROJECT_URL}/tags/${CI_COMMIT_TAG}\nYou can download the apks on ${NC_DOWNLOAD_URL}")
2018-12-11 22:10:31 +01:00
- if [[ ! -z $HOST ]]; then carton exec ./pouet-it-from-ci.pl; fi
2018-12-08 10:54:27 +01:00
only :
2018-12-09 12:06:57 +01:00
- tags