72 lines
2.5 KiB
YAML
72 lines
2.5 KiB
YAML
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: Android
|
|
|
|
steps:
|
|
- name: prepare signing
|
|
image: busybox
|
|
environment:
|
|
STOREPASSWORD:
|
|
from_secret: StorePassword
|
|
KEYPASSWORD:
|
|
from_secret: KeyPassword
|
|
commands:
|
|
- touch keystore.properties
|
|
- echo "storePassword=$STOREPASSWORD" >> keystore.properties
|
|
- echo "keyPassword=$KEYPASSWORD" >> keystore.properties
|
|
- echo "keyAlias=key0" >> keystore.properties
|
|
- echo "storeFile=../AndroidKey" >> keystore.properties
|
|
|
|
- name: generate versionCode
|
|
image: busybox
|
|
commands:
|
|
- touch version.properties
|
|
- let timestamp=$(date +%s)/10
|
|
- echo "versionCode=$timestamp" >> version.properties
|
|
|
|
- name: build
|
|
image: mingc/android-build-box
|
|
commands:
|
|
- ./gradlew test
|
|
- ./gradlew assembleRelease
|
|
- ./gradlew bundleRelease
|
|
|
|
- name: deploy latest build
|
|
image: curlimages/curl
|
|
environment:
|
|
SEAFILE_API_KEY:
|
|
from_secret: SeafileApiKey
|
|
commands:
|
|
- APK_FILE="app/build/outputs/apk/release/app-release.apk"
|
|
- BUNDLE_FILE="app/build/outputs/bundle/release/app-release.aab"
|
|
- 'UPLOADLINK=$(curl -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/daffda8b-5840-4a65-b6d0-73b991facfb6/upload-link/ | tr -d '"')'
|
|
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$APK_FILE -F parent_dir=/ -F relative_path=latest/ -F replace=1 $UPLOADLINK'
|
|
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$BUNDLE_FILE -F parent_dir=/ -F relative_path=latest/ -F replace=1 $UPLOADLINK'
|
|
|
|
- name: deploy tagged build
|
|
image: curlimages/curl
|
|
environment:
|
|
SEAFILE_API_KEY:
|
|
from_secret: SeafileApiKey
|
|
commands:
|
|
- APK_FILE="app/build/outputs/apk/release/app-release$DRONE_TAG.apk"
|
|
- BUNDLE_FILE="app/build/outputs/bundle/release/app-release$DRONE_TAG.aab"
|
|
- mv app/build/outputs/apk/release/app-release.apk $APK_FILE
|
|
- mv app/build/outputs/bundle/release/app-release.aab $BUNDLE_FILE
|
|
- 'UPLOADLINK=$(curl -H "Authorization: Token $SEAFILE_API_KEY" https://seafile.zobrist.me/api2/repos/daffda8b-5840-4a65-b6d0-73b991facfb6/upload-link/ | tr -d '"')'
|
|
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$APK_FILE -F parent_dir=/ -F relative_path=tagged/$DRONE_TAG/ -F replace=1 $UPLOADLINK'
|
|
- 'curl -H "Authorization: Token $SEAFILE_API_KEY" -F file=@$BUNDLE_FILE -F parent_dir=/ -F relative_path=tagged/$DRONE_TAG/ -F replace=1 $UPLOADLINK'
|
|
when:
|
|
event:
|
|
- tag
|
|
|
|
- name: slack notification
|
|
image: plugins/slack
|
|
settings:
|
|
webhook:
|
|
from_secret: SlackWebhook
|
|
when:
|
|
status:
|
|
- failure
|
|
- success |