Build titledb #936
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a basic workflow to help you get started with Actions | |
name: Build titledb | |
# Controls when the workflow will run | |
on: | |
schedule: | |
- cron: '0 */4 * * *' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
# Runs a set of commands using the runners shell | |
- name: Setup folders | |
run: | | |
sudo apt update && sudo apt install -y libcurl4-openssl-dev libssl-dev | |
git clone https://github.com/blawar/nut | |
cd nut | |
pip install -r requirements.txt | |
mkdir build_artefacts | |
git clone --depth=1 https://github.com/blawar/titledb | |
titledb_commit=$(git -C titledb rev-parse --short HEAD) | |
echo "formatted_date=$(date +"%Y-%m-%d_%H%M%S")" >> $GITHUB_ENV | |
touch "build_artefacts/latest_${titledb_commit}" | |
- uses: jannekem/run-python-script-action@v1 | |
name: Generate region titles | |
with: | |
script: | | |
import os, sys | |
import json | |
os.chdir('nut') | |
sys.path.append(os.getcwd()) | |
import nut | |
with open('titledb/languages.json') as f: | |
languages = json.load(f) | |
languages = dict(sorted(languages.items())) | |
for region in languages.keys(): | |
for language in languages[region]: | |
print(region, language) | |
nut.importRegion(region, language) | |
os.rename('titledb/titles.json', f'build_artefacts/titles.{region}.{language}.json') | |
for f in [ | |
'cnmts.json', | |
'languages.json', | |
'versions.json', | |
'versions.txt', | |
]: | |
os.rename(f'titledb/{f}', f'build_artefacts/{f}') | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: titledb | |
path: nut/build_artefacts/* | |
compression-level: 9 |