Skip to content

Commit be8bf40

Browse files
authored
Merge branch 'master' into feat/pydantic
2 parents fc7fb16 + 9a7b2e8 commit be8bf40

12 files changed

Lines changed: 326 additions & 383 deletions

.github/labeler.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/latest-changes.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
auto-labels:
2+
docs:
3+
- docs/**
4+
- docs_src/**
5+
internal:
6+
- .github/**
7+
- scripts/**
8+
- .gitignore
9+
- .pre-commit-config.yaml
10+
- uv.lock

.github/pr-push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
workflows:
2+
- .github/workflows/pre-commit.yml

.github/pr-submit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
workflows:
2+
- .github/workflows/bump-pre-commit-hooks.yml
3+
- .github/workflows/prepare-release.yml

.github/workflows/build-docs.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ jobs:
6767
uv.lock
6868
- name: Install docs extras
6969
run: uv sync --locked --no-dev --group docs
70-
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
71-
with:
72-
key: mkdocs-cards-${{ github.ref }}-v1
73-
path: .cache
7470
- name: Build Docs
7571
run: uv run ./scripts/docs.py build
7672
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

.github/workflows/bump-pre-commit-hooks.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ jobs:
1212
if: github.repository_owner == 'fastapi'
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 10
15+
permissions:
16+
contents: read
17+
id-token: write
1518
steps:
1619
- name: Dump GitHub context
1720
env:
1821
GITHUB_CONTEXT: ${{ toJson(github) }}
1922
run: echo "$GITHUB_CONTEXT"
2023
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2124
with:
22-
token: ${{ secrets.TYPER_LATEST_CHANGES }}
23-
persist-credentials: true
25+
persist-credentials: false
2426
- name: Set up Python
2527
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
2628
with:
@@ -36,22 +38,26 @@ jobs:
3638
uv.lock
3739
- name: Bump pre-commit hooks
3840
run: uv run prek auto-update --freeze --cooldown-days 7
41+
- name: Get PR Submit token
42+
id: pr-submit
43+
uses: tiangolo/pr-submit@d802fdf59bde80bc3eb8bd3259f4cbeec63de4aa # 0.0.1
3944
- name: Create pull request
4045
env:
41-
GH_TOKEN: ${{ secrets.TYPER_LATEST_CHANGES }}
46+
GH_TOKEN: ${{ steps.pr-submit.outputs.token }}
4247
BASE_BRANCH: ${{ github.event.repository.default_branch }}
4348
run: |
4449
set -euo pipefail
4550
if git diff --quiet; then
4651
echo "No pre-commit hook updates available"
4752
exit 0
4853
fi
49-
git config user.name "github-actions[bot]"
50-
git config user.email "github-actions[bot]@users.noreply.github.com"
54+
git config user.name "pr-submit[bot]"
55+
git config user.email "pr-submit[bot]@users.noreply.github.com"
5156
branch="bump-pre-commit-hooks"
5257
git switch -C "$branch"
5358
git add .pre-commit-config.yaml
5459
git commit -m "⬆ Bump pre-commit hooks"
60+
gh auth setup-git
5561
git push --force origin "$branch"
5662
if [ -z "$(gh pr list --head "$branch" --state open --json number --jq '.[].number')" ]; then
5763
gh pr create \

.github/workflows/labeler.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/latest-changes.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/pre-commit.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ on:
55
permissions: {}
66

77
env:
8-
# Forks and Dependabot don't have access to secrets
9-
HAS_SECRETS: ${{ secrets.PRE_COMMIT != '' }}
8+
CAN_PUSH: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]' }}
109

1110
jobs:
1211
pre-commit:
1312
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
id-token: write
1416
timeout-minutes: 5
1517
steps:
1618
- name: Dump GitHub context
@@ -19,20 +21,18 @@ jobs:
1921
run: echo "$GITHUB_CONTEXT"
2022
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2123
name: Checkout PR for own repo
22-
if: env.HAS_SECRETS == 'true'
24+
if: env.CAN_PUSH == 'true'
2325
with:
2426
# To be able to commit it needs to fetch the head of the branch, not the
2527
# merge commit
2628
ref: ${{ github.head_ref }}
2729
# And it needs the full history to be able to compute diffs
2830
fetch-depth: 0
29-
# A token other than the default GITHUB_TOKEN is needed to be able to trigger CI
30-
token: ${{ secrets.PRE_COMMIT }} # zizmor: ignore[secrets-outside-env]
31-
persist-credentials: true # Required for `git push` command
31+
persist-credentials: false
3232
# pre-commit lite ci needs the default checkout configs to work
3333
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3434
name: Checkout PR for fork
35-
if: env.HAS_SECRETS == 'false'
35+
if: env.CAN_PUSH == 'false'
3636
with:
3737
# To be able to commit it needs the head branch of the PR, the remote one
3838
ref: ${{ github.event.pull_request.head.sha }}
@@ -57,11 +57,26 @@ jobs:
5757
id: precommit
5858
run: uv run prek run --from-ref origin/${GITHUB_BASE_REF} --to-ref HEAD --show-diff-on-failure
5959
continue-on-error: true
60+
- name: Check for changes
61+
id: changes
62+
run: |
63+
if [[ -n "$(git status --porcelain)" ]]; then
64+
echo "changed=true" >> "$GITHUB_OUTPUT"
65+
else
66+
echo "changed=false" >> "$GITHUB_OUTPUT"
67+
fi
68+
- name: Get PR Push token
69+
id: pr-push
70+
if: env.CAN_PUSH == 'true' && steps.changes.outputs.changed == 'true'
71+
uses: tiangolo/pr-push@ff4e51a433de4c22bbf90597e069e8247b9203d2 # 0.0.1
6072
- name: Commit and push changes
61-
if: env.HAS_SECRETS == 'true'
73+
if: env.CAN_PUSH == 'true' && steps.changes.outputs.changed == 'true'
74+
env:
75+
GH_TOKEN: ${{ steps.pr-push.outputs.token }}
6276
run: |
63-
git config user.name "github-actions[bot]"
64-
git config user.email "github-actions[bot]@users.noreply.github.com"
77+
git config user.name "pr-push[bot]"
78+
git config user.email "pr-push[bot]@users.noreply.github.com"
79+
gh auth setup-git
6580
git add -A
6681
if git diff --staged --quiet; then
6782
echo "No changes to commit"
@@ -70,7 +85,7 @@ jobs:
7085
git push
7186
fi
7287
- uses: pre-commit-ci/lite-action@5d6cc0eb514c891a40562a58a8e71576c5c7fb43 # v1.1.0
73-
if: env.HAS_SECRETS == 'false'
88+
if: env.CAN_PUSH == 'false'
7489
with:
7590
msg: 🎨 Auto format
7691
- name: Error out on pre-commit errors

.github/workflows/prepare-release.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ jobs:
2323
runs-on: ubuntu-latest
2424
timeout-minutes: 5
2525
permissions:
26-
contents: write
27-
issues: write
28-
pull-requests: write
26+
contents: read
27+
id-token: write
2928
env:
3029
PREPARE_RELEASE_VERSION_FILE: typer/__init__.py
3130
PREPARE_RELEASE_RELEASE_NOTES_FILE: docs/release-notes.md
@@ -36,8 +35,7 @@ jobs:
3635
run: echo "$GITHUB_CONTEXT"
3736
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3837
with:
39-
token: ${{ secrets.TYPER_LATEST_CHANGES }} # zizmor: ignore[secrets-outside-env]
40-
persist-credentials: true
38+
persist-credentials: false
4139
- name: Set up Python
4240
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
4341
with:
@@ -59,18 +57,22 @@ jobs:
5957
version="$(uv run python scripts/prepare_release.py current-version)"
6058
echo "$version"
6159
echo "version=$version" >> "$GITHUB_OUTPUT"
60+
- name: Get PR Submit token
61+
id: pr-submit
62+
uses: tiangolo/pr-submit@d802fdf59bde80bc3eb8bd3259f4cbeec63de4aa # 0.0.1
6263
- name: Create release pull request
6364
env:
64-
GH_TOKEN: ${{ secrets.TYPER_LATEST_CHANGES }}
65+
GH_TOKEN: ${{ steps.pr-submit.outputs.token }}
6566
VERSION: ${{ steps.release-version.outputs.version }}
6667
run: |
6768
set -euo pipefail
6869
branch="release-${VERSION}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
69-
git config user.name "github-actions[bot]"
70-
git config user.email "github-actions[bot]@users.noreply.github.com"
70+
git config user.name "pr-submit[bot]"
71+
git config user.email "pr-submit[bot]@users.noreply.github.com"
7172
git switch -c "$branch"
7273
git add $PREPARE_RELEASE_VERSION_FILE $PREPARE_RELEASE_RELEASE_NOTES_FILE
7374
git commit -m "🔖 Release version ${VERSION}"
75+
gh auth setup-git
7476
git push --set-upstream origin "$branch"
7577
gh pr create \
7678
--base master \

0 commit comments

Comments
 (0)