-
Notifications
You must be signed in to change notification settings - Fork 466
71 lines (64 loc) · 2.79 KB
/
Copy pathpricing-supplement.yml
File metadata and controls
71 lines (64 loc) · 2.79 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
# Publishes the pricing supplement to GitHub Pages whenever it changes on main.
#
# Installed apps fetch https://robinebers.github.io/openusage/pricing_supplement.json on their daily
# pricing refresh, so merging a change to the supplement updates Cursor-native model pricing (auto,
# composer-*, github_bugbot), fast multipliers, and model alias rules in the field within ~a day —
# no tag, no release, no Sparkle involvement.
#
# Shares the release workflow's concurrency group: both publish to gh-pages with keep_files, so
# serializing them prevents lost updates from concurrent pushes to the branch.
name: Publish pricing supplement
on:
push:
branches: [main]
paths:
- Sources/OpenUsage/Resources/pricing_supplement.json
- .github/workflows/pricing-supplement.yml
workflow_dispatch:
concurrency:
group: release-appcast
cancel-in-progress: false
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Validate supplement JSON
run: |
python3 - << 'PY'
import json, re, sys
with open("Sources/OpenUsage/Resources/pricing_supplement.json") as f:
supplement = json.load(f)
problems = []
for model, entry in supplement["pricing"].items():
for field in ("input_per_million", "output_per_million"):
if not isinstance(entry.get(field), (int, float)):
problems.append(f"pricing[{model}].{field} missing or not a number")
for rule in supplement["alias_rules"]:
try:
re.compile(rule["pattern"])
except re.error as error:
problems.append(f"alias pattern {rule['pattern']!r}: {error}")
if not rule.get("canonical"):
problems.append(f"alias pattern {rule['pattern']!r} has no canonical")
for model, multiplier in (supplement.get("fast_multipliers") or {}).items():
if not isinstance(multiplier, (int, float)) or multiplier <= 0:
problems.append(f"fast_multipliers[{model}] must be a positive number")
if problems:
sys.exit("Supplement validation failed:\n" + "\n".join(problems))
print(f"Supplement OK: {len(supplement['pricing'])} models, "
f"{len(supplement['alias_rules'])} alias rules.")
PY
- name: Assemble Pages directory
run: |
mkdir -p public
cp Sources/OpenUsage/Resources/pricing_supplement.json public/pricing_supplement.json
- name: Publish to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./public
keep_files: true