|
| 1 | + |
1 | 2 | name: Push Translations to Transifex |
2 | 3 |
|
3 | 4 | on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "3.15" |
| 8 | + paths: |
| 9 | + - "**/*.po" |
| 10 | + |
4 | 11 | workflow_dispatch: |
5 | 12 | inputs: |
6 | | - version: |
7 | | - description: "Python documentation version" |
| 13 | + push_translations: |
| 14 | + description: "Push Punjabi translations to Transifex" |
8 | 15 | required: true |
9 | | - type: choice |
10 | | - options: |
11 | | - - "3.13" |
12 | | - - "3.14" |
13 | | - - "3.15" |
14 | | - default: "3.15" |
| 16 | + type: boolean |
| 17 | + default: true |
| 18 | + push_sources: |
| 19 | + description: "Generate and push CPython source templates" |
| 20 | + required: true |
| 21 | + type: boolean |
| 22 | + default: false |
15 | 23 |
|
16 | 24 | permissions: |
17 | 25 | contents: read |
18 | 26 |
|
| 27 | +concurrency: |
| 28 | + group: transifex-push-${{ github.ref }} |
| 29 | + cancel-in-progress: false |
| 30 | + |
19 | 31 | jobs: |
20 | 32 | push-translations: |
| 33 | + name: Push Punjabi translations |
| 34 | + if: github.actor != 'github-actions[bot]' && (github.event_name == 'push' || inputs.push_translations) |
| 35 | + runs-on: ubuntu-latest |
| 36 | + |
| 37 | + steps: |
| 38 | + - name: Checkout translation repository |
| 39 | + uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + persist-credentials: false |
| 42 | + |
| 43 | + - name: Install Transifex CLI |
| 44 | + working-directory: /usr/local/bin |
| 45 | + run: | |
| 46 | + curl -fsSL https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- v1.6.16 |
| 47 | +
|
| 48 | + - name: Push Punjabi translations |
| 49 | + env: |
| 50 | + TX_TOKEN: ${{ secrets.TX_TOKEN }} |
| 51 | + run: | |
| 52 | + tx push --translation --languages pa --use-git-timestamps |
| 53 | +
|
| 54 | + push-sources: |
| 55 | + name: Generate and push source templates |
| 56 | + needs: push-translations |
| 57 | + if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.push_sources && (needs.push-translations.result == 'success' || needs.push-translations.result == 'skipped') }} |
21 | 58 | runs-on: ubuntu-latest |
22 | 59 |
|
23 | 60 | steps: |
24 | | - - uses: actions/checkout@v4 |
| 61 | + - name: Checkout translation repository |
| 62 | + uses: actions/checkout@v4 |
25 | 63 | with: |
26 | | - ref: ${{ inputs.version }} |
27 | | - fetch-depth: 0 |
| 64 | + persist-credentials: false |
28 | 65 |
|
29 | | - - uses: actions/setup-python@v5 |
| 66 | + - name: Checkout CPython 3.15 |
| 67 | + uses: actions/checkout@v4 |
30 | 68 | with: |
31 | | - python-version: "3.x" |
| 69 | + repository: python/cpython |
| 70 | + ref: "3.15" |
| 71 | + path: cpython |
| 72 | + persist-credentials: false |
32 | 73 |
|
33 | | - - name: Install Dependencies |
| 74 | + - name: Set up Python |
| 75 | + uses: actions/setup-python@v5 |
| 76 | + with: |
| 77 | + python-version: "3.12" |
| 78 | + |
| 79 | + - name: Install documentation build dependencies |
34 | 80 | run: | |
35 | 81 | sudo apt-get update |
36 | 82 | sudo apt-get install -y gettext |
37 | | - pip install requests cogapp polib transifex-python sphinx-intl blurb six |
38 | | - curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash |
39 | | - working-directory: /usr/local/bin |
| 83 | + python -m pip install -r cpython/Doc/requirements.txt |
40 | 84 |
|
41 | | - - name: Recreate Transifex configuration |
| 85 | + - name: Generate gettext source templates |
42 | 86 | run: | |
43 | | - curl -O https://raw.githubusercontent.com/python-docs-translations/transifex-automations/master/sample-workflows/transifex-util.py |
44 | | - chmod +x transifex-util.py |
45 | | - ./transifex-util.py recreate_tx_config \ |
46 | | - --language pa \ |
47 | | - --project-slug python-newest \ |
48 | | - --version ${{ inputs.version }} |
49 | | - env: |
50 | | - TX_TOKEN: ${{ secrets.TX_TOKEN }} |
| 87 | + make -C cpython/Doc gettext |
| 88 | + test -d cpython/Doc/build/gettext |
| 89 | + mkdir -p gettext |
| 90 | + cp -a cpython/Doc/build/gettext/. gettext/ |
| 91 | +
|
| 92 | + - name: Validate configured source templates |
| 93 | + run: | |
| 94 | + python - <<'PY' |
| 95 | + import configparser |
| 96 | + from pathlib import Path |
| 97 | +
|
| 98 | + config = configparser.ConfigParser() |
| 99 | + if not config.read(".tx/config"): |
| 100 | + raise SystemExit("ERROR: .tx/config could not be read") |
51 | 101 |
|
52 | | - - name: Push translations to Transifex |
53 | | - run: tx push --translation --languages pa --use-git-timestamps |
| 102 | + missing = [] |
| 103 | + for section in config.sections(): |
| 104 | + source = config.get(section, "source_file", fallback="").strip() |
| 105 | + if source and not Path(source).is_file(): |
| 106 | + missing.append(f"{section}: {source}") |
| 107 | +
|
| 108 | + if missing: |
| 109 | + print("Missing source templates:") |
| 110 | + print("\n".join(missing)) |
| 111 | + raise SystemExit(1) |
| 112 | +
|
| 113 | + print("All configured source templates exist.") |
| 114 | + PY |
| 115 | +
|
| 116 | + - name: Install Transifex CLI |
| 117 | + working-directory: /usr/local/bin |
| 118 | + run: | |
| 119 | + curl -fsSL https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- v1.6.16 |
| 120 | +
|
| 121 | + - name: Push source templates |
54 | 122 | env: |
55 | 123 | TX_TOKEN: ${{ secrets.TX_TOKEN }} |
| 124 | + run: | |
| 125 | + tx push --source --skip |
0 commit comments