mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
Translations: github workflows use the translations branch
This commit is contained in:
parent
ec4bacc1a8
commit
00699aaed4
4 changed files with 63 additions and 26 deletions
6
.github/workflows/integration.yml
vendored
6
.github/workflows/integration.yml
vendored
|
@ -93,7 +93,7 @@ jobs:
|
||||||
babel:
|
babel:
|
||||||
name: Babel
|
name: Babel
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
if: ${{ github.repository_owner == 'searxng' && github.ref == 'refs/heads/master' }}
|
if: ${{ github.repository_owner == 'dalf' && github.ref == 'refs/heads/master' }}
|
||||||
needs:
|
needs:
|
||||||
- python
|
- python
|
||||||
- themes
|
- themes
|
||||||
|
@ -115,11 +115,11 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.config
|
mkdir -p ~/.config
|
||||||
echo "${WEBLATE_CONFIG}" > ~/.config/weblate
|
echo "${WEBLATE_CONFIG}" > ~/.config/weblate
|
||||||
git config --global user.email "alex.searxng@al-f.net"
|
git config --global user.email "searxng-bot@users.noreply.github.com"
|
||||||
git config --global user.name "searxng-bot"
|
git config --global user.name "searxng-bot"
|
||||||
- name: Update transations
|
- name: Update transations
|
||||||
id: update
|
id: update
|
||||||
run: make V=1 ci.babel.update
|
run: make V=1 babel.master.to.translations
|
||||||
|
|
||||||
dockers:
|
dockers:
|
||||||
name: Docker
|
name: Docker
|
||||||
|
|
25
.github/workflows/translations-update.yml
vendored
25
.github/workflows/translations-update.yml
vendored
|
@ -8,7 +8,7 @@ jobs:
|
||||||
babel:
|
babel:
|
||||||
name: Weblate
|
name: Weblate
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
if: ${{ github.repository_owner == 'searxng' && github.ref == 'refs/heads/master' }}
|
if: ${{ github.repository_owner == 'dalf' && github.ref == 'refs/heads/master' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -26,9 +26,24 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.config
|
mkdir -p ~/.config
|
||||||
echo "${WEBLATE_CONFIG}" > ~/.config/weblate
|
echo "${WEBLATE_CONFIG}" > ~/.config/weblate
|
||||||
git config --global user.email "alex.searxng@al-f.net"
|
git config --global user.email "searxng-bot@users.noreply.github.com"
|
||||||
git config --global user.name "searxng-bot"
|
git config --global user.name "searxng-bot"
|
||||||
- name: Merge and push transation updates
|
- name: Merge and push transation updates
|
||||||
id: update
|
run: make V=1 ci.babel.translations.to.master
|
||||||
run: make V=1 weblate.merge.push.updates
|
- name: Create Pull Request
|
||||||
|
id: cpr
|
||||||
|
uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.WEBLATE_GITHUB_TOKEN }}
|
||||||
|
commit-message: Update translations
|
||||||
|
committer: searxng-bot <searxng-bot@users.noreply.github.com>
|
||||||
|
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
||||||
|
signoff: false
|
||||||
|
branch: translations_update
|
||||||
|
delete-branch: true
|
||||||
|
draft: false
|
||||||
|
title: 'Update translations'
|
||||||
|
body: |
|
||||||
|
Update translations
|
||||||
|
labels: |
|
||||||
|
translation
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -77,7 +77,7 @@ test.shell:
|
||||||
# wrap ./manage script
|
# wrap ./manage script
|
||||||
|
|
||||||
MANAGE += buildenv
|
MANAGE += buildenv
|
||||||
MANAGE += ci.babel.update babel.extract babel.update babel.compile
|
MANAGE += babel.extract babel.update babel.compile babel.translations.to.master babel.master.to.translations
|
||||||
MANAGE += data.all data.languages data.useragents data.osm_keys_tags
|
MANAGE += data.all data.languages data.useragents data.osm_keys_tags
|
||||||
MANAGE += docs.html docs.live docs.gh-pages docs.prebuild docs.clean
|
MANAGE += docs.html docs.live docs.gh-pages docs.prebuild docs.clean
|
||||||
MANAGE += docker.build docker.push docker.buildx
|
MANAGE += docker.build docker.push docker.buildx
|
||||||
|
|
56
manage
56
manage
|
@ -122,21 +122,16 @@ buildenv() {
|
||||||
return "${PIPESTATUS[0]}"
|
return "${PIPESTATUS[0]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
babel.sha256sum() {
|
babel.weblate.to.translations() {
|
||||||
grep "msgid" "searx/translations/messages.pot" | sort | sha256sum | cut -f1 -d ' '
|
local exitcode
|
||||||
}
|
|
||||||
|
|
||||||
weblate.merge.push.updates() {
|
|
||||||
( set -e
|
( set -e
|
||||||
pyenv.cmd wlc lock
|
pyenv.cmd wlc lock
|
||||||
|
git checkout translations
|
||||||
if ! git remote get-url weblate; then
|
if ! git remote get-url weblate; then
|
||||||
git remote add weblate https://weblate.bubu1.eu/git/searxng/searxng/
|
git remote add weblate https://weblate.bubu1.eu/git/searxng/searxng/
|
||||||
fi
|
fi
|
||||||
git remote update weblate
|
git remote update weblate
|
||||||
git merge weblate/master
|
git merge weblate/translations
|
||||||
babel.compile
|
|
||||||
git add searx/translations
|
|
||||||
git commit -m "[translations] update messages.mo files"
|
|
||||||
git push
|
git push
|
||||||
)
|
)
|
||||||
exitcode=$?
|
exitcode=$?
|
||||||
|
@ -147,22 +142,49 @@ weblate.merge.push.updates() {
|
||||||
dump_return $exitcode
|
dump_return $exitcode
|
||||||
}
|
}
|
||||||
|
|
||||||
ci.babel.update() {
|
babel.translations.to.master() {
|
||||||
local sha_before
|
( set -e
|
||||||
|
# pull weblate commits
|
||||||
|
babel.weblate.to.translations
|
||||||
|
|
||||||
|
# copy the changes to the master branch
|
||||||
|
git checkout translations
|
||||||
|
tar cf "/tmp/translations.tar.gz" searx/translations
|
||||||
|
git checkout master
|
||||||
|
tar xf "/tmp/translations.tar.gz"
|
||||||
|
|
||||||
|
# compile translations
|
||||||
|
babel.compile
|
||||||
|
)
|
||||||
|
dump_return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
babel.sha256sum() {
|
||||||
|
grep "msgid" "searx/translations/messages.pot" | sort | sha256sum | cut -f1 -d ' '
|
||||||
|
}
|
||||||
|
|
||||||
|
babel.master.to.translations() {
|
||||||
|
local new_sha translations_sha exitcode
|
||||||
( set -e
|
( set -e
|
||||||
sha_before="$(babel.sha256sum)"
|
|
||||||
babel.extract
|
babel.extract
|
||||||
if [ "$(babel.sha256sum)" = "${sha_before}" ]; then
|
new_sha=$(babel.sha256sum)
|
||||||
|
git stash push "searx/translations/messages.pot"
|
||||||
|
|
||||||
|
git checkout translations
|
||||||
|
translations_sha="$(babel.sha256sum)"
|
||||||
|
|
||||||
|
if [ "${new_sha}" = "${translations_sha}" ]; then
|
||||||
build_msg BABEL 'no changes detected, exiting'
|
build_msg BABEL 'no changes detected, exiting'
|
||||||
|
git stash drop
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# call weblate.merge.push.updates right away
|
# update the translations branch with weblate commits
|
||||||
git stash push "searx/translations/messages.pot"
|
babel.weblate.to.translations
|
||||||
weblate.merge.push.updates babel.update
|
|
||||||
|
|
||||||
# then update messages.pot while weblate is locked
|
# update/commit/push messages.po while weblate is locked
|
||||||
pyenv.cmd wlc lock
|
pyenv.cmd wlc lock
|
||||||
|
git checkout translations
|
||||||
git stash pop
|
git stash pop
|
||||||
babel.update
|
babel.update
|
||||||
git add searx/translations
|
git add searx/translations
|
||||||
|
|
Loading…
Add table
Reference in a new issue