Created
August 29, 2012 06:43
-
-
Save isagalaev/3507557 to your computer and use it in GitHub Desktop.
highlight.js fabfile for softwaremaniacs.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from fabric.api import env, cd, run, local, get | |
from fabric.contrib.files import sed | |
env['hosts'] = ['softwaremaniacs.org'] | |
SRC = '/home/maniac/code/highlight' | |
MEDIA = '/var/www/media/soft/highlight' | |
CACHE = '/home/maniac/app-data/hljs_cache' | |
def checkout(version): | |
with cd(SRC): | |
run('git checkout master') | |
run('git pull') | |
run('git checkout %s' % version) | |
def check_version(version): | |
node_version = version if len(version.split('.')) >= 3 else '%s.0' % version | |
with cd(SRC): | |
run('grep \'Version: %s\' README.md' % version) | |
run('grep \'Версия: %s\' README.ru.md' % version) | |
run('grep \'"version" : "%s"\' src/package.json' % node_version) | |
def publish_site(version): | |
with cd(SRC): | |
run('python tools/build.py --target browser') | |
run('cp build/highlight.pack.js %s' % MEDIA) | |
run('cp -r src/styles %s' % MEDIA) | |
run('cp src/test.html %s' % MEDIA) | |
with cd(MEDIA): | |
sed('test.html', r'\.\./build/highlight\.pack\.js', 'highlight.pack.js', backup='') | |
run('/home/maniac/sm_org/manage.py fillhljscache') | |
run('/home/maniac/sm_org/manage.py setversion highlight %s' % version) | |
run('touch /etc/uwsgi/apps-available/sm_org.ini') | |
def publish_node(): | |
with cd(SRC): | |
run('python tools/build.py --target node') | |
run('npm publish build') | |
def publish_cdn(version): | |
with cd(SRC): | |
run('python tools/build.py --target cdn :common') | |
with cd('build'): | |
zipname = 'highlight.js-%s.zip' % version | |
run('zip -r %s *' % zipname) | |
path = get(zipname, '')[0] | |
local('mv %s .' % path) | |
local('rmdir %s' % env['hosts'][0]) | |
return zipname | |
def print_memo(zipname): | |
with cd(SRC): | |
languages = run('ls -l src/languages/*.js | wc -l') | |
styles = run('ls -l src/styles/*.css | wc -l') | |
print 'TODO:' | |
if zipname: | |
print '- send %s to Yandex' % zipname | |
print '- update short description with counts: %s languages, %s styles' % (languages, styles) | |
print '- update long description from README' | |
print '- write news' | |
def publish(version): | |
checkout(version) | |
check_version(version) | |
publish_site(version) | |
zipname = publish_cdn(version) | |
publish_node() | |
print_memo(zipname) | |
def update_smorg(): | |
with cd('/var/www/media/js/highlight'): | |
run('./update.sh') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment