-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (91 loc) · 3.17 KB
/
release.yml
File metadata and controls
105 lines (91 loc) · 3.17 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
101
102
103
104
105
name: Release
on:
workflow_dispatch:
inputs:
bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
- alpha
- beta
- rc
prerelease:
description: 'Mark as pre-release'
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Set up Python
run: uv python install 3.12
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version with uv
id: bump
run: |
BUMP_TYPE="${{ inputs.bump }}"
# For alpha/beta/rc, we need to bump minor first if not already a prerelease
if [[ "$BUMP_TYPE" =~ ^(alpha|beta|rc)$ ]]; then
CURRENT_VERSION=$(uv version --short)
if [[ ! "$CURRENT_VERSION" =~ (a|b|rc)[0-9]+ ]]; then
# Not a prerelease, bump minor first
uv version --bump minor
fi
uv version --bump "$BUMP_TYPE"
else
uv version --bump "$BUMP_TYPE"
fi
# Get the new version
NEW_VERSION=$(uv version --short)
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
# Check if it's a prerelease version
if [[ "$NEW_VERSION" =~ (a|b|rc)[0-9]+ ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "is_prerelease=${{ inputs.prerelease }}" >> $GITHUB_OUTPUT
fi
- name: Sync version to __init__.py
run: |
VERSION="${{ steps.bump.outputs.new_version }}"
sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/" src/abstract_validation_base/__init__.py
echo "Updated __init__.py to version $VERSION"
cat src/abstract_validation_base/__init__.py | grep __version__
- name: Commit version bump
run: |
VERSION="${{ steps.bump.outputs.new_version }}"
git add pyproject.toml uv.lock src/abstract_validation_base/__init__.py
git commit -m "chore: bump version to $VERSION"
- name: Create and push tag
run: |
VERSION="${{ steps.bump.outputs.new_version }}"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin main --follow-tags
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.bump.outputs.new_version }}
name: Release v${{ steps.bump.outputs.new_version }}
generate_release_notes: true
prerelease: ${{ steps.bump.outputs.is_prerelease == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}