98 lines
3.4 KiB
YAML
98 lines
3.4 KiB
YAML
name: Temporary Vendor Values DB Generator
|
|
|
|
# Temporary one-shot generator for the Turtle WoW static vendor database.
|
|
on:
|
|
push:
|
|
branches: [classicapi-enhanced]
|
|
paths:
|
|
- '.github/workflows/temp-vendor-values.yml'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
generate:
|
|
if: github.actor != 'github-actions[bot]'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout ShaguTweaks
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: classicapi-enhanced
|
|
|
|
- name: Checkout Tortoise DB Viewer
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: Xian55/tortoise-db-viewer
|
|
path: .vendor-build/viewer
|
|
|
|
- name: Checkout Turtle WoW SQL
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: Penqle/tortoise-wow
|
|
path: .vendor-build/server
|
|
sparse-checkout: |
|
|
sql/base
|
|
sql/database_updates
|
|
sparse-checkout-cone-mode: false
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: Install viewer dependencies
|
|
working-directory: .vendor-build/viewer
|
|
run: bun install
|
|
|
|
- name: Build migrated Turtle SQLite
|
|
working-directory: .vendor-build/viewer
|
|
env:
|
|
SQL_DIR: ${{ github.workspace }}/.vendor-build/server/sql/base
|
|
run: bun scripts/build-db.mjs
|
|
|
|
- name: Regenerate Vendor Values table
|
|
shell: python
|
|
run: |
|
|
import re
|
|
import sqlite3
|
|
from pathlib import Path
|
|
|
|
db_path = Path('.vendor-build/viewer/public/data/tortoise.sqlite')
|
|
target = Path('mods/vendor-values.lua')
|
|
|
|
con = sqlite3.connect(db_path)
|
|
rows = con.execute(
|
|
'SELECT entry, sell_price FROM items WHERE sell_price > 0 ORDER BY entry'
|
|
).fetchall()
|
|
con.close()
|
|
|
|
entries = [f'[{item_id}]={price}' for item_id, price in rows]
|
|
lines = [' ' + ', '.join(entries[i:i + 6]) + ',' for i in range(0, len(entries), 6)]
|
|
block = (
|
|
'-- Vendor prices generated from Penqle/tortoise-wow through the migrated Tortoise DB Viewer build.\n'
|
|
'-- Values are per-item vendor sell prices in copper; unsellable (0-price) items are omitted.\n'
|
|
'local data = {\n' + '\n'.join(lines) + '\n}\n\n'
|
|
)
|
|
|
|
text = target.read_text(encoding='utf-8')
|
|
pattern = r'(?:-- Vendor prices generated.*?\n-- Values are per-item.*?\n)?local data = \{\n.*?\n\}\n\n'
|
|
new_text, count = re.subn(pattern, block, text, count=1, flags=re.S)
|
|
if count != 1:
|
|
raise SystemExit(f'Could not replace Vendor Values data table (matches={count})')
|
|
|
|
target.write_text(new_text, encoding='utf-8', newline='\n')
|
|
print(f'Generated {len(rows)} sellable item prices')
|
|
print(f'Highest item ID: {rows[-1][0] if rows else 0}')
|
|
print(f'File size: {target.stat().st_size} bytes')
|
|
|
|
- name: Commit generated database
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add mods/vendor-values.lua
|
|
git diff --cached --stat
|
|
git diff --cached --quiet && exit 0
|
|
git commit -m "Update Vendor Values database for Turtle WoW 1.18.1"
|
|
git push origin HEAD:classicapi-enhanced
|