diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml new file mode 100644 index 0000000000..c2e3ce8207 --- /dev/null +++ b/.github/workflows/translations.yml @@ -0,0 +1,34 @@ +name: Transifex +on: + push: + branches: [master, ] + + +jobs: + Push-To-Transifex: + name: Update translations on Transifex + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@master + with: + fetch-depth: 2 + + - name: Set up Python + uses: actions/setup-python@master + with: + python-version: 3.8 + + - name: Install calibre dependencies + run: + python setup/unix-ci.py install + + - name: Install transifex client + run: + python -m pip install transifex-client + + - name: Update translations + env: + tx: ${{ secrets.tx }} + run: + python setup/unix-ci.py pot diff --git a/setup/unix-ci.py b/setup/unix-ci.py index 260baff1a8..db60f5d7bf 100644 --- a/setup/unix-ci.py +++ b/setup/unix-ci.py @@ -115,11 +115,24 @@ def main(): install_env() run_python('setup.py bootstrap --ephemeral') + elif action == 'pot': + install_env() + transifexrc = '''\ +[https://www.transifex.com] +api_hostname = https://api.transifex.com +hostname = https://www.transifex.com +password = PASSWORD +username = api +'''.replace('PASSWORD', os.environ['tx']) + with open(os.path.expanduser('~/.transifexrc'), 'w') as f: + f.write(transifexrc) + run_python('setup.py pot') + elif action == 'test': os.environ['CI'] = 'true' if ismacos: - os.environ['SSL_CERT_FILE' - ] = os.path.abspath('resources/mozilla-ca-certs.pem') + os.environ['SSL_CERT_FILE'] = os.path.abspath( + 'resources/mozilla-ca-certs.pem') install_env() run_python('setup.py test')