Skip to content

Translations update from Hosted Weblate #176

Translations update from Hosted Weblate

Translations update from Hosted Weblate #176

name: Compress and Release
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'mux/*.json'
- 'tr_map.txt'
- '.github/workflows/compress-and-release-lang.yml'
pull_request:
paths:
- 'mux/*.json'
- 'tr_map.txt'
- '.github/workflows/compress-and-release-lang.yml'
jobs:
compress-and-upload:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Derive tag, name, and target
shell: bash
run: |
set -eu
TS="$(date +'%Y%m%d-%H%M%S')"
SHORT_SHA="$(git rev-parse --short HEAD)"
NOW_DATE="$(date +'%Y-%m-%d %H:%M:%S')"
case "${{ github.event_name }}" in
workflow_dispatch)
TAG_NAME="release-${TS}"
RELEASE_NAME="Language Pack - ${NOW_DATE}"
TARGET="${{ github.sha }}"
;;
push)
TAG_NAME="release-main-${SHORT_SHA}-${TS}"
RELEASE_NAME="Language Pack (main @ ${SHORT_SHA}) - ${NOW_DATE}"
TARGET="${{ github.sha }}"
;;
pull_request)
PR="${{ github.event.pull_request.number }}"
TAG_NAME="pr-${PR}-${SHORT_SHA}-${TS}"
RELEASE_NAME="Language Pack (PR #${PR}) - ${NOW_DATE}"
TARGET="${{ github.event.pull_request.head.sha }}"
;;
esac
{
echo "TAG_NAME=$TAG_NAME"
echo "RELEASE_NAME=$RELEASE_NAME"
echo "TARGET_COMMITISH=$TARGET"
} >> "$GITHUB_ENV"
- name: Build lang.muxzip
shell: bash
run: |
set -euxo pipefail
MAP="tr_map.txt"
SRC="mux"
test -f "$MAP"
test -d "$SRC"
mkdir -p artifacts
STAGE="$(mktemp -d)"
DEST="$STAGE/language"
mkdir -p "$DEST"
added=0
while IFS= read -r -d '' f; do
code="${f##*/}"; code="${code%.json}"
if ! name="$(awk -F: -v k="$code" '
$1==k {
n=$2
sub(/^[[:space:]]+/,"",n)
sub(/[[:space:]\r]+$/,"",n)
print n
found=1
}
END { if (!found) exit 1 }
' "$MAP" 2>/dev/null)"; then
echo "::notice::Skipped $code (no mapping in tr_map.txt)"
continue
fi
cp "$f" "$DEST/$name.json"
echo "Added: $code -> $name"
added=$((added+1))
done < <(find "$SRC" -type f -name '*.json' -print0 | sort -z)
echo "Total mapped files added: $added"
if [ "$added" -eq 0 ]; then
echo "::error::No mapped languages found."
exit 1
fi
( cd "$STAGE" && zip -r9X lang.muxzip language )
mv "$STAGE/lang.muxzip" artifacts/lang.muxzip
unzip -l artifacts/lang.muxzip || true
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: lang.muxzip
path: artifacts/lang.muxzip
if-no-files-found: error
retention-days: 14
- name: Create GitHub Release
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG_NAME }}
name: ${{ env.RELEASE_NAME }}
target_commitish: ${{ env.TARGET_COMMITISH }}
files: artifacts/lang.muxzip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}