-
Notifications
You must be signed in to change notification settings - Fork 9
100 lines (87 loc) · 3.05 KB
/
prepare-release.yaml
File metadata and controls
100 lines (87 loc) · 3.05 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Prepare Release
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: true
type: choice
options:
- auto
- major
- minor
- patch
default: auto
permissions:
contents: read
env:
FORCE_COLOR: 1
jobs:
prepare-release:
runs-on: ubuntu-24.04
environment: release-auth
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PAT }}
persist-credentials: true
- name: Install the latest version of uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Calculate next version
id: version
env:
BUMP: ${{ inputs.bump }}
run: |
current=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
echo "Current version: $current"
IFS='.' read -r major minor patch <<< "$current"
bump_type="$BUMP"
if [ "$bump_type" = "auto" ]; then
feature_count=$(find docs/changelog -name "*.feature.rst" 2>/dev/null | wc -l)
breaking_count=$(find docs/changelog -name "*.breaking.rst" 2>/dev/null | wc -l)
if [ "$breaking_count" -gt 0 ]; then
bump_type="major"
echo "Auto-detected: major bump (found $breaking_count breaking changelog(s))"
elif [ "$feature_count" -gt 0 ]; then
bump_type="minor"
echo "Auto-detected: minor bump (found $feature_count feature changelog(s))"
else
bump_type="patch"
echo "Auto-detected: patch bump (no feature changelogs)"
fi
fi
case "$bump_type" in
major)
next="$((major + 1)).0.0"
;;
minor)
next="$major.$((minor + 1)).0"
;;
patch)
next="$major.$minor.$((patch + 1))"
;;
esac
echo "Next version: $next"
echo "version=$next" >> $GITHUB_OUTPUT
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.14 tox@latest --with tox-uv
- name: Run release process
run: tox run -e release -- ${STEPS_VERSION_OUTPUTS_VERSION}
env:
GH_TOKEN: ${{ secrets.RELEASE_PAT }}
STEPS_VERSION_OUTPUTS_VERSION: ${{ steps.version.outputs.version }}
- name: Display completion message
run: echo "Release ${STEPS_VERSION_OUTPUTS_VERSION} prepared and pushed successfully!"
env:
STEPS_VERSION_OUTPUTS_VERSION: ${{ steps.version.outputs.version }}