Skip to content

Commit

Permalink
Use pull request id or tag for upload
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 23, 2018
1 parent 54ca79e commit 64fd9d4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 109 deletions.
8 changes: 4 additions & 4 deletions scripts/basic_upload_apks_service_account.py
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Copyright 2014 Marta Rodriguez.
#
Expand All @@ -18,7 +18,7 @@

import argparse

from apiclient.discovery import build
from googleapiclient.discovery import build
import httplib2
from oauth2client.service_account import ServiceAccountCredentials
from oauth2client import client
Expand All @@ -40,7 +40,7 @@
def main():
# Load the key in PKCS 12 format that you downloaded from the Google APIs
# Console when you created your Service account.
with open('play_developer.p12', 'rb') as f:
with open('.ci/play_developer.p12', 'rb') as f:
key = f.read()

# Create an httplib2.Http object to handle our HTTP requests and authorize it
Expand All @@ -49,7 +49,7 @@ def main():
# address associated with the key that was created.
credentials = ServiceAccountCredentials.from_p12_keyfile(
SERVICE_ACCOUNT_EMAIL,
'../.ci/play_developer.p12',
'.ci/play_developer.p12',
scopes='https://www.googleapis.com/auth/androidpublisher')
http = httplib2.Http()
http = credentials.authorize(http)
Expand Down
22 changes: 14 additions & 8 deletions scripts/deploy.sh
@@ -1,23 +1,29 @@
#!/bin/bash

set -e

source scripts/travis_env.sh

if [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ];
then
if [ "${TRAVIS_PULL_REQUEST}" != "false" ];
then
echo -e "\e[31mDeploying app to pull request\e[0m"
curl -u m-kuhn:${GITHUB_API_TOKEN} -X POST --data '{"body": "Uploaded test apks for [armv7](https://opengis.ch/download/qfield/ci-builds/qfield-dev-'${TRAVIS_PULL_REQUEST}'-'${TRAVIS_COMMIT}'-armv7.apk) and [x86](https://opengis.ch/download/qfield/ci-builds/qfield-dev-'${TRAVIS_PULL_REQUEST}'-'${TRAVIS_COMMIT}'-x86.apk)"}' https://api.github.com/repos/opengisch/QField/issues/${TRAVIS_PULL_REQUEST}/comments
curl -u m-kuhn:${GITHUB_API_TOKEN} -X POST --data '{"body": "Uploaded test apks for [armv7](https://opengis.ch/download/qfield/ci-builds/qfield-dev-'${UPLOAD_ARTIFACT_ID}'-'${TRAVIS_COMMIT}'-armv7.apk) and [x86](https://opengis.ch/download/qfield/ci-builds/qfield-dev-'${UPLOAD_ARTIFACT_ID}'-'${TRAVIS_COMMIT}'-x86.apk)"}' https://api.github.com/repos/opengisch/QField/issues/${TRAVIS_PULL_REQUEST}/comments
fi

if [ "${TRAVIS_TAG}X" != "X" ];
then
echo -e "\e[31mDeploying app to releases\e[0m"
echo -e "\e[31mStarting to deploy a new release\e[0m"
openssl aes-256-cbc -K $encrypted_play_upload_key -iv $encrypted_play_upload_iv -in .ci/play_developer.p12.enc -out .ci/play_developer.p12 -d
wget -o /tmp/qfield-${TRAVIS_TAG}-armv7.apk https://opengis.ch/download/qfield/ci-builds/qfield-dev-'${TRAVIS_PULL_REQUEST}'-'${TRAVIS_COMMIT}'-armv7.apk
wget -o /tmp/qfield-${TRAVIS_TAG}-x86.apk https://opengis.ch/download/qfield/ci-builds/qfield-dev-'${TRAVIS_PULL_REQUEST}'-'${TRAVIS_COMMIT}'-x86.apk
./basic_upload_apks_service_account.py ch.opengis.qfield /tmp/qfield-${TRAVIS_TAG}-armv7.apk
./basic_upload_apks_service_account.py ch.opengis.qfield /tmp/qfield-${TRAVIS_TAG}-x86.apk
./release-upload.py --release=${TRAVIS_TAG} --oauth-token=${GITHUB_API_TOKEN} /tmp/qfield-${TRAVIS_TAG}-armv7.apk /tmp/qfield-${TRAVIS_TAG}-x86.apk
echo -e "\e[31m * Collecting apks to upload...\e[0m"
wget -O /tmp/qfield-${TRAVIS_TAG}-armv7.apk https://opengis.ch/download/qfield/ci-builds/qfield-dev-${UPLOAD_ARTIFACT_ID}-${TRAVIS_COMMIT}-armv7.apk
wget -O /tmp/qfield-${TRAVIS_TAG}-x86.apk https://opengis.ch/download/qfield/ci-builds/qfield-dev-${UPLOAD_ARTIFACT_ID}-${TRAVIS_COMMIT}-x86.apk

echo -e "\e[31m * Deploying app to google play...\e[0m"
./scripts/basic_upload_apks_service_account.py ch.opengis.qfield /tmp/qfield-${TRAVIS_TAG}-armv7.apk
./scripts/basic_upload_apks_service_account.py ch.opengis.qfield /tmp/qfield-${TRAVIS_TAG}-x86.apk

echo -e "\e[31m * Deploying app to github release...\e[0m"
./scripts/release-upload.py --release=${TRAVIS_TAG} --oauth-token=${GITHUB_API_TOKEN} /tmp/qfield-${TRAVIS_TAG}-armv7.apk /tmp/qfield-${TRAVIS_TAG}-x86.apk
fi
fi
3 changes: 3 additions & 0 deletions scripts/travis_env.sh
@@ -0,0 +1,3 @@
#!/bin/bash

export UPLOAD_ARTIFACT_ID=$( [[ ${TRAVIS_PULL_REQUEST} =~ false ]] && echo ${TRAVIS_TAG} || echo ${TRAVIS_PULL_REQUEST} )
9 changes: 5 additions & 4 deletions scripts/upload-artifacts.sh
@@ -1,16 +1,17 @@
#!/bin/bash

set -e

source scripts/travis_env.sh

# If we have secure env vars and are in either a pull request or a tag, we need to upload artifacts
if [[ "${TRAVIS_SECURE_ENV_VARS}" = "true" && ( "${TRAVIS_PULL_REQUEST}" != "false" || "${TRAVIS_TAG}" ) ]];
then
echo -e "\e[31mAbout to upload build artifacts\e[0m"
sudo mv build-${ARCH}/out/build/outputs/apk/out-release-signed.apk /tmp/qfield-dev-${TRAVIS_PULL_REQUEST}-${TRAVIS_COMMIT}-${ARCH}.apk
sudo mv build-${ARCH}/out/build/outputs/apk/out-release-signed.apk /tmp/qfield-dev-${UPLOAD_ARTIFACT_ID}-${TRAVIS_COMMIT}-${ARCH}.apk
openssl aes-256-cbc -K $encrypted_dev_upload_key -iv $encrypted_dev_upload_iv -in .ci/id_rsa.enc -out .ci/id_rsa -d
chmod 400 .ci/id_rsa
scp -i .ci/id_rsa -o "StrictHostKeyChecking no" /tmp/qfield-dev-${TRAVIS_PULL_REQUEST}-${TRAVIS_COMMIT}-${ARCH}.apk ${DEV_UPLOAD_USER}@${DEV_UPLOAD_HOST}:~/ci-builds/
echo -e "\e[31Uploaded to https://opengis.ch/download/qfield/ci-builds/qfield-dev-${TRAVIS_PULL_REQUEST}-${TRAVIS_COMMIT}-${ARCH}.apk \e[0m"
scp -i .ci/id_rsa -o "StrictHostKeyChecking no" /tmp/qfield-dev-${UPLOAD_ARTIFACT_ID}-${TRAVIS_COMMIT}-${ARCH}.apk ${DEV_UPLOAD_USER}@${DEV_UPLOAD_HOST}:~/ci-builds/
echo -e "\e[31Uploaded to https://opengis.ch/download/qfield/ci-builds/qfield-dev-${UPLOAD_ARTIFACT_ID}-${TRAVIS_COMMIT}-${ARCH}.apk \e[0m"
else
echo -e "Not uploading artifacts ..."
if [ "${TRAVIS_SECURE_ENV_VARS}" != "true" ];
Expand Down
93 changes: 0 additions & 93 deletions scripts/upload_apk.py

This file was deleted.

0 comments on commit 64fd9d4

Please sign in to comment.