Skip to content

Commit 37e801e

Browse files
committed
Tidy up build scripts
1 parent 312f6c0 commit 37e801e

File tree

4 files changed

+92
-51
lines changed

4 files changed

+92
-51
lines changed

.travis.yml

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
dist: trusty
1+
dist: xenial
22
language: python
3-
python: '3.6'
3+
python: '3.7'
44
branches:
55
only:
66
- 3.7
@@ -14,61 +14,17 @@ env:
1414
- CATALOG_BRANCH=catalog-3.7
1515
# Transifex project name
1616
- TRANSIFEX_PROJECT=python-newest
17+
# Directory where repositories are cloned
18+
- BASEDIR="$(dirname ${TRAVIS_BUILD_DIR})"
1719
before_install:
18-
- export TZ=Asia/Tokyo
19-
- git checkout ${DOCS_BRANCH}
20-
- cd ..
21-
- pwd
22-
- ls -la
23-
- BASEDIR="$(pwd)"
24-
- cd ~
25-
- openssl aes-256-cbc -K ${encryption_37_K} -iv ${encryption_37_iv} -in "${BASEDIR}/python-docs-ja/secrets_${DOCS_BRANCH}.tar.enc" -out ~/secrets_${DOCS_BRANCH}.tar -d
26-
- tar xvf ~/secrets_${DOCS_BRANCH}.tar
27-
- rm ~/secrets_${DOCS_BRANCH}.tar
28-
- chmod 600 ~/.ssh/python-docs-ja_${DOCS_BRANCH}
29-
- chmod 600 ~/.ssh/cpython-doc-catalog_${CATALOG_BRANCH}
30-
# Hack from: https://gist.github.com/jamesmcfadden/d379e04e7ae2861414886af189ec59e5
31-
- echo -e "Host python-docs-ja.github.com\n\tHostName github.com\n\tIdentityFile ~/.ssh/python-docs-ja_${DOCS_BRANCH}\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
32-
- echo -e "Host cpython-doc-catalog.github.com\n\tHostName github.com\n\tIdentityFile ~/.ssh/cpython-doc-catalog_${CATALOG_BRANCH}\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
33-
- cat ~/.ssh/config
34-
- git config --global user.email "travisci-build-bot@example.com"
35-
- git config --global user.name "Autobuild bot on TravisCI"
20+
- bash ./scripts/before_install_3.7
3621
install:
3722
- pip install sphinx
3823
- pip install blurb
3924
- pip install transifex-client
4025
- pip install sphinx-intl
41-
- cd "${BASEDIR}"
42-
- git clone --depth 50 --branch ${CATALOG_BRANCH} https://github.com/python-doc-ja/cpython-doc-catalog.git cpython-doc-catalog
43-
- mkdir -p "${BASEDIR}"/cpython-doc-catalog/Doc/locales/ja
44-
- cd "${BASEDIR}"/cpython-doc-catalog/Doc/locales/ja
45-
- ln -s "${BASEDIR}"/python-docs-ja LC_MESSAGES
46-
- ls -lF LC_MESSAGES
4726
script:
4827
# upload-catalog
49-
- cd "${BASEDIR}"/cpython-doc-catalog/Doc/locales
50-
- tx pull --force --language ja
51-
- cd ja/LC_MESSAGES
52-
- git add *.po **/*.po
53-
- git status
54-
- if [ $(git status --short | wc -l) -eq 0 ]; then echo "no .po file to upload"; else echo "I have .po file(s) to upload"; git commit --message="[skip ci] Update .po files"; git push --quiet "git@python-docs-ja.github.com:python/python-docs-ja.git" ${DOCS_BRANCH}:${DOCS_BRANCH}; fi
55-
- rm -rf "${BASEDIR}"/cpython-doc-catalog/Doc/locales/ja
28+
- bash ./scripts/upload-catalog
5629
# renew-catalog-template
57-
- cd "${BASEDIR}"/cpython-doc-catalog
58-
- git remote add upstream https://github.com/python/cpython.git
59-
- git remote -v
60-
- git fetch --quiet upstream
61-
- git merge --no-ff upstream/${CPYTHON_BRANCH} -m "Merge remote-tracking branch 'upstream/${CPYTHON_BRANCH}' into ${CATALOG_BRANCH} by Autobuild bot on TravisCI"
62-
- cd Doc
63-
- make build ALLSPHINXOPTS="-E -b gettext -D gettext_compact=0 -d build/.doctrees . locales/pot"
64-
- ls -lt locales/pot
65-
- cd locales
66-
- git add pot
67-
- if [ $(git status -s | wc -l) -eq 0 ]; then echo "no .pot file to update"; exit 0; else echo "I have .pot file(s) to upload"; fi
68-
- rm -rf .tx
69-
- sphinx-intl create-txconfig
70-
- sphinx-intl update-txconfig-resources --transifex-project-name=${TRANSIFEX_PROJECT} --locale-dir . --pot-dir pot
71-
- tx push -s
72-
- git add .tx
73-
- git commit --message="[skip ci] Update .pot files and .tx/config"
74-
- git push --quiet "git@cpython-doc-catalog.github.com:python-doc-ja/cpython-doc-catalog.git" ${CATALOG_BRANCH}:${CATALOG_BRANCH}
30+
- bash ./scripts/renew-catalog-template

scripts/before_install_3.7

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
ls -la ${BASEDIR}
4+
git config --global user.email "travisci-build-bot@example.com"
5+
git config --global user.name "Autobuild bot on TravisCI"
6+
git checkout ${DOCS_BRANCH}
7+
8+
# extract secrets
9+
cd ~
10+
openssl aes-256-cbc -K ${encryption_37_K} -iv ${encryption_37_iv} -in "${BASEDIR}/python-docs-ja/secrets_${DOCS_BRANCH}.tar.enc" -out ~/secrets_${DOCS_BRANCH}.tar -d
11+
tar xvf ~/secrets_${DOCS_BRANCH}.tar
12+
rm ~/secrets_${DOCS_BRANCH}.tar
13+
chmod 600 ~/.ssh/python-docs-ja_${DOCS_BRANCH}
14+
chmod 600 ~/.ssh/cpython-doc-catalog_${CATALOG_BRANCH}
15+
16+
# enable using plural deploy keys for repositories
17+
# Hack from: https://gist.github.com/jamesmcfadden/d379e04e7ae2861414886af189ec59e5
18+
cat <<EOF >> ~/.ssh/config
19+
Host python-docs-ja.github.com
20+
HostName github.com
21+
IdentityFile ~/.ssh/python-docs-ja_${DOCS_BRANCH}
22+
StrictHostKeyChecking no
23+
24+
Host cpython-doc-catalog.github.com
25+
HostName github.com
26+
IdentityFile ~/.ssh/cpython-doc-catalog_${CATALOG_BRANCH}
27+
StrictHostKeyChecking no
28+
EOF
29+
30+
cat ~/.ssh/config

scripts/renew-catalog-template

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# merge from upstream
4+
cd "${BASEDIR}"/cpython-doc-catalog
5+
git remote add upstream https://github.com/python/cpython.git
6+
git remote -v
7+
git fetch --quiet upstream
8+
git merge --no-ff upstream/${CPYTHON_BRANCH} -m "Merge remote-tracking branch 'upstream/${CPYTHON_BRANCH}' into ${CATALOG_BRANCH} by Autobuild bot on TravisCI"
9+
10+
# generate catalog
11+
cd Doc
12+
make build ALLSPHINXOPTS="-E -b gettext -D gettext_compact=0 -d build/.doctrees . locales/pot"
13+
ls -lt locales/pot
14+
15+
# upload catalog templates to cpython-doc-catalog
16+
cd locales
17+
git add pot
18+
if [ $(git status -s | wc -l) -eq 0 ]; then
19+
echo "no .pot file to update"
20+
exit 0
21+
fi
22+
23+
echo "I have .pot file(s) to upload"
24+
25+
rm -rf .tx
26+
sphinx-intl create-txconfig
27+
sphinx-intl update-txconfig-resources --transifex-project-name=${TRANSIFEX_PROJECT} --locale-dir . --pot-dir pot
28+
tx push -s
29+
git add .tx
30+
git commit --message="[skip ci] Update .pot files and .tx/config"
31+
git push --quiet "git@cpython-doc-catalog.github.com:python-doc-ja/cpython-doc-catalog.git" ${CATALOG_BRANCH}:${CATALOG_BRANCH}

scripts/upload-catalog

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# clone an additional repository
4+
cd "${BASEDIR}"
5+
git clone --depth 50 --branch ${CATALOG_BRANCH} https://github.com/python-doc-ja/cpython-doc-catalog.git cpython-doc-catalog
6+
mkdir -p "${BASEDIR}"/cpython-doc-catalog/Doc/locales/ja
7+
cd "${BASEDIR}"/cpython-doc-catalog/Doc/locales/ja
8+
ln -s "${BASEDIR}"/python-docs-ja LC_MESSAGES
9+
ls -lF LC_MESSAGES
10+
11+
# upload catalogs to python-docs-ja
12+
cd "${BASEDIR}"/cpython-doc-catalog/Doc/locales
13+
tx pull --force --language ja
14+
cd ja/LC_MESSAGES
15+
git add *.po **/*.po
16+
git status
17+
if [ $(git status --short | wc -l) -eq 0 ]; then
18+
echo "no .po file to upload"
19+
else
20+
echo "I have .po file(s) to upload"
21+
git commit --message="[skip ci] Update .po files"
22+
git push --quiet "git@python-docs-ja.github.com:python/python-docs-ja.git" ${DOCS_BRANCH}:${DOCS_BRANCH}
23+
fi
24+
rm -rf "${BASEDIR}"/cpython-doc-catalog/Doc/locales/ja

0 commit comments

Comments
 (0)