updated build script
This commit is contained in:
parent
6c5cbad9bb
commit
6f7cd002a5
14
.travis.yml
14
.travis.yml
|
@ -34,8 +34,8 @@ env:
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- python2.7
|
- tar
|
||||||
- libmagic1
|
- gzip
|
||||||
- patch
|
- patch
|
||||||
|
|
||||||
#cache:
|
#cache:
|
||||||
|
@ -53,3 +53,13 @@ before_script:
|
||||||
- patch --dry-run -d twidere < twidere/patches/remove_closed_source_dependencies.patch
|
- patch --dry-run -d twidere < twidere/patches/remove_closed_source_dependencies.patch
|
||||||
|
|
||||||
script: ./gradlew build --no-daemon --stacktrace
|
script: ./gradlew build --no-daemon --stacktrace
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
provider: releases
|
||||||
|
api_key:
|
||||||
|
secure: WKtKwda3hegqO9QVujdonNoL2ESJUR80WHNq/13wDsbCABo/GNnuqHNYZmml3wAifEKKeCEYfNZRUuHQ8eHs54Lj5BlGRX5i+1LrGhhgnVFQgmrhIv4RJuVQ663kDEh+Jwo4vowJ2mxNDvLvOhfZwxjULPDiknqy6u5PyW3id5M=
|
||||||
|
file_glob: true
|
||||||
|
file: '**/*-release.apk'
|
||||||
|
on:
|
||||||
|
repo: TwidereProject/Twidere-Android
|
||||||
|
tags: true
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [ -n ${PRIVATE_BUILD_CONFIG} ]; then
|
|
||||||
echo ${PRIVATE_BUILD_CONFIG} | base64 -d | tar zxf -
|
|
||||||
echo 'Extracted signing config'
|
|
||||||
fi
|
|
|
@ -1,42 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
project_dir=`pwd`
|
|
||||||
local_opt_dir="${HOME}/.local/opt"
|
|
||||||
|
|
||||||
ndk_name="android-ndk-r10e"
|
|
||||||
ndk_install_dest="${local_opt_dir}/${ndk_name}"
|
|
||||||
|
|
||||||
echo "Adding NDK install path to ${project_dir}"
|
|
||||||
echo "ndk.dir=${ndk_install_dest}" >> ${project_dir}/local.properties
|
|
||||||
|
|
||||||
if [ -d ${ndk_install_dest} ]; then
|
|
||||||
echo "NDK already installed in ${ndk_install_dest}"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d ${local_opt_dir} ]; then
|
|
||||||
mkdir -p ${local_opt_dir}
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ${local_opt_dir}
|
|
||||||
|
|
||||||
if [ `uname -m` = x86_64 ];
|
|
||||||
then
|
|
||||||
ndk_installer_name="${ndk_name}-linux-x86_64.bin"
|
|
||||||
else
|
|
||||||
ndk_installer_name="${ndk_name}-linux-x86.bin"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Downloading NDK installer ${ndk_installer_name}"
|
|
||||||
|
|
||||||
wget "http://dl.google.com/android/ndk/${ndk_installer_name}"
|
|
||||||
|
|
||||||
chmod +x ${ndk_installer_name}
|
|
||||||
|
|
||||||
echo "Installing NDK installer ${ndk_installer_name}"
|
|
||||||
|
|
||||||
./${ndk_installer_name} -y 1>/dev/null
|
|
||||||
|
|
||||||
echo "Removing installed NDK installer ${ndk_installer_name}"
|
|
||||||
|
|
||||||
rm ${ndk_installer_name}
|
|
|
@ -1,137 +0,0 @@
|
||||||
#!/usr/bin/env python2
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import urllib2
|
|
||||||
import json
|
|
||||||
import fnmatch
|
|
||||||
import magic
|
|
||||||
import uritemplate
|
|
||||||
import string
|
|
||||||
from os import getenv
|
|
||||||
from subprocess import check_output
|
|
||||||
from subprocess import CalledProcessError
|
|
||||||
from urllib2 import HTTPError
|
|
||||||
|
|
||||||
__author__ = 'mariotaku'
|
|
||||||
git_https_url_prefix = 'https://github.com/'
|
|
||||||
git_ssh_url_prefix = 'git@github.com:'
|
|
||||||
git_git_url_prefix = 'git://github.com/'
|
|
||||||
git_file_suffix = '.git'
|
|
||||||
github_header_accept = 'application/vnd.github.v3+json'
|
|
||||||
github_header_user_agent = 'TravisUploader/0.1'
|
|
||||||
|
|
||||||
DEVNULL = open(os.devnull, 'w')
|
|
||||||
repo_url = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
repo_url = check_output(['git', 'config', '--get', 'remote.origin.url']).splitlines()[0]
|
|
||||||
except CalledProcessError:
|
|
||||||
print('No remote url for this project, abort')
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
user_repo_name = None
|
|
||||||
if repo_url.startswith(git_ssh_url_prefix):
|
|
||||||
user_repo_name = repo_url[len(git_ssh_url_prefix):]
|
|
||||||
elif repo_url.startswith(git_https_url_prefix):
|
|
||||||
user_repo_name = repo_url[len(git_https_url_prefix):]
|
|
||||||
elif repo_url.startswith(git_git_url_prefix):
|
|
||||||
user_repo_name = repo_url[len(git_git_url_prefix):]
|
|
||||||
|
|
||||||
if not user_repo_name:
|
|
||||||
print('Not a github repo (%s), abort' % repo_url, file=sys.stderr)
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
if user_repo_name.endswith(git_file_suffix):
|
|
||||||
user_repo_name = user_repo_name[:-len(git_file_suffix)]
|
|
||||||
|
|
||||||
github_user_name = string.split(user_repo_name, '/')[0]
|
|
||||||
github_repo_name = string.split(user_repo_name, '/')[1]
|
|
||||||
|
|
||||||
current_tag = None
|
|
||||||
current_tag_body = None
|
|
||||||
try:
|
|
||||||
current_tag = check_output(['git', 'describe', '--tags', '--exact-match', '--abbrev=0'],
|
|
||||||
stderr=DEVNULL).splitlines()[0]
|
|
||||||
except CalledProcessError:
|
|
||||||
print('This commit doesn\'t have tag, abort', file=sys.stderr)
|
|
||||||
exit(0)
|
|
||||||
try:
|
|
||||||
current_tag_body = '\n'.join(
|
|
||||||
check_output(['git', 'show', '-s', '--format=%b', current_tag], stderr=DEVNULL).splitlines()[2:])
|
|
||||||
except CalledProcessError:
|
|
||||||
current_tag_body = "Automatic upload for version %s" % current_tag
|
|
||||||
|
|
||||||
github_access_token = getenv('GITHUB_ACCESS_TOKEN')
|
|
||||||
|
|
||||||
if not github_access_token:
|
|
||||||
print('No access token given, abort', file=sys.stderr)
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
github_authorization_header = "token %s" % github_access_token
|
|
||||||
|
|
||||||
req_headers = {'Accept': github_header_accept}
|
|
||||||
|
|
||||||
request = urllib2.Request(
|
|
||||||
uritemplate.expand('https://api.github.com/repos/{user}/{repo}/releases/tags/{tag}',
|
|
||||||
{'user': github_user_name, 'repo': github_repo_name, 'tag': current_tag}),
|
|
||||||
headers={
|
|
||||||
'Accept': github_header_accept,
|
|
||||||
'Authorization': github_authorization_header,
|
|
||||||
'User-Agent': github_header_user_agent
|
|
||||||
})
|
|
||||||
response = None
|
|
||||||
try:
|
|
||||||
response = urllib2.urlopen(request)
|
|
||||||
except HTTPError, err:
|
|
||||||
if err.code == 404:
|
|
||||||
print('Creating release for tag %s' % current_tag)
|
|
||||||
request = urllib2.Request(
|
|
||||||
uritemplate.expand('https://api.github.com/repos/{user}/{repo}/releases',
|
|
||||||
{'user': github_user_name, 'repo': github_repo_name}),
|
|
||||||
data=json.dumps({
|
|
||||||
'tag_name': current_tag,
|
|
||||||
'name': "Version %s" % current_tag,
|
|
||||||
'body': current_tag_body
|
|
||||||
}),
|
|
||||||
headers={
|
|
||||||
'Accept': github_header_accept,
|
|
||||||
'Authorization': github_authorization_header,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'User-Agent': github_header_user_agent
|
|
||||||
})
|
|
||||||
try:
|
|
||||||
response = urllib2.urlopen(request)
|
|
||||||
except HTTPError:
|
|
||||||
print('Unable to create release, abort', file=sys.stderr)
|
|
||||||
exit(0)
|
|
||||||
else:
|
|
||||||
response = None
|
|
||||||
|
|
||||||
if not response:
|
|
||||||
print('Unable to get release, abort', file=sys.stderr)
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
response_values = json.loads(response.read())
|
|
||||||
|
|
||||||
for root, dirnames, filenames in os.walk(os.getcwd()):
|
|
||||||
for filename in fnmatch.filter(filenames, '*-release.apk'):
|
|
||||||
file_path = os.path.join(root, filename)
|
|
||||||
request = urllib2.Request(
|
|
||||||
uritemplate.expand(response_values['upload_url'], {'name': filename}),
|
|
||||||
data=open(file_path, 'rb'),
|
|
||||||
headers={
|
|
||||||
'Accept': github_header_accept,
|
|
||||||
'Authorization': github_authorization_header,
|
|
||||||
'Content-Type': magic.from_file(file_path, mime=True),
|
|
||||||
'Content-Length': os.path.getsize(file_path),
|
|
||||||
'User-Agent': github_header_user_agent
|
|
||||||
})
|
|
||||||
print("Uploading %s ..." % filename),
|
|
||||||
try:
|
|
||||||
response = urllib2.urlopen(request)
|
|
||||||
print("OK")
|
|
||||||
except HTTPError, err:
|
|
||||||
print("Error %d" % err.code)
|
|
Loading…
Reference in New Issue