Commit cfd6ae88 authored by Aleks Kissinger's avatar Aleks Kissinger

added github AUTO deploy scripts

parent d49cde5d
language: cpp
branches:
only:
- master
- master
matrix:
include:
include:
- os: osx
compiler: clang
env:
- FILE=tikzit-osx.dmg
- QTVER=511
- DEPLOY_TIKZIT=1
# - os: osx
# compiler: clang
# env:
# - FILE=tikzit-osx-mountain.dmg
# - QTVER=56
# - DEPLOY_TIKZIT=1
before_install:
# - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 56 ]] || curl https://raw.githubusercontent.com/GiovanniBussi/macports-ci/master/macports-ci > macports-ci'
# - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 56 ]] || source macports-ci install'
- FILE=tikzit-osx.dmg
- QTVER=511
- DEPLOY_TIKZIT=1
before_install:
install:
- '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 511 ]] || brew update'
- '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 511 ]] || brew install qt5'
- '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 511 ]] || brew link --force qt5'
- '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 511 ]] || brew install poppler --with-qt'
# - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 56 ]] || sudo port -N -k install qt56'
# - '[[ "$TRAVIS_OS_NAME" != osx || "$QTVER" != 56 ]] || export PATH=/opt/local/libexec/qt5/bin:$PATH'
- brew update
- brew install qt5
- brew link --force qt5
- brew install poppler --with-qt
script:
- qmake -v
- qmake -r
- make
- '[[ "$TRAVIS_OS_NAME" != osx ]] || (chmod +x deploy-osx.sh && ./deploy-osx.sh && mv tikzit.dmg $FILE)'
- '[[ "$DEPLOY_TIKZIT" != 1 ]] || curl --upload-file $FILE https://transfer.sh/$FILE'
- qmake -v
- qmake -r
- make
- '(chmod +x deploy-osx.sh && ./deploy-osx.sh && mv tikzit.dmg $FILE)'
- python scripts/gh-push.py $FILE
notifications:
email: false
from gh import gh, pr
import os
tok = os.getenv('GITHUB_TOKEN')
draft = [r for r in gh('releases')
if r['draft'] and r['name'] == 'AUTO'][0]
for a in draft['assets']:
print(a['browser_download_url'] +
'?access_token=' + tok)
import sys, re
from gh import gh, get_release
if len(sys.argv) != 2:
print("Usage: python gh-push.py FILENAME")
sys.exit(1)
f = sys.argv[1]
print('Pulling info on release AUTO.')
draft = get_release('AUTO')
existing = [a for a in draft['assets'] if a['name'] == f]
if (len(existing) > 0):
print('Asset exists, deleting.')
gh('releases/assets/' + str(existing[0]['id']),
['-X', 'DELETE'])
print('Uploading new asset...')
upload_url = re.sub(
'\\{.*\\}', '?name=' + f,
draft['upload_url'])
resp = gh(upload_url, [
'-H', 'Content-type: application/octet-stream',
'--data-binary', f
])
print('Done.')
import sys, os, json
from subprocess import Popen, PIPE
api_url = 'https://api.github.com/repos/tikzit/tikzit'
tok = os.getenv('GITHUB_TOKEN', '')
if tok == '':
print("Must set GITHUB_TOKEN environment variable.")
sys.exit(1)
# pretty-print JSON responses
def pr(j): print(json.dumps(j, indent=2))
# call GitHub API with curl
def gh(s, args=[]):
cmd = (["curl", "-s"] + args +
["-H", "Authorization: token " + tok] +
[s if 'https://' in s else api_url + '/' + s])
# ONLY UN-COMMENT FOR TESTING:
# print(' '.join(cmd))
p = Popen(cmd, stdout=PIPE)
resp = p.stdout.read()
return json.loads(resp if resp else '{}')
def get_release(n):
rs = [r for r in gh('releases') if r['name'] == n]
if len(rs) > 0: return rs[0]
else: return None
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment