chore(i18n): automate Crowdin translation progress SVG chart and consolidate repo chart workflows

Add automated Crowdin translation progress SVG chart generator, test, and workflow. Consolidate star history and translation stats generation into unified repo-charts workflow, and update README links.
This commit is contained in:
neon
2026-07-27 18:17:33 +00:00
parent 5f47145a64
commit 3aff8f521b
12 changed files with 771 additions and 159 deletions
+141
View File
@@ -0,0 +1,141 @@
name: Repo Charts
on:
workflow_dispatch:
schedule:
- cron: "37 6 * * *"
push:
branches: [main]
paths:
- ".github/workflows/repo-charts.yml"
- "scripts/star-history/**"
- "scripts/crowdin-stats/**"
permissions: {}
concurrency:
group: repo-charts
cancel-in-progress: false
env:
CHARTS_BRANCH: generated-charts
jobs:
publish:
name: Refresh charts
if: github.repository == 'bookorbit/bookorbit'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 24
- name: Test generators
run: node --test scripts/star-history/generate.test.mjs scripts/crowdin-stats/generate.test.mjs
- name: Restore published charts
env:
SERIES_PATH: ${{ runner.temp }}/star-history.json
run: |
restore_series() {
for branch in "$CHARTS_BRANCH" star-history; do
if git ls-remote --exit-code --heads origin "$branch" >/dev/null &&
git fetch --depth 1 origin "+refs/heads/$branch:refs/remotes/origin/$branch" &&
git show "origin/$branch:star-history.json" > "$SERIES_PATH" 2>/dev/null; then
echo "Restored star history series from $branch"
return 0
fi
done
echo "No published series found, using the bootstrap snapshot"
cp scripts/star-history/bootstrap.json "$SERIES_PATH"
}
restore_series
- name: Generate star history chart
id: star-history
continue-on-error: true
env:
GITHUB_TOKEN: ${{ github.token }}
STAR_HISTORY_TOKEN: ${{ secrets.STAR_HISTORY_TOKEN }}
SERIES_PATH: ${{ runner.temp }}/star-history.json
SVG_PATH: ${{ runner.temp }}/star-history.svg
run: |
node scripts/star-history/generate.mjs \
--repo "$GITHUB_REPOSITORY" \
--series "$SERIES_PATH" \
--bootstrap scripts/star-history/bootstrap.json \
--out "$SVG_PATH"
- name: Generate translation progress chart
id: translation-progress
continue-on-error: true
env:
SVG_PATH: ${{ runner.temp }}/translation-progress.svg
run: |
node scripts/crowdin-stats/generate.mjs --out "$SVG_PATH"
- name: Publish charts
env:
SERIES_PATH: ${{ runner.temp }}/star-history.json
STAR_SVG_PATH: ${{ runner.temp }}/star-history.svg
TRANSLATION_SVG_PATH: ${{ runner.temp }}/translation-progress.svg
GIT_INDEX_FILE: ${{ runner.temp }}/charts.index
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
parent=$(git rev-parse --verify "refs/remotes/origin/$CHARTS_BRANCH" 2>/dev/null || true)
rm -f "$GIT_INDEX_FILE"
if [ -n "$parent" ]; then
git read-tree "$parent"
fi
stage_chart() {
if [ ! -s "$2" ]; then
echo "Skipping $1, keeping the published copy"
return 0
fi
blob=$(git hash-object -w "$2")
git update-index --add --cacheinfo "100644,$blob,$1"
}
stage_chart star-history.svg "$STAR_SVG_PATH"
stage_chart star-history.json "$SERIES_PATH"
stage_chart translation-progress.svg "$TRANSLATION_SVG_PATH"
tree=$(git write-tree)
if [ -n "$parent" ]; then
if [ "$tree" = "$(git rev-parse "$parent^{tree}")" ]; then
echo "Charts are unchanged"
exit 0
fi
commit=$(printf '%s\n' "chore: update repository charts" | \
TZ=UTC git commit-tree "$tree" -p "$parent")
else
commit=$(printf '%s\n' "chore: initialize repository charts" | \
TZ=UTC git commit-tree "$tree")
fi
git push origin "$commit:refs/heads/$CHARTS_BRANCH"
- name: Fail on generator errors
if: steps.star-history.outcome == 'failure' || steps.translation-progress.outcome == 'failure'
env:
STAR_OUTCOME: ${{ steps.star-history.outcome }}
TRANSLATION_OUTCOME: ${{ steps.translation-progress.outcome }}
run: |
echo "star history: $STAR_OUTCOME"
echo "translation progress: $TRANSLATION_OUTCOME"
exit 1
-92
View File
@@ -1,92 +0,0 @@
name: Star History
on:
workflow_dispatch:
schedule:
- cron: "37 6 * * *"
push:
branches: [main]
paths:
- ".github/workflows/star-history.yml"
- "scripts/star-history/**"
permissions: {}
concurrency:
group: star-history
cancel-in-progress: false
jobs:
publish:
name: Refresh chart
if: github.repository == 'bookorbit/bookorbit'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: 24
- name: Test generator
run: node --test scripts/star-history/generate.test.mjs
- name: Restore accumulated series
env:
SERIES_PATH: ${{ runner.temp }}/star-history.json
run: |
if git ls-remote --exit-code --heads origin star-history >/dev/null; then
git fetch --depth 1 origin \
'+refs/heads/star-history:refs/remotes/origin/star-history'
git show origin/star-history:star-history.json > "$SERIES_PATH"
else
cp scripts/star-history/bootstrap.json "$SERIES_PATH"
fi
- name: Generate chart
env:
GITHUB_TOKEN: ${{ github.token }}
STAR_HISTORY_TOKEN: ${{ secrets.STAR_HISTORY_TOKEN }}
SERIES_PATH: ${{ runner.temp }}/star-history.json
SVG_PATH: ${{ runner.temp }}/star-history.svg
run: |
node scripts/star-history/generate.mjs \
--repo "$GITHUB_REPOSITORY" \
--series "$SERIES_PATH" \
--bootstrap scripts/star-history/bootstrap.json \
--out "$SVG_PATH"
- name: Publish chart and data
env:
SERIES_PATH: ${{ runner.temp }}/star-history.json
SVG_PATH: ${{ runner.temp }}/star-history.svg
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
json_blob=$(git hash-object -w "$SERIES_PATH")
svg_blob=$(git hash-object -w "$SVG_PATH")
tree=$(printf '100644 blob %s\tstar-history.json\n100644 blob %s\tstar-history.svg\n' \
"$json_blob" "$svg_blob" | git mktree)
parent=$(git rev-parse --verify refs/remotes/origin/star-history 2>/dev/null || true)
if [ -n "$parent" ]; then
previous_tree=$(git rev-parse "$parent^{tree}")
if [ "$tree" = "$previous_tree" ]; then
echo "Star history is unchanged"
exit 0
fi
commit=$(printf '%s\n' "chore: update star history" | \
TZ=UTC git commit-tree "$tree" -p "$parent")
else
commit=$(printf '%s\n' "chore: initialize star history" | \
TZ=UTC git commit-tree "$tree")
fi
git push origin "$commit:refs/heads/star-history"