| 1 |
name: Create Draft Release |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
types: |
| 6 |
- closed |
| 7 |
|
| 8 |
permissions: {} |
| 9 |
|
| 10 |
jobs: |
| 11 |
create-draft-release: |
| 12 |
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') |
| 13 |
runs-on: ubuntu-latest |
| 14 |
timeout-minutes: 5 |
| 15 |
permissions: |
| 16 |
contents: write |
| 17 |
env: |
| 18 |
PREPARE_RELEASE_VERSION_FILE: fastapi/__init__.py |
| 19 |
PREPARE_RELEASE_RELEASE_NOTES_FILE: docs/en/docs/release-notes.md |
| 20 |
steps: |
| 21 |
- name: Dump GitHub context |
| 22 |
env: |
| 23 |
GITHUB_CONTEXT: ${{ toJson(github) }} |
| 24 |
run: echo "$GITHUB_CONTEXT" |
| 25 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 26 |
with: |
| 27 |
ref: ${{ github.event.repository.default_branch }} |
| 28 |
persist-credentials: true |
| 29 |
- name: Set up Python |
| 30 |
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 |
| 31 |
with: |
| 32 |
python-version-file: ".python-version" |
| 33 |
- name: Install uv |
| 34 |
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0 |
| 35 |
with: |
| 36 |
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum. |
| 37 |
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837 |
| 38 |
version: "0.11.18" |
| 39 |
- name: Extract release details |
| 40 |
id: release-details |
| 41 |
run: | |
| 42 |
set -euo pipefail |
| 43 |
version="$(uv run python scripts/prepare_release.py current-version)" |
| 44 |
uv run python scripts/prepare_release.py release-notes > draft-release-notes.md |
| 45 |
echo "version=$version" >> "$GITHUB_OUTPUT" |
| 46 |
- name: Create draft release |
| 47 |
env: |
| 48 |
GH_TOKEN: ${{ github.token }} |
| 49 |
VERSION: ${{ steps.release-details.outputs.version }} |
| 50 |
run: | |
| 51 |
set -euo pipefail |
| 52 |
gh release create "$VERSION" \ |
| 53 |
--draft \ |
| 54 |
--title "$VERSION" \ |
| 55 |
--notes-file draft-release-notes.md \ |
| 56 |
--target "$(git rev-parse HEAD)" |