-
Notifications
You must be signed in to change notification settings - Fork 4
74 lines (63 loc) · 2.31 KB
/
sync-typeshed.yml
File metadata and controls
74 lines (63 loc) · 2.31 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
name: Sync bundled typeshed
on:
schedule:
- cron: "0 9 1 * *"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
sync-typeshed:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Sync bundled typeshed
id: sync
run: |
python update_bundled.py
if git diff --cached --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Bump minor version
id: bump
if: steps.sync.outputs.changed == 'true'
run: |
new_version="$(python - <<'PY'
import pathlib
import re
path = pathlib.Path("typeshed_client/__init__.py")
text = path.read_text(encoding="utf-8")
match = re.search(r'^__version__\s*=\s*"(\d+)\.(\d+)\.(\d+)"$', text, re.MULTILINE)
if match is None:
raise SystemExit("Could not find __version__ in typeshed_client/__init__.py")
major, minor, _patch = map(int, match.groups())
new_version = f"{major}.{minor + 1}.0"
path.write_text(text[: match.start(0)] + f'__version__ = "{new_version}"' + text[match.end(0) :], encoding="utf-8")
print(new_version)
PY
)"
echo "new_version=${new_version}" >> "$GITHUB_OUTPUT"
- name: Run tests
if: steps.sync.outputs.changed == 'true'
run: |
python -m pip install -e .
python tests/test.py
- name: Create pull request
if: steps.sync.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v6
with:
branch: automation/sync-typeshed
delete-branch: true
commit-message: "Sync bundled typeshed and bump version to ${{ steps.bump.outputs.new_version }}"
title: "Sync bundled typeshed and bump version to ${{ steps.bump.outputs.new_version }}"
body: |
Automated update from the scheduled sync workflow.
Changes:
- sync `typeshed_client/typeshed` from `python/typeshed`
- bump `typeshed_client.__version__` to `${{ steps.bump.outputs.new_version }}`