| 1 |
name: Prepare Release |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_dispatch: |
| 5 |
inputs: |
| 6 |
bump: |
| 7 |
description: Release bump |
| 8 |
required: true |
| 9 |
type: choice |
| 10 |
options: |
| 11 |
- patch |
| 12 |
- minor |
| 13 |
- major |
| 14 |
date: |
| 15 |
description: Release date in YYYY-MM-DD format. Defaults to today. |
| 16 |
required: false |
| 17 |
type: string |
| 18 |
|
| 19 |
permissions: {} |
| 20 |
|
| 21 |
jobs: |
| 22 |
prepare-release: |
| 23 |
runs-on: ubuntu-latest |
| 24 |
timeout-minutes: 5 |
| 25 |
permissions: |
| 26 |
contents: write |
| 27 |
issues: write |
| 28 |
pull-requests: write |
| 29 |
env: |
| 30 |
PREPARE_RELEASE_VERSION_FILE: fastapi/__init__.py |
| 31 |
PREPARE_RELEASE_RELEASE_NOTES_FILE: docs/en/docs/release-notes.md |
| 32 |
steps: |
| 33 |
- name: Dump GitHub context |
| 34 |
env: |
| 35 |
GITHUB_CONTEXT: ${{ toJson(github) }} |
| 36 |
run: echo "$GITHUB_CONTEXT" |
| 37 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 38 |
with: |
| 39 |
token: ${{ secrets.FASTAPI_LATEST_CHANGES }} # zizmor: ignore[secrets-outside-env] |
| 40 |
persist-credentials: true |
| 41 |
- name: Set up Python |
| 42 |
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 |
| 43 |
with: |
| 44 |
python-version-file: ".python-version" |
| 45 |
- name: Install uv |
| 46 |
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0 |
| 47 |
with: |
| 48 |
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum. |
| 49 |
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837 |
| 50 |
version: "0.11.18" |
| 51 |
- name: Prepare release |
| 52 |
env: |
| 53 |
PREPARE_RELEASE_BUMP: ${{ inputs.bump }} |
| 54 |
PREPARE_RELEASE_DATE: ${{ inputs.date }} |
| 55 |
run: uv run python scripts/prepare_release.py prepare |
| 56 |
- name: Get release version |
| 57 |
id: release-version |
| 58 |
run: | |
| 59 |
version="$(uv run python scripts/prepare_release.py current-version)" |
| 60 |
echo "$version" |
| 61 |
echo "version=$version" >> "$GITHUB_OUTPUT" |
| 62 |
- name: Create release pull request |
| 63 |
env: |
| 64 |
GH_TOKEN: ${{ secrets.FASTAPI_LATEST_CHANGES }} |
| 65 |
VERSION: ${{ steps.release-version.outputs.version }} |
| 66 |
run: | |
| 67 |
set -euo pipefail |
| 68 |
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" |
| 71 |
git switch -c "$branch" |
| 72 |
git add $PREPARE_RELEASE_VERSION_FILE $PREPARE_RELEASE_RELEASE_NOTES_FILE |
| 73 |
git commit -m "🔖 Release version ${VERSION}" |
| 74 |
git push --set-upstream origin "$branch" |
| 75 |
gh pr create \ |
| 76 |
--base master \ |
| 77 |
--head "$branch" \ |
| 78 |
--title "🔖 Release version ${VERSION}" \ |
| 79 |
--body "Prepare release ${VERSION}." \ |
| 80 |
--label release |