Repository navigation
72 lines (64 loc) · 2.67 KB
/
Copy pathpython_release_prep.yaml
File metadata and controls
72 lines (64 loc) · 2.67 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
name: Python Release Prep
# Sets the next version in python/pyproject.toml, renders the changelog fragments in
# python/changelog.d into python/CHANGELOG.md and opens a pull request. Merging that pull request
# starts the Python Release Tag workflow.
on:
workflow_dispatch:
inputs:
version:
description: Optional explicit X.Y.Z. Skips the automatic bump from the fragment types.
type: string
required: false
permissions:
contents: write
pull-requests: write
jobs:
prep:
name: Open release prep PR
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}
- name: Set up uv
uses: astral-sh/setup-uv@v6
- name: Compute next version
id: version
env:
VERSION_OVERRIDE: ${{ inputs.version }}
run: |
version=$(python3 python/scripts/release_version.py --version "$VERSION_OVERRIDE")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Next version: $version"
- name: Set version and render changelog
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
cd python
uv version --no-sync "$VERSION"
uvx towncrier@26.9.0 build --yes --version "$VERSION" --date "$(date '+%B %-d, %Y')"
- name: Open pull request
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
BASE_BRANCH: ${{ github.event.repository.default_branch }}
run: |
branch="release/python-v${VERSION}"
title="Python(chore): v${VERSION} release prep"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b "$branch"
git add -A python/pyproject.toml python/uv.lock python/CHANGELOG.md python/changelog.d
git commit -m "$title"
# A rerun for the same version replaces the branch and updates its open pull request.
git push --force origin "$branch"
if [[ "$(gh pr view "$branch" --json state -q .state 2>/dev/null)" == "OPEN" ]]; then
echo "Updated the open pull request for ${branch}."
exit 0
fi
gh pr create \
--base "$BASE_BRANCH" \
--head "$branch" \
--title "$title" \
--body "Sets the version to ${VERSION} and renders its changelog fragments. Review the version and entries before merging. Merging this pull request tags \`python/v${VERSION}\` and publishes it. See \`python/changelog.d/README.md\`."