-
Notifications
You must be signed in to change notification settings - Fork 21
444 lines (352 loc) · 13.5 KB
/
draft_release.yml
File metadata and controls
444 lines (352 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
name: Draft Release
on:
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build-linux:
runs-on: ubuntu-latest
outputs:
RELEASE_DATE: ${{ steps.set_release_date.outputs.RELEASE_DATE }}
RELEASE_TAG: ${{ steps.set_release_tag.outputs.RELEASE_TAG }}
steps:
# ----------------------------------------
# Setup
# ----------------------------------------
- name: Checkout repository
uses: actions/checkout@v5
with:
repository: 'digitalpalidictionary/dpd-db'
ref: 'main'
submodules: 'recursive'
# Fetch depth 1 for shallow clone to save disk space
fetch-depth: 1
# Use PAT to allow pushing to the submodule
token: ${{ secrets.GH_PAT }}
- name: Remove large dirs
run: |
rm -rf ${{ github.workspace }}/resources/bjt/dev/*
rm -rf ${{ github.workspace }}/resources/sc-data/html_text/*
- name: Unzip deconstructor_output
run: |
cd ${{ github.workspace }}/resources/deconstructor_output
tar -xzvf deconstructor_output.json.tar.gz
ls -la
cd ${{ github.workspace }}/
- name: Install dictzip
run: sudo apt-get update && sudo apt-get install -y dictzip
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install Slob Linux dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential libicu-dev icu-devtools pkg-config
- name: Install dependencies
run: uv sync --all-groups
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.22.2'
# ----------------------------------------
# Build Database
# ----------------------------------------
- name: Config for GitHub release
run: uv run python scripts/build/config_github_release.py
- name: Create dpd.db
run: touch dpd.db
- name: Build the database
run: uv run python scripts/build/db_rebuild_from_tsv.py
- name: Run initial setup script
run: uv run python scripts/bash/initial_setup_run_once.py
- name: Create version
run: uv run python tools/version.py
- name: Create Inflection Templates
run: uv run python db/inflections/create_inflection_templates.py
- name: Create Inflection Tables
run: uv run python db/inflections/generate_inflection_tables.py
- name: Update Root Has Verb values
run: uv run python scripts/build/root_has_verb_updater.py
- name: Update Sanskrit Family Roots
run: uv run python scripts/build/sanskrit_root_families_updater.py
- name: Add Root Families
run: uv run python db/families/family_root.py
- name: Add Word Families
run: uv run python db/families/family_word.py
- name: Add Compound Families
run: uv run python db/families/family_compound.py
- name: Add Sets
run: uv run python db/families/family_set.py
- name: Add Idioms
run: uv run python db/families/family_idiom.py
- name: Families to JSON
run: uv run python scripts/build/families_to_json.py
- name: Extract Variants
run: uv run python db/variants/main.py
- name: Run Deconstructor
run: uv run python scripts/build/deconstructor_output_add_to_db.py
- name: Add api ca eva iti to inflections
run: uv run python scripts/build/api_ca_eva_iti_iva_hi.py
- name: Transliterate Inflections
run: uv run python db/inflections/transliterate_inflections.py
- name: Inflections to Headwords
run: uv run python db/inflections/inflections_to_headwords.py
- name: Populate Sutta table
run: uv run python db/suttas/suttas_update.py
- name: Add Suttas to Lookup table
run: uv run python db/suttas/suttas_to_lookup.py
- name: Generate Grammar data
run: uv run python db/grammar/grammar_to_lookup.py
- name: Lookup Variants and Spelling Mistakes
run: uv run python db/lookup/spelling_mistakes.py
- name: Lookup Transliterate
run: uv run python db/lookup/transliterate_lookup_table.py
- name: Lookup Help and Abbreviations
run: uv run python db/lookup/help_abbrev_add_to_lookup.py
- name: Add Frequency
run: |
go build -o frequency go_modules/frequency/main.go
./frequency
- name: Run EBT Counter
run: uv run python scripts/build/ebt_counter.py
- name: Add EPD to Lookup Table
run: uv run python db/epd/epd_to_lookup.py
- name: Test Dealbreakers
run: uv run python scripts/build/dealbreakers.py
# ----------------------------------------
# Download Audio Database
# ----------------------------------------
- name: Download Audio Database
run: uv run python audio/db_release_download.py
# ----------------------------------------
# Exporter
# ----------------------------------------
- name: Setup disk space checker
run: |
cat << 'EOF' >> $HOME/check_disk.sh
#!/bin/bash
echo "=== Disk space and large files (>1GB) ==="
df -h
du -h --max-depth=2 ${{ github.workspace }} | grep -E "^[0-9.]+[GT]" || echo "No files >1GB found"
EOF
chmod +x $HOME/check_disk.sh
- name: Export Grammar Dictionary
run: uv run python exporter/grammar_dict/grammar_dict.py
- name: Export GoldenDict & MDict
run: |
uv run python exporter/goldendict/main.py
echo "=== After GoldenDict export ==="
$HOME/check_disk.sh
- name: Delete Audio Database to free space
run: |
echo "=== Before deleting audio DB ==="
$HOME/check_disk.sh
rm -rf ${{ github.workspace }}/audio/db/dpd_audio.db
echo "=== After deleting audio DB ==="
$HOME/check_disk.sh
- name: Export Deconstructor
run: |
uv run python exporter/deconstructor/deconstructor_exporter.py
echo "=== After Deconstructor export ==="
$HOME/check_disk.sh
- name: Export Kindle & ePub
run: |
uv run python exporter/kindle/kindle_exporter.py
echo "=== After Kindle export ==="
$HOME/check_disk.sh
- name: Export Kobo
run: |
uv run python exporter/kobo/kobo.py
echo "=== After Kobo export ==="
$HOME/check_disk.sh
- name: Export Variants
run: |
uv run python exporter/variants/variants_exporter.py
echo "=== After Variants export ==="
$HOME/check_disk.sh
- name: Export TXT
run: |
uv run python exporter/txt/export_txt.py
echo "=== After TXT export ==="
$HOME/check_disk.sh
- name: Export Mobile DB
run: |
uv run python exporter/mobile/mobile_exporter.py
echo "=== After Mobile DB export ==="
$HOME/check_disk.sh
# ----------------------------------------
# Export Apple Dictionary Source
# ----------------------------------------
- name: Export Apple Dictionary
run: |
uv run python exporter/apple_dictionary/apple_dictionary.py
echo "=== After Apple Dictionary export ==="
ls -lh exporter/share/apple_dictionary/
$HOME/check_disk.sh
# ----------------------------------------
# Package Assets
# ----------------------------------------
- name: Zip GoldenDict & Mdict
run: |
uv run python scripts/build/zip_goldendict_mdict.py
echo "=== After zipping ==="
$HOME/check_disk.sh
- name: Tarball DB
run: |
uv run python scripts/build/tarball_db.py
echo "=== After tarball ==="
$HOME/check_disk.sh
# ----------------------------------------
# Upload Artifacts for macOS Build
# ----------------------------------------
- name: Upload Apple Dictionary Source
uses: actions/upload-artifact@v6
with:
name: apple-dictionary-source
path: exporter/share/apple_dictionary/
retention-days: 1
# ----------------------------------------
# Prepare Release Metadata
# ----------------------------------------
- name: Make Release Notes
run: uv run python tools/docs_changelog_and_release_notes.py
- name: Commit updated uposatha count
run: |
if git diff --quiet tools/uposatha_day.ini; then
echo "No changes to uposatha count"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add tools/uposatha_day.ini
git commit -m "chore: update uposatha count"
git push
fi
- name: Set Release Date
id: set_release_date
run: |
echo "RELEASE_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "RELEASE_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Set Release Tag
id: set_release_tag
run: |
echo "RELEASE_TAG=$(uv run python scripts/build/version_print.py)" >> $GITHUB_ENV
echo "RELEASE_TAG=$(uv run python scripts/build/version_print.py)" >> $GITHUB_OUTPUT
- name: Prepare Kobo Asset
run: cp exporter/share/dicthtml-pi-en.zip exporter/share/dpd-kobo.zip
# ----------------------------------------
# Upload Linux Artifacts
# ----------------------------------------
- name: Upload Linux Assets
uses: actions/upload-artifact@v6
with:
name: linux-assets
path: |
exporter/share/dpd-goldendict.zip
exporter/share/dpd.slob
exporter/share/dpd-mdict.zip
exporter/share/dpd-kindle.epub
exporter/share/dpd-kindle.mobi
exporter/share/dpd.db.tar.bz2
exporter/share/dpd-kobo.zip
exporter/share/dpd-txt.zip
exporter/share/dpd-mobile-db.zip
exporter/share/release_notes.md
retention-days: 1
# ----------------------------------------
# Job 2: Build Apple Dictionary
# ----------------------------------------
build-macos:
needs: build-linux
runs-on: macos-14
steps:
- name: Download Apple Dictionary Source
uses: actions/download-artifact@v6
with:
name: apple-dictionary-source
path: ./apple-dictionary-source/
- name: Setup Dictionary Development Kit
run: |
# Install Rosetta 2 for legacy binary compatibility
if ! /usr/bin/pgrep oahd >/dev/null 2>&1; then
sudo softwareupdate --install-rosetta --agree-to-license
fi
git clone --depth 1 https://github.com/SebastianSzturo/Dictionary-Development-Kit.git
DDK_PATH="$(pwd)/Dictionary-Development-Kit"
echo "DDK_PATH=$DDK_PATH" >> $GITHUB_ENV
# Ensure binaries are executable
chmod +x "$DDK_PATH/bin/"*
- name: Build Dictionary
run: |
if [ ! -s "./apple-dictionary-source/Dictionary.xml" ]; then
echo "Error: Dictionary.xml is missing or empty"
exit 1
fi
mkdir -p build
cp ./apple-dictionary-source/Dictionary.xml ./build/
cp ./apple-dictionary-source/Dictionary.css ./build/
cp ./apple-dictionary-source/Info.plist ./build/
cd build
# Compile using Rosetta 2 (arch -x86_64)
arch -x86_64 "$DDK_PATH/bin/build_dict.sh" \
"Digital-Pali-Dictionary" \
Dictionary.xml \
Dictionary.css \
Info.plist
# Move output from objects directory to root for packaging
if [ -d "objects/Digital-Pali-Dictionary.dictionary" ]; then
mv objects/Digital-Pali-Dictionary.dictionary .
else
echo "Error: Build failed to produce .dictionary bundle"
exit 1
fi
- name: Package Dictionary
run: |
cd build
zip -r dpd-apple.dictionary.zip Digital-Pali-Dictionary.dictionary
- name: Upload Apple Dictionary
uses: actions/upload-artifact@v6
with:
name: macos-dictionary
path: build/dpd-apple.dictionary.zip
retention-days: 1
# ----------------------------------------
# Job 3: Create Draft Release
# ----------------------------------------
create-release:
needs: [build-linux, build-macos]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Linux Assets
uses: actions/download-artifact@v6
with:
name: linux-assets
path: ./linux-assets/
- name: Download Apple Dictionary
uses: actions/download-artifact@v6
with:
name: macos-dictionary
path: ./macos-dictionary/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.build-linux.outputs.RELEASE_TAG }}
name: ${{ needs.build-linux.outputs.RELEASE_DATE }}
body_path: ./linux-assets/release_notes.md
draft: true
prerelease: false
files: |
./linux-assets/dpd-goldendict.zip
./linux-assets/dpd.slob
./linux-assets/dpd-mdict.zip
./linux-assets/dpd-kindle.epub
./linux-assets/dpd-kindle.mobi
./linux-assets/dpd.db.tar.bz2
./linux-assets/dpd-kobo.zip
./linux-assets/dpd-txt.zip
./linux-assets/dpd-mobile-db.zip
./macos-dictionary/dpd-apple.dictionary.zip
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}