Skip to content

Commit

Permalink
Experimental Travis-Transifex integration
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Feb 13, 2017
1 parent b46ba82 commit edf6381
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 11 deletions.
19 changes: 13 additions & 6 deletions .travis.yml
@@ -1,12 +1,19 @@
osx_image: xcode8
language: objective-c
cache:
- bundler
- cocoapods
- bundler
- cocoapods
env:
global:
secure: Vyar5YYP3n5CXQWiGxxT2QGYCcZgrSECmMb0BxeaG60KrKfDuXIoj6+rL/VqSImIlaF7qiVHkhHQba8Gf9QHhktUtfK4PQLfE0DzogoFVp8IXaTVEg9wBDnHAiqdadMmY3Vt2blnIIBLiV5+lFWxuSYlX27TTlr1ieev9Z+fMC0=
install:
- "bundle install"
- "travis_wait bundle exec pod install"
- bundle install
- travis_wait bundle exec pod install
- pip install --user transifex-client
before_script:
- set -o pipefail
- set -o pipefail
script:
- xcodebuild -workspace MacDown.xcworkspace -scheme MacDown test | xcpretty
- xcodebuild -workspace MacDown.xcworkspace -scheme MacDown test | xcpretty
- xcodebuild -exportLocalizations -localizationPath Build/Localizations
after_success:
- python Tools/travis_push_transifex.py
9 changes: 4 additions & 5 deletions .tx/config
@@ -1,9 +1,8 @@
[main]
host = https://www.transifex.com
lang_map = zh_TW:zh-Hant, zh_CN:zh-Hans

[macdown.localizable]
source_file = po/myproj.pot
[macdown.macdownxliff]
file_filter = Build/Localizations/<lang>.xliff
source_lang = en
type = PO
file_filter = po/<lang>.po
trans.fi = translations/fi/LC_MESSAGES/django.po
type = XLIFF
45 changes: 45 additions & 0 deletions Tools/travis_push_transifex.py
@@ -0,0 +1,45 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function, unicode_literals
import io
import os
import sys


def write_transifex_config():
"""Used to setup Travis for Transifex push.
Requires environ "TRANSIFEX_PASSWORD".
"""
transifexrc_path = os.path.expanduser('~/.transifexrc')
if os.path.exists(transifexrc_path):
return
with io.open(transifexrc_path, 'w', encoding='utf-8') as f:
f.write((
'[https://www.transifex.com]\n'
'hostname = https://www.transifex.com\n'
'password = {password}\n'
'token = \n'
'username = macdown\n'
).format(password=os.environ['TRANSIFEX_PASSWORD']))


def main():
if os.getenv('TRAVIS_PULL_REQUEST') != 'false':
print('Build triggered by a pull request. Transifex push skipped.',
file=sys.stderr)
return
current_branch = os.getenv('TRAVIS_BRANCH')
target_branch = 'master'
if current_branch != target_branch:
print('Branch {cur} is not {target}. Transifex push skipped.'.format(
cur=current_branch, target=target_branch,
), file=sys.stderr)
return
write_transifex_config()
os.system('~/.local/bin/tx push -s')


if __name__ == '__main__':
main()

0 comments on commit edf6381

Please sign in to comment.