mirror of
https://github.com/fastapi/full-stack-fastapi-template.git
synced 2026-10-05 02:14:49 +00:00
👷 Add release automation (#2431)
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
name: Prepare Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
bump:
|
||||
description: Release bump
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
date:
|
||||
description: Release date in YYYY-MM-DD format. Defaults to today.
|
||||
required: false
|
||||
type: string
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
prepare-release:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Dump GitHub context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||
with:
|
||||
python-version-file: ".python-version"
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
||||
with:
|
||||
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum.
|
||||
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837
|
||||
version: "0.11.18"
|
||||
- name: Prepare release
|
||||
env:
|
||||
BUMP: ${{ inputs.bump }}
|
||||
RELEASE_DATE: ${{ inputs.date }}
|
||||
run: uv run python scripts/prepare_release.py prepare "$BUMP" --date "$RELEASE_DATE"
|
||||
- name: Get release version
|
||||
id: release-version
|
||||
run: |
|
||||
version="$(uv run python scripts/prepare_release.py current-version)"
|
||||
echo "$version"
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
- name: Get PR Submit token
|
||||
id: pr-submit
|
||||
uses: tiangolo/pr-submit@d802fdf59bde80bc3eb8bd3259f4cbeec63de4aa # 0.0.1
|
||||
- name: Create release pull request
|
||||
env:
|
||||
BASE_BRANCH: ${{ github.event.repository.default_branch }}
|
||||
GH_TOKEN: ${{ steps.pr-submit.outputs.token }}
|
||||
VERSION: ${{ steps.release-version.outputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
branch="release-${VERSION}-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
|
||||
git config user.name "pr-submit[bot]"
|
||||
git config user.email "pr-submit[bot]@users.noreply.github.com"
|
||||
git switch -c "$branch"
|
||||
git add release-notes.md
|
||||
git commit -m "🔖 Release version ${VERSION}"
|
||||
gh auth setup-git
|
||||
git push --set-upstream origin "$branch"
|
||||
gh label create release \
|
||||
--description "Release preparation" \
|
||||
--color ededed \
|
||||
--force
|
||||
gh pr create \
|
||||
--base "$BASE_BRANCH" \
|
||||
--head "$branch" \
|
||||
--title "🔖 Release version ${VERSION}" \
|
||||
--body "Prepare release ${VERSION}." \
|
||||
--label release
|
||||
Reference in New Issue
Block a user