mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-17 04:00:48 +01:00
trying to fix ci release upload
removed future date checking
This commit is contained in:
parent
0bff453c4b
commit
ebf8b64851
@ -34,6 +34,12 @@ addons:
|
|||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- python2.7
|
- python2.7
|
||||||
|
- libmagic1
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- export PATH=$HOME/.local/bin:$PATH
|
||||||
|
- pip install -r ./scripts/requirements.txt --user
|
||||||
|
|
||||||
|
|
||||||
script: ./gradlew build --no-daemon
|
script: ./gradlew build --no-daemon
|
||||||
|
|
||||||
|
2
scripts/requirements.txt
Normal file
2
scripts/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
uritemplate
|
||||||
|
python-magic
|
@ -4,15 +4,16 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import httplib
|
import urllib2
|
||||||
import urllib
|
|
||||||
import urlparse
|
|
||||||
import json
|
import json
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import re
|
import magic
|
||||||
|
import uritemplate
|
||||||
|
import string
|
||||||
from os import getenv
|
from os import getenv
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
|
from urllib2 import HTTPError
|
||||||
|
|
||||||
__author__ = 'mariotaku'
|
__author__ = 'mariotaku'
|
||||||
git_https_url_prefix = 'https://github.com/'
|
git_https_url_prefix = 'https://github.com/'
|
||||||
@ -46,6 +47,9 @@ if not user_repo_name:
|
|||||||
if user_repo_name.endswith(git_file_suffix):
|
if user_repo_name.endswith(git_file_suffix):
|
||||||
user_repo_name = user_repo_name[:-len(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 = None
|
||||||
current_tag_body = None
|
current_tag_body = None
|
||||||
try:
|
try:
|
||||||
@ -68,54 +72,67 @@ if not github_access_token:
|
|||||||
|
|
||||||
github_authorization_header = "token %s" % github_access_token
|
github_authorization_header = "token %s" % github_access_token
|
||||||
|
|
||||||
print('Creating release for tag %s' % current_tag)
|
|
||||||
|
|
||||||
req_headers = {'Accept': github_header_accept}
|
req_headers = {'Accept': github_header_accept}
|
||||||
|
|
||||||
conn = httplib.HTTPSConnection('api.github.com')
|
request = urllib2.Request(
|
||||||
conn.request('POST', '/repos/%s/releases' % user_repo_name,
|
uritemplate.expand('https://api.github.com/repos/{user}/{repo}/releases/tags/{tag}',
|
||||||
body=json.dumps({
|
{'user': github_user_name, 'repo': github_repo_name, 'tag': current_tag}),
|
||||||
'tag_name': current_tag,
|
headers={
|
||||||
'name': "Version %s" % current_tag,
|
'Accept': github_header_accept,
|
||||||
'body': current_tag_body
|
'Authorization': github_authorization_header,
|
||||||
}),
|
'User-Agent': github_header_user_agent
|
||||||
headers={
|
})
|
||||||
'Accept': github_header_accept,
|
response = None
|
||||||
'Authorization': github_authorization_header,
|
try:
|
||||||
'Content-Type': 'application/json',
|
response = urllib2.urlopen(request)
|
||||||
'User-Agent': github_header_user_agent
|
except HTTPError, err:
|
||||||
})
|
print(err.code)
|
||||||
response = conn.getresponse()
|
if err.code == 404:
|
||||||
if response.status == 422:
|
print('Creating release for tag %s' % current_tag)
|
||||||
conn = httplib.HTTPSConnection('api.github.com')
|
request = urllib2.Request(
|
||||||
conn.request('GET', '/repos/%s/releases/tags/%s' % (user_repo_name, current_tag),
|
uritemplate.expand('https://api.github.com/repos/{user}/{repo}/releases',
|
||||||
headers={
|
{'user': github_user_name, 'repo': github_repo_name}),
|
||||||
'Accept': github_header_accept,
|
data=json.dumps({
|
||||||
'Authorization': github_authorization_header,
|
'tag_name': current_tag,
|
||||||
'User-Agent': github_header_user_agent
|
'name': "Version %s" % current_tag,
|
||||||
})
|
'body': current_tag_body
|
||||||
response = conn.getresponse()
|
}),
|
||||||
|
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 response.status not in range(200, 204):
|
if not response:
|
||||||
print('Unable to create or get release, abort', file=sys.stderr)
|
print('Unable to get release, abort', file=sys.stderr)
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
response_values = json.loads(response.read())
|
response_values = json.loads(response.read())
|
||||||
|
|
||||||
upload_url = urlparse.urlparse(re.sub('\{\?([\w\d_\-]+)\}', '', response_values['upload_url']))
|
|
||||||
for root, dirnames, filenames in os.walk(os.getcwd()):
|
for root, dirnames, filenames in os.walk(os.getcwd()):
|
||||||
for filename in fnmatch.filter(filenames, '*-release.apk'):
|
for filename in fnmatch.filter(filenames, '*-release.apk'):
|
||||||
conn = httplib.HTTPSConnection(upload_url.hostname)
|
file_path = os.path.join(root, filename)
|
||||||
conn.request('POST', "%s?%s" % (upload_url.path, urllib.urlencode({'name': filename})),
|
request = urllib2.Request(
|
||||||
body=open(os.path.join(root, filename), 'r'),
|
uritemplate.expand(response_values['upload_url'], {'name': filename}),
|
||||||
headers={
|
data=open(file_path, 'rb'),
|
||||||
'Accept': github_header_accept,
|
headers={
|
||||||
'Authorization': github_authorization_header,
|
'Accept': github_header_accept,
|
||||||
'Content-Type': 'application/json',
|
'Authorization': github_authorization_header,
|
||||||
'User-Agent': github_header_user_agent
|
'Content-Type': magic.from_file(file_path, mime=True),
|
||||||
})
|
'Content-Length': os.path.getsize(file_path),
|
||||||
response = conn.getresponse()
|
'User-Agent': github_header_user_agent
|
||||||
if response.status in range(200, 204):
|
})
|
||||||
print("Upload %s success" % filename)
|
print("Uploading %s ..." % filename),
|
||||||
else:
|
try:
|
||||||
print("Upload %s returned %d" % (filename, response.status), file=sys.stderr)
|
response = urllib2.urlopen(request)
|
||||||
|
print("OK")
|
||||||
|
except HTTPError, err:
|
||||||
|
print("Error %d" % err.code)
|
||||||
|
@ -70,7 +70,6 @@ public class TwitterDateConverter extends StringBasedTypeConverter<Date> {
|
|||||||
if (date != null) return date;
|
if (date != null) return date;
|
||||||
try {
|
try {
|
||||||
date = mDateFormat.parse(string);
|
date = mDateFormat.parse(string);
|
||||||
checkTime(string, date);
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
AbsLogger.error("Unrecognized date: " + string, e);
|
AbsLogger.error("Unrecognized date: " + string, e);
|
||||||
return null;
|
return null;
|
||||||
@ -78,14 +77,6 @@ public class TwitterDateConverter extends StringBasedTypeConverter<Date> {
|
|||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTime(String string, Date date) {
|
|
||||||
final long currentTime = System.currentTimeMillis();
|
|
||||||
if (date.getTime() - currentTime > ONE_MINUTE) {
|
|
||||||
AbsLogger.error("Tweet date from future, raw string: " + string + ", date parsed: "
|
|
||||||
+ date + ", current time is " + currentTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Date parseTwitterDate(String string) {
|
private Date parseTwitterDate(String string) {
|
||||||
final String[] segs = StringUtils.split(string, ' ');
|
final String[] segs = StringUtils.split(string, ' ');
|
||||||
if (segs.length != 6) {
|
if (segs.length != 6) {
|
||||||
@ -114,7 +105,6 @@ public class TwitterDateConverter extends StringBasedTypeConverter<Date> {
|
|||||||
AbsLogger.error("Week mismatch " + string + " => " + date);
|
AbsLogger.error("Week mismatch " + string + " => " + date);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
checkTime(string, date);
|
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1376,6 +1376,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
final int conversationCount = getConversationCount();
|
final int conversationCount = getConversationCount();
|
||||||
if (position == getItemCount() - 1) {
|
if (position == getItemCount() - 1) {
|
||||||
|
// Space is always the last item
|
||||||
return VIEW_TYPE_SPACE;
|
return VIEW_TYPE_SPACE;
|
||||||
} else if (position < conversationCount) {
|
} else if (position < conversationCount) {
|
||||||
return mConversation != null ? VIEW_TYPE_LIST_STATUS : VIEW_TYPE_CONVERSATION_LOAD_INDICATOR;
|
return mConversation != null ? VIEW_TYPE_LIST_STATUS : VIEW_TYPE_CONVERSATION_LOAD_INDICATOR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user