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:
|
||||
name: Babel
|
||||
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:
|
||||
- python
|
||||
- themes
|
||||
|
@ -115,11 +115,11 @@ jobs:
|
|||
run: |
|
||||
mkdir -p ~/.config
|
||||
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"
|
||||
- name: Update transations
|
||||
id: update
|
||||
run: make V=1 ci.babel.update
|
||||
run: make V=1 babel.master.to.translations
|
||||
|
||||
dockers:
|
||||
name: Docker
|
||||
|
|
25
.github/workflows/translations-update.yml
vendored
25
.github/workflows/translations-update.yml
vendored
|
@ -8,7 +8,7 @@ jobs:
|
|||
babel:
|
||||
name: Weblate
|
||||
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:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
@ -26,9 +26,24 @@ jobs:
|
|||
run: |
|
||||
mkdir -p ~/.config
|
||||
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"
|
||||
- name: Merge and push transation updates
|
||||
id: update
|
||||
run: make V=1 weblate.merge.push.updates
|
||||
|
||||
run: make V=1 ci.babel.translations.to.master
|
||||
- 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
|
||||
|
||||
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 += docs.html docs.live docs.gh-pages docs.prebuild docs.clean
|
||||
MANAGE += docker.build docker.push docker.buildx
|
||||
|
|
56
manage
56
manage
|
@ -122,21 +122,16 @@ buildenv() {
|
|||
return "${PIPESTATUS[0]}"
|
||||
}
|
||||
|
||||
babel.sha256sum() {
|
||||
grep "msgid" "searx/translations/messages.pot" | sort | sha256sum | cut -f1 -d ' '
|
||||
}
|
||||
|
||||
weblate.merge.push.updates() {
|
||||
babel.weblate.to.translations() {
|
||||
local exitcode
|
||||
( set -e
|
||||
pyenv.cmd wlc lock
|
||||
git checkout translations
|
||||
if ! git remote get-url weblate; then
|
||||
git remote add weblate https://weblate.bubu1.eu/git/searxng/searxng/
|
||||
fi
|
||||
git remote update weblate
|
||||
git merge weblate/master
|
||||
babel.compile
|
||||
git add searx/translations
|
||||
git commit -m "[translations] update messages.mo files"
|
||||
git merge weblate/translations
|
||||
git push
|
||||
)
|
||||
exitcode=$?
|
||||
|
@ -147,22 +142,49 @@ weblate.merge.push.updates() {
|
|||
dump_return $exitcode
|
||||
}
|
||||
|
||||
ci.babel.update() {
|
||||
local sha_before
|
||||
babel.translations.to.master() {
|
||||
( 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
|
||||
sha_before="$(babel.sha256sum)"
|
||||
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'
|
||||
git stash drop
|
||||
return 0
|
||||
fi
|
||||
|
||||
# call weblate.merge.push.updates right away
|
||||
git stash push "searx/translations/messages.pot"
|
||||
weblate.merge.push.updates babel.update
|
||||
# update the translations branch with weblate commits
|
||||
babel.weblate.to.translations
|
||||
|
||||
# then update messages.pot while weblate is locked
|
||||
# update/commit/push messages.po while weblate is locked
|
||||
pyenv.cmd wlc lock
|
||||
git checkout translations
|
||||
git stash pop
|
||||
babel.update
|
||||
git add searx/translations
|
||||
|
|
Loading…
Add table
Reference in a new issue